MyST-Parser
MyST-Parser copied to clipboard
Allow newlines for role syntax parsing
I noticed that when my {download} inline markup flows across lines, the parsing fails. For example:
from myst_parser.main import to_html
markdown = """
{download}`Link text <test_long_link.py>`.
Here the link runs across lines, breaking parsing {download}`Here is a short
piece of link text <test_long_link.py>`.
"""
print(to_html(markdown))
generates
p><code class="sphinx-role">{download}[Link text <test_long_link.py>]</code>.</p>
<p>Here the link runs across lines, breaking parsing {download}<code>Here is a short piece of link text <test_long_link.py></code>.</p>
Is this expected? It does not seem to be the case for Sphinx / ReST parsing.
the way how roles are currently indentified in https://github.com/executablebooks/mdit-py-plugins/blob/5c0038fd4348cc37548b3ee7891a9f380517f959/mdit_py_plugins/myst_role/index.py#L8, it is expected.
but this could be relatively easily changed to allow for new line breaks
In the meantime we should document that roles cannot span multiple lines as well (unless you think this enhancement will be done easily/quickly? wdyt?)
It's pretty easy to run over a line in a role, by accident, so my vote would be to change the behavior. Are there other Markdown inline markups that cannot run over lines?
we have come across this bug a couple times in some of our projects during migration checks. @AakashGfude perhaps we can see if this regex can be updated to accept newlines for roles.