Home Download Buy Blog Forum Support

Underscores in Markdown

Underscores in Markdown

Postby Jacobs on Tue Aug 28, 2012 7:38 am

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 :-)
Jacobs
 
Posts: 4
Joined: Mon Jan 16, 2012 8:35 am

Re: Underscores in Markdown

Postby Jacobs on Thu Dec 13, 2012 10:35 am

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:

Code: Select all
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
Code: Select all
774:                  \W(\*|_)(?=\S)                        # Open


Option 2: italic char (_ or *) must be preceded by whitespace - more radical change
Code: Select all
774:                  \s(\*|_)(?=\S)                        # Open
Jacobs
 
Posts: 4
Joined: Mon Jan 16, 2012 8:35 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 22 guests