vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

Plain less than (<) in list will disable syntax highlighting from that point onwards

Open lonAlpha opened this issue 11 years ago • 7 comments

After putting a < sign in a list, text after that sign are not highlighted.

**highlighted**

- **highlighted**
- < **not highlighted**

**not highlighted**

**not highlighted**

lonAlpha avatar Oct 29 '14 06:10 lonAlpha

Thanks for the report: I reproduce, and it is serious as it breaks the syntax of the entire file.

On future posts, please post your markdown code as escaped code on the request so we can see it unredered. I've updated that, and made the example easier to reproduce. Feel free to edit again if you think meaning was lost.

cirosantilli avatar Nov 14 '14 07:11 cirosantilli

Same problem.

And simply escape the "<" doesn't help.

2015-02-19 5 15 58

MForever78 avatar Feb 20 '15 16:02 MForever78

While this issue still exists, I noticed it works as intended when the < symbol is inside LaTeX math delimiters (e.g., $x < 1$) and vim_markdown_math is enabled.

achilleas-k avatar Oct 15 '15 14:10 achilleas-k

It looks like the behavior is somehow inherited from the html.vim syntax file: I see the same thing if I do set syntax=html.

ptzz avatar Oct 18 '15 00:10 ptzz

See also #104

tpo avatar May 30 '19 10:05 tpo

My solution is to redefine htmlTag. Add following code in your after/syntax/html.vim.

syn clear htmlTag
syn region htmlTag start=+<[[:alnum:]]+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
"                          ^^^^^^^^^^^ redefined this part

Since it's likely to have a space after <, it would work most of the times. This actually is the correct definition of the html tag according to the specification.

  1. The first character of a start tag must be a U+003C LESS-THAN SIGN character (<).
  2. The next few characters of a start tag must be the element's tag name. ...

Tags contain a tag name, giving the element's name. HTML elements all have names that only use ASCII alphanumerics.

Similarly, if you don't want > to be highlighted as htmlError, you can simply clear its definition as well.

tomtomjhj avatar Jul 06 '20 16:07 tomtomjhj

@tomtomjhj nice workaround! However it doesn't catch cases like my vim takes <1sec to start. Instead, I'd patch htmlTag to include the oneline argument:

syn clear htmlTag
syn region htmlTag start=+<[^/]+ end=+>+ fold oneline contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster

azrdev avatar Jan 08 '21 15:01 azrdev