When working on with Markdown, there are sometimes alternate dialects that you'd like to handle. These might simply be as simple as the language-tags on code-blocks, as complicated as custom sorting tools for Markdown Tables, and often these are project specific tweaks that wouldn't be appropriate to merge into the core Ignite library.
It'd be great if there was a mapping step, where instead of directly emitting strings, users could hook full Ignite components.
// Current Implementation
func visitOrderedList(_ orderedList: Markdown.OrderedList) -> String {
var result = "<ol>"
for listItem in orderedList.listItems {
result += visit(listItem)
}
result += "</ol>"
return result
}
// Instead:
func visitOrderedList(_ orderedList: Markdown.OrderedList) -> Element {
return (tagOverrides.OrderedList ?? MarkdownOrderedList)(listItems: visit(orderedList.listItems))
}
// Where tagOverrides obviously needs some way to be populated by the project -- ideally even allowing for different patches in different content directories.
Note: I think this should emit Element instead of String to allow these components to play nice with #3 and #2 -- Otherwise Markdown pages wouldn't be able to have a hypothetical AutomaticOutline static-component.
Alternatives Considered
Don't let people tweak the rendered tags 😢
Let people provide an alternative MarkdownVisitor implementation -- this would be clunky, but probably would work, but would require much more patching from the consumer code.
Purpose
When working on with Markdown, there are sometimes alternate dialects that you'd like to handle. These might simply be as simple as the language-tags on code-blocks, as complicated as custom sorting tools for Markdown Tables, and often these are project specific tweaks that wouldn't be appropriate to merge into the core Ignite library.
Proposed Implementation
In this module, there are a ton of
visit*
methods that each render raw html. https://github.com/twostraws/Ignite/blob/main/Sources/Ignite/Rendering/MarkdownToHTML.swiftIt'd be great if there was a mapping step, where instead of directly emitting strings, users could hook full Ignite components.
Note: I think this should emit
Element
instead ofString
to allow these components to play nice with #3 and #2 -- Otherwise Markdown pages wouldn't be able to have a hypotheticalAutomaticOutline
static-component.Alternatives Considered