-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to generate single (raw) backslash #133
Comments
Allan -- I hope you are doing well!! This is basically an effect of precedence order between two quasi-conflicting rules:
So:
First, I agree that:
But I'm not absolutely 100% entirely certain that is correct.... (Don't get me wrong -- I have no strong objection to the common interpretation being considered right, but I think it does require some hand-picking of how to follow the rules in order to get there.) First, there is a workaround:
(The first is more "symmetric", but since it's only the trailing space that matters the second one is also correct.) As for a solution.... Option 1A simple possible solution is to prevent However, unlike other Markdown variants, MultiMarkdown creates more than just HTML and a backtick may be important in current/future formats. So just disabling it is not without consequence. Also, it seems strange to single out So I don't think simply disabling escaped-backticks is a good solution. Option 2Another option is to consider All of which means I think this option is only realistic if used in the "dumb" sense where Conclusion
|
Thanks for your detailed reply, and your well wishes :) As for your conclusion, adding a space can have an impact when the inline raw is followed by more content, as the space will then be using the style of
Will render as: As for this being rare, I believe that a lot of technical documentation will need to render literal escape characters, in fact, your own README.md uses both a single escape character in inline raw, and an escape character followed by a space (and expects them to render differently). I think having raw inline strings that escapes everything is crucial! Knowing that whatever content I have, I can wrap it in backticks and not have to worry about triggering some special mode/character, is not only valuable, but it also makes for nicer to read content. A rule about being able to escape backticks after a backtick, and thus cancelling the inline raw, seems like a can of worms to me, take a string like this: As for a practical solution, can you make |
Forgive the length -- this is partially a response and partially a way for me to track my thoughts on this issue for the future. MMD (version 6) is written such that it doesn't perform backtracking at all (unless there is a small edge case I am forgetting.) Paired tokens (e.g.
Additional BackgroundIt's probably useful to explain what happens when processing with MultiMarkdown v6.
Escaped characters are treated as a single token, since they don't participate in matching (e.g. Because Another way of thinking about this, is that escaped characters are treated has having higher precedence than pairing backticks to form code spans. (I'm not arguing that this is intrinsically "right", just stating what currently happens.) To work around this, there are a few options:
Raw String as Single TokenI don't think that treating the entire raw string as a single token is the right way to go, as MMD would be unable to accurately reflect possible edge cases, nor to identify tokens within that string that must be treated differently for the desired output format (e.g. using More importantly, I'm not sure that there is a way to properly configure this in
(If you can prove me wrong, please let me know!) Option 2 (from above)Even treating
Normally, because the third backtick is escaped, this becomes (in almost all variants):
If instead the middle was treated as a single token, it would become:
This is because the first backtick would start a code span, but a matched "closer" would not be found until the 4th backtick, since the middle 2 are wrapped up as a single token. To work around this, However, this would not work "properly" here:
In this case, the opening double-backtick would not match with a single backtick followed by the new token. Option 1 (from above)I experimented with removing
This works ok if we prevent a backtick from opening if preceded by a backslash. However, this does not work:
Because now the entire group of backticks are blocked from opening. This would lead to the need to further analyze backtick tokens and modify them based on surrounding text, some of which won't be understood until after later processing steps. Option 3A tweak to the previous "workaround" would be to check for an escaped space at the end of the raw string, and then ignore it in that case:
This actually brings MultiMarkdown closer inline with regular Markdown, as the trailing space would be ignored normally, since Markdown doesn't have a concept of escaped spaces (MultiMarkdown uses them to trigger a non-breaking space when desired.) I have pushed this change into the Other Comments
Saying that it's not rare when it's used isn't really a logically helpful statement.... ;) Amongst all MultiMarkdown users, having a backslash as the final character in a code span is sufficiently rare that I believe you are only the second person to contact me about it. I suspect that it is not rare for you, but it's still rare for most others.
I agree, however as I mentioned before here we have a situation where two rules contradict each other. The escape syntax I am not inherently opposed to Conclusion
|
I am unable to output a single backslash in raw mode.
On the left is input and right shows output:
Using v6.3.2 installed via homebrew.
The text was updated successfully, but these errors were encountered: