Sublime Forum

Underscores in Markdown

#1

Hi, I’m not sure if this is the right place for Markdown syntax highlighter questions or if that component is built by some 3rd party - if that’s the case I’d appreciate any hints on who can I contact.

Anyways, my problem is this - in markdown, the bold/italic highlighting is triggered inside words - e.g. “team_build_er” will highlight the string “build”. This is probably correct behaviour as per markdown syntax definition, but I’d really appreciate an option to turn this off and require whitespace character to accompany the asterisk/underscore for it to highlight anything.

The motivation is that I store my technical notes in Markdown and very often I’d have a note on some variable which includes one or more underscores in its name - the text then looks weird and especially if there’s odd number of underscores, the rest of the whole paragraph ends up being highlighted :cry:

Thanks for any hints on how to achieve this :smile:

0 Likes

#2

So in case this helps anyone, here’s my naive take on workaround for disabling the emphasis in the middle of word:

In Packages/Markdown/Markdown.tmLanguage change the line 774:

770:		<key>italic</key>
771:		<dict>
772:			<key>begin</key>
773:			<string>(?x)
774:						(\*|_)(?=\S)								# Open
775:						(?=

Option 1: italic char (_ or *) cannot be preceded by word character - less radical change

774:						\W(\*|_)(?=\S)								# Open

Option 2: italic char (_ or *) must be preceded by whitespace - more radical change

774:						\s(\*|_)(?=\S)								# Open
0 Likes