-
-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Add concrete syntax details
It would be nice to have concrete syntax information on certain nodes, for example, which bullet type was used for a list item.
Problem
When using a markdown parser to modify markdown and write it back to a file, it would be nice to re-use the same style as the original markdown content. Currently, there is no way to get this information to either use inside a compiler or to set the compiler options.
Expected behaviour
Syntax details included in tree Nodes. Below an example for emphasis
Interface
interface Emphasis <: Parent {
type: "emphasis"
character: string?
children: [TransparentContent]
}
Markdown:
*alpha* _bravo_
Yields:
{
type: 'paragraph',
children: [
{
type: 'emphasis',
character: '*',
children: [{type: 'text', value: 'alpha'}]
},
{type: 'text', value: ' '},
{
type: 'emphasis',
character: '_',
children: [{type: 'text', value: 'bravo'}]
}
]
}
When recompiling the above tree back to Markdown, it would render back to *alpha* _bravo_
rather than *alpha* *bravo*
, unless the compiler is explicitly set to use a certain character for emphasis.
Alternatives
This could be implemented without any compiler modifications by having a utility that detects the used syntax and sets the compiler's options accordingly.