Skip to content

Commit

Permalink
added full markdown support
Browse files Browse the repository at this point in the history
One of our markdown consent documents were not rendering properly, hence this. Not sure why Spezi team restricted to inline only - open to feedback!
  • Loading branch information
auddithio committed Mar 5, 2024
1 parent fc94473 commit 985eb86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/SpeziViews/Views/Text/MarkdownView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public struct MarkdownView: View {


/// Creates a ``MarkdownView`` that displays the content of a markdown file as an utf8 representation that is loaded asynchronously.

/// - Parameters:
/// - asyncMarkdown: An async closure to load the markdown in an utf8 representation.
/// - state: A `Binding` to observe the ``ViewState`` of the ``MarkdownView``.
Expand Down Expand Up @@ -95,14 +96,16 @@ public struct MarkdownView: View {
/// Parses the incoming markdown and handles the view's error state management.
/// - Parameters:
/// - markdown: A `Data` instance containing the markdown file in an utf8 representation.
///
/// Example: Data(
/// " # This is a markdown example
/// *This should be italiced* and **this bolded**").utf8
/// - Returns: Parsed Markdown as an `AttributedString`
@MainActor private func parse(markdown: Data) -> AttributedString {
state = .processing

guard let markdownString = try? AttributedString(
markdown: markdown,
options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
options: .init(interpretedSyntax: .full)
) else {
state = .error(Error.markdownLoadingError)
return AttributedString(
Expand Down

0 comments on commit 985eb86

Please sign in to comment.