import OrgSwiftUI import SwiftUI /// Renders an issue/MR body or comment in whichever format it was stored as. /// Mirrors `ReadmeView`'s dispatch, keyed on the stored `body_format` rather /// than a file name. A missing format renders as markdown, matching every /// body written before org support existed. struct FormattedBodyView: View { let text: String var format: String? /// The repository `#N` and `!N` refer to; nil links no references. /// The links open through `referenceNavigation()`. var repo: String? @Environment(\.colorScheme) private var colorScheme var isOrg: Bool { format == "org" } var body: some View { if isOrg { // Qualified: `OrgView` here is org-mode, not the organization view. OrgSwiftUI.OrgView( text, styler: OrgSyntaxStyler(colorScheme: colorScheme), keywords: OrgKeywordStyle(todo: .gbOK, done: .gbDone), textTransform: repo.map { repo in { linkReferences(in: &$0, repo: repo) } } ) } else { MarkdownView(markdown: text, referenceRepo: repo) } } }