Wonder how one would support this within commonmark, even if it’s as an extension hook. If using custom containers like in https://markdown-it.github.io/ , then it may look like this:
I think this kind of thing is best handled using fenced code blocks that are marked in a special way, plus some kind of filter on the AST, as in the gitit wiki.
That brings to mind the question of if commonmark has a way to marking a fenced block as something that should be treated differently if a AST filter is present, else display as a marked up syntax. (e.g. runnable python code, or dot diagrams)
so the info string is any text after the ``` but with a space? If so then there would be a distinction between:
No Space:
```dot
-- put your dot diagram here
```
and With Space
``` dot
-- put your dot diagram here
```
Where the first one would be rendered as just “block code” but with dot syntax markup and the second as a “dot diagram”? So with that logic, to have a “dot diagram” with “dot code fallback”, it would look like?:
and if you want just the dot code without the dot diagram? (Specifically say… the author is illustrating how to write dot code?). Perhaps .dot instead of dot in infotext indicate that it must be displayed as code?
and if you want just the dot code without the dot diagram? (Specifically say… the author is illustrating how to write dot code?). Perhaps .dot instead of dot in infotext indicate that it must be displayed as code?
Well, it’s up to the particular application to define this. (There are so many special purpose things like this you might want to do, it would not make sense to build them into the spec.) An application could use anything it likes in the info string to trigger dot rendering. If you want to mix dot syntax examples with rendered diagrams, then you might want to use a different convention than the one used in gitit.
That sounds rather fair. I can imagine the spec would have a section on recommendation for trigger words to always be provided e.g.diagram like:
``` dot diagram
...
```
And if diagram is not in infostring, then the plugin would simply ignore it and let it fall to code block mode.
Which would mean that by convention, the plugin will not activate without seeing the diagram keyword in the info-string (could be other keywords as it’s only a recommendation, not a standard).
I cannot and don’t want to see CM adopting English trigger words.
However, there’s syntax precedent for embedding instead of more or less verbatim rendering: the exclamation mark in image syntax vs. normal hyperlinks. I could see extensions adopting this letter for the info string, e.g.:
I totally agree with embracing the exclamation point as a generic marker of embedding content in commonmark, and this aligns with what I suggested elsewhere to disambiguate image link syntax and convert alt text into a visible caption.
Keep in mind that Mermaid, Viz.js (Graphviz), et al. are one of those things that should work fine today as embedded HTML with not much more syntax burden than fenced code blocks would require.
Whether that translates into usable graphing behavior when exporting to PDF or ePub, e.g., from a given implementation may be a different, more difficult, story.
Essentially a no-markdown island. Of course, you could also have a filter in front of the AST to catch and modify the behaviour before it defaults back to webcomponent mode.
alt field is heavily encouraged by w3 for disability accessibility reasons. So infotext should always be included in alt field to encourage it’s usage. (e.g. blind users can understand what the diagram is suppose to be.)
Note, until the official mermaid supports webcomponents, if the above approach is adopted… you will need to type like this:
``` !div { .mermaid }
CHART DEFINITION GOES HERE
```
<div class="mermaid">
CHART DEFINITION GOES HERE
</div>
Alternatively, you can have a official commonmark-mermaid plugin that captures the web-component and output the correct html code for the mermaid engine (at least until they switch to webcomponents).
Another approach is to say that “.dot” and “#dot” in infotext means a div with either a class=dot or id=dot. ( e.g. .mermaid is equiv to !div { .mermaid } )
If people like this idea and it has not been discussed before, I could probbly paste this into it’s own thread. Or maybe slip it into the “no markdown island” if relevant.
I don’t like the generic attribute syntax with curly braces at all, but I could live with special-casing strings that are introduced by dot . or hash # in places that don’t get rendered. The exact treatment depends on the output format, HTML attributes id and class are obviously the default case. Other places than the info string of a start fence are the location and reference parts of links, but it’s not as compatible with existing implementations, e.g.:
In most cases the generic attribute syntax can be omitted if you do not need to set any values in html (or plugin/extention settings). (basically I know it’s ugly, but it helps avoid overloading the most common commonmark syntax, by moving the cruft to an optional {}.
On the question of compatibility. This is what it would generally look like (in current commonmark):