brrd / abricotine

Markdown editor with inline preview
GNU General Public License v3.0
2.63k stars 159 forks source link

Greyed out lines when after <de> #278

Closed ghost closed 4 years ago

ghost commented 4 years ago

following code

abc <de>
greyed_out_line_1
greyed_out_line_2

makes Abricotine enclose following lines to be enclosed in grey box.

brrd commented 4 years ago

The grey background indicates html code. In markdown tags are interpreted as html (this is a part of the original specs). Most markdown parsers would produce the following html export from your code:

<p>abc <de> greyed_out_line_1 greyed_out_line_2</de></p>

You can use this solution: https://stackoverflow.com/questions/41705811/how-do-i-type-html-in-a-markdown-file-without-it-rendering

Having said that, the grey background will probably be removed in a future release due to another issue (#274).

ghost commented 4 years ago

You don't need to insert html tag to produce this bug. If you change \<de> to <de next two lines will still be greyed out.

brrd commented 4 years ago

<de is considered as the beginning of an html tag, so the following line is actually the contents of the tag. It's the way CodeMirror is parsing markdown. If you really think this is an issue then please report it to CodeMirror project: https://github.com/codemirror/CodeMirror/issues

ghost commented 4 years ago

According to HTML syntax <de is not a tag. You can't just take some random string and say it is a tag. Same you could say that de> is a tag but it's not. No editor I know will color part of any programming language because it could be part of syntax. e.g. no language will colorize fo because it could be for. If you enter whole keyword "for" only then it will be colored. If you start typing fo you might just end it's differently e.g. foo which is not keyword so it does not make sense to colorize fo because it is prefix of some keyword.

brrd commented 4 years ago

This is valid XML:

<div
  id="foo"
  class="bar"
  hello
  world
>
baz
</div>

If you are interested in this subject, I recommend that you read Marijn Haverbeke's articles on parsing, which explain why it is difficult with the current CodeMirror parser to process certain ambiguous multiline expressions: https://marijnhaverbeke.nl/blog/#parsing

This should evolve in the next CodeMirror though.

And if you really want to nitpick about details, please contact the contributors responsible for this part of the code directly: https://github.com/codemirror/CodeMirror/issues

I'm locking this conversation because I don't think it will be useful for Abricotine development.