Closed rchl closed 3 years ago
I'll take a look. We might be doing something funny in the Sublime syntax highlighter.
This doesn't appear to be something innate with Python Markdown. Nor does it seem innate with any of the extensions, so it must be something in the custom highlighter for mdpopups.
Probably just need to rstrip()
the source before highlighting it. I'll run some tests, but I'm betting that will fix it.
Yup, Pygments always strips trailing empty lines in code blocks, and Python Markdown seems to do the same to code blocks at the very end. Should they? That is a subjective question as CommonMark and some others will preserve empty lines at the tail of a fenced code block (not an indented code block). Is that useful? 🤷
So, multiple lines actually come from the Markdown parser. Not sure why, but they were always cleaned up at the end so you never see them, except with our homegrown ST highlighter. We don't rstrip()
the tail because we didn't think to do so. That is why you are seeing the results that you are.
So, rstrip()
is the way to at least bring consistency to everything.
So with the fix, this:
mdpopups.show_popup(view, '''Examples:
res.json(null);
res.json({ user: 'tj' });
res.status(500).json('oh noes!');
res.status(404).json('I dont have that');''')
Now yields:
Sanity restored!
There are some stray empty lines added with markdown like:
An example for testing from the console:
This produces:
It works correctly when the code is followed by unindented line, for example: