MarkdownView

struct MarkdownView : View

SwiftUI View for a Markdown text

This View is used for Help and is parsing the Documentation Catalog

Note

The first heading is ignored; the Views have to show it themself
  • The Help model

    Declaration

    Swift

    @EnvironmentObject
    var help: HelpModel { get }
  • The Markdown String that will be formatted

    Declaration

    Swift

    let markdown: String
  • The body of the View

    Declaration

    Swift

    var body: some View { get }

Convert a Markdown string to an array

Headings

  • Convert a Markdown heading into seperate components

    Declaration

    Swift

    func convertHeading(text: String) -> (text: String, level: Int)

    Parameters

    text

    a String with a Markdown heading

    Return Value

    a stripped text and the level of the header

  • Format a heading

    Declaration

    Swift

    @ViewBuilder
    func formatHeading(text: String, level: Int) -> some View

    Parameters

    text

    the text of the heading

    level

    the level of the heading

    Return Value

    the formatted heading in a Text view

List items

  • Format a list item

    Declaration

    Swift

    @ViewBuilder
    func formatListItem(text: String) -> some View

    Parameters

    text

    the text of the list item

    Return Value

    a formatted list item in an HStack view

Code blocks

  • Format a code block

    Declaration

    Swift

    @ViewBuilder
    func formatCodeBlock(text: String) -> some View

    Parameters

    text

    the text of the code block

    Return Value

    a formatted code block in an HStack view

Attributed string

  • Format a string if it has atributes

    Declaration

    Swift

    @ViewBuilder
    func formatAttributedString(text: String) -> some View

    Parameters

    text

    the Markdown text

    Return Value

    the formatted text in a Text view

Quote

  • Format a quote

    Declaration

    Swift

    @ViewBuilder
    func formatQuote(text: String) -> some View

    Parameters

    text

    the Markdown text

    Return Value

    the formatted text in a Text view