How to recognize escaped characters in AST?
See original GitHub issueI’m looking for a way to find out whether a given character in an AST String inline node was escaped in the original Markdown.
In particular, I’d like to know this for square brackets. My goal is to enable something like artifact links in SourceForge’s Allura Markdown. You can think of it as an inline marker comparable to a link, but without any use for a custom link text.
With the current CommonMark.NET, I can already scan the text returned as literal strings and check whether there are any [...]
like substrings that I would like to process.
However, for this to work properly, I would like to respect explicit escapes by the user. Thus, \[...]
should not be considered for custom processing, [...\]...]
would recognize the first ]
as a part of the string within the processing-worthy square brackets, etc. Is there a (clean) way to retrieve this bit of information already?
It would, of course, be extra-convenient to receive [...]
groups as a separate inline tag, but as that is not part of the CommonMark standard, I understand it may not be desirable to integrate this feature so deeply in the CommonMark.NET source code.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Thanks for these explanations. I have successfully integrated the feature into a local copy of CommonMark.NET based upon your last solution. In fact, I have changed a few more lines in order to support a new
InlineTag
value for that kind of syntax. (I called itPlaceholder
, because it’s essentially a keyword/string that gets replaced by the host application – if the host application decides it wants to process that particular string rather than insert it as a bracketed literal.)Looking at this feature again, would it be desirable from your side to add it as an activatable “additional feature”, the way it is currently done with the strikethrough feature? Such a “placeholder” feature could help connect Markdown with application-specific content, as it currently happens with SourceForge’s aforementioned artifact links, tag reference on the Stack Exchange network, the table of contents in Roadkill Wiki (this one uses braces, but it is conceptually the same thing), etc.
If you might consider this worthwhile, I could create a unit test and put my modifications on Github for you guys to have a look.
Indeed, all my wishes have been fulfilled 😃