Fix trailing space breaking blocks if placed after the start delimiter or end delimiter. #55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
So you might not agree with this "fix" but at least a PR has the merit to document this particular way of doing things.
I'm trying to fix the following issue: having trailing spaces or characters after the block delimiters breaks parsing, for instance:
Discussion
You may object: but this is not a valid block syntax anyway and people should do a proper line return.
This is my argument: at the very least we should be agnostic to trailing spaces which happen quite often and is hard to spot.
Breaking parsing on trailing spaces would be quite confusing for the user.
Now why admit characters? Sure, why not taking into account characters after the starting delimiter... but who would ever want to put characters after the end delimiter right? (Markdown should be human readable anyway).
My argument: I have real-time rendering of my markdown code, and while typing I may for a moment forget to insert a line return. As is, it temporally breaks rendering of unrelated lines, which is confusing. I would also argue that, even without real-time rendering, if someone mistakenly leaves characters the way it breaks remains confusing.
Solution
For now my solution was to simply modify the regexpr that detect the start and end delimiters.
I allowed for any trailing characters and refeed them to the parser.
One caveat is that while I could refeed the line after the start delimiter to be inserted in the final math block.
I could not figure out how to refeed the line after the end symbol to be interpreted as markdown.
I think that's ok because as discussed, one should not actually do that anyway,
and having the markdown syntax not working for that particular line,
is probably the most graceful way to fail and hint the user that this is not the proper way.
(as oppose to break unrelated stuff around.)
Settings used