Thursday, 29 August 2013

Sublime theme regex not working when the line doesn't start with a white space

Sublime theme regex not working when the line doesn't start with a white
space

I'm trying to customize a SublimeText theme for pandoc's markdown syntax.
I want to highlight footnotes references inside paragraphs.
The syntax for footnotes is : [^foo]
I have the following regex : \[\^(.*)\] in my tmLanguage file :
<dict>
<key>comment</key>
<string>Footnotes references</string>
<key>match</key>
<string>\[\^(.*)\]</string>
<key>name</key>
<string>meta.paragraph.markdown.footnote</string>
</dict>
Here's the result :
https://dl.dropboxusercontent.com/u/483488/stackoverflow/sublregex.png
(sorry, I can't insert images...)
Line 149: just the reference. It works.
Line 150: white space and the reference. It works.
Line 151: white space, random text, the reference. It works
Line 152: white space, random text, white space, the reference, white
space, random text. It works.
Line 153: white space, random text, the reference, random text. It works.
Line 154: NO white space, the reference. IT FAILS.
Line 155: same as line 149, it should work but it fails... I guess because
of line 154.
Line 156: blank
Line 157: same as line 149 and 155, it works again...
It seems that my regex or Sublime or something needs a leading white
space. Adding the multiline option (?w) doesn't help.
Do you have any idea of what's going wrong here and how to fix it ?

No comments:

Post a Comment