yzhang-gh / vscode-markdown

Markdown All in One
https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
MIT License
2.91k stars 322 forks source link

Liquid tags within Markdown sections are not always handled correctly #1330

Open ianjevans opened 1 year ago

ianjevans commented 1 year ago

What's the problem

The Markdown plugin's syntax highlighter doesn't properly handle Liquid tags embedded within Markdown.

We author documentation using Jekyll, which uses Liquid tags within the Markdown.

Liquid tags typically are wrapped with {% foo %} or {{ bar }} symbols.

To comment out sections in Jekyll, you're supposed to use the Liquid {% comment %} and {% endcomment %} tags because it strips out the commented sections before it gets processed by the parser.

If you try to use these tags in VS Code, you get strange behavior.

Screenshot 2023-09-07 at 2 58 35 PM

It's not clear what triggers the end of the comment, as sometimes it continues into the next section.

Screenshot 2023-09-07 at 2 51 41 PM

What's the expected result

The Markdown plugin should handle Liquid tags within Markdown, particularly Liquid/Jekyll style comment tags.

How to reproduce

  1. Wrap part of a Markdown file with {% comment %} and {% endcomment %} tags.

# A Heading 

This is an intro sentence.

{% comment %}
This paragraph should be commented out.
{% endcomment %}

This paragraph should not be commented out.

{% comment %}Another commented out sentence.{% endcomment %} But this sentence should show up.

Current output:

Screenshot 2023-09-07 at 3 11 34 PM

Other information

I've installed the VS Code Liquid plugin but when you override the syntax highlighter to use it instead, it doesn't render the Markdown well, and has its own syntax problems with different symbols.

yzhang-gh commented 1 year ago

Thanks for the feedback.

There seem to be two things: { syntax highlight, rendering } of Liquid tags. The syntax highlight could be done by writing some tmLanguage rules (as how it is done for the Math syntax) and the latter requires a markdown-it plugin which changes how Markdown is converted to HTML.

They are not easy. Given the popularity of Jekyll, there may be someone willing to help.