mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.92k stars 714 forks source link

markdown highlighting with html attributes #3979

Closed nonumeros closed 3 years ago

nonumeros commented 3 years ago

is there a way to exclude the underscore _ value of an html attribute from being identified/highlighted as italics text from a markdown file, as long as, and obviously, is enclosed within its html respective opening and closing tags <, >. Then only reason I mentioned the delimiters/symbols/signs < and > is simply because I think is customary in html to write it within double quotes. And with or without it makes no difference on the error. Looking at the regex of markdown.kak I wouldn't know where to start really.

e.g of the annoyance<a href="https://google.com" target="_blank">this text should not be emphasized</a>

Other html elements that I presume would have the same issue

_self   
_parent 
_top        

possibly related after writing the above https://github.com/mawww/kakoune/issues/2111

Ordoviz commented 3 years ago

Add the following lines to markdown.kak:

require-module html
add-highlighter shared/markdown/inline/tag region </?(a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdi|bdo|big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|data|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frame|frameset|h[1-6]|head|header|hr|html|i|iframe|img|input|ins|kbd|label|legend|li|link|main|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|picture|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|source|span|strike|strong|style|sub|summary|sup|svg|table|tbody|td|template|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video|wbr) > ref html/tag

Read :doc highlighters if you want to understand it. I got the list of HTML tags from w3schools.com.

nonumeros commented 3 years ago

@Ordoviz thanks a bunch. Your code should definitely be on the wiki or as a sticky. Heck. Let's try to move it to source. @lenormf would this be possible?

When you mentioned w3schhols.com , it reminded me of a user on stackexchange network, saying not to refer to that site. https://superuser.com/questions/707522/html-historical-or-technical-reason-for-target-blank-with-underscore#comment903673_707774 If true, imagine what you could have done with well-documented sources then. Thanks again.