From 3a591ed511ff5d1d63a6685719c2d5708e4741a8 Mon Sep 17 00:00:00 2001 From: Stephan Partzsch Date: Wed, 6 Mar 2024 21:29:16 +0100 Subject: [PATCH] Fix crash with invalid URL (https://github.com/SimonFairbairn/SwiftyMarkdown/pull/102). Done by https://github.com/kushak --- Example/SwiftyMarkdownExample/example.md | 2 +- Sources/SwiftyMarkdown/SwiftyMarkdown.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/SwiftyMarkdownExample/example.md b/Example/SwiftyMarkdownExample/example.md index 75cb1f6..7c15f20 100644 --- a/Example/SwiftyMarkdownExample/example.md +++ b/Example/SwiftyMarkdownExample/example.md @@ -18,7 +18,7 @@ Customise fonts and colors easily in a Swift-like way: It supports the standard Markdown syntax, like *italics*, _underline italics_, **bold**, even _**boldItalic**_, `backticks for code`, ~~strikethrough~~, and headings. -It ignores random * and correctly handles escaped \*asterisks\* and \_underlines\_ and \`backticks\`. It also supports inline Markdown [Links](http://voyagetravelapps.com/). +It ignores random * and correctly handles escaped \*asterisks\* and \_underlines\_ and \`backticks\`. It also supports inline Markdown [Links](http://voyagetravelapps.com/ ). > It also now supports blockquotes > and it supports whole-line italic and bold styles so you can go completely wild with styling! Wow! Such styles! Much fun! diff --git a/Sources/SwiftyMarkdown/SwiftyMarkdown.swift b/Sources/SwiftyMarkdown/SwiftyMarkdown.swift index c12c5cf..5effe98 100644 --- a/Sources/SwiftyMarkdown/SwiftyMarkdown.swift +++ b/Sources/SwiftyMarkdown/SwiftyMarkdown.swift @@ -574,7 +574,7 @@ extension SwiftyMarkdown { if let linkIdx = styles.firstIndex(of: .link), linkIdx < token.metadataStrings.count { attributes[.foregroundColor] = self.link.color attributes[.font] = self.font(for: line, characterOverride: .link) - attributes[.link] = token.metadataStrings[linkIdx] as AnyObject + attributes[.link] = URL(string: token.metadataStrings[linkIdx]) as AnyObject if underlineLinks { attributes[.underlineStyle] = self.link.underlineStyle.rawValue as AnyObject