Sublime Forum

Custom Markdown syntax highlighting

#1

I’m trying to adjust Sublime’s Markdown syntax highlighting in three cases so that it matches the rules of a custom variant of markdown I’ve created for myself using marked.js. The new syntax is as follows:

/this should be italics/
*This should be boldface*
__This should be underline__

Ideally, it would be awesome if nested syntax was also recognised… So that something like __underline *with bold /and italic/ was* matched__.

I realise this is probably a big task, but if someone could just point me in the general direction of what needs to be adjusted, that would be a huge help! The complexity of Sublime’s syntax highlighting system is impressive, but it makes getting started with tweaking it a bit daunting…

0 Likes

#2

I guess you could start by reverse-engineering a Markdown.sublime-syntax that someone else has built, like so:

For me however, the elephant-in-the-room question is: Wouldn’t it be better/faster/more future proof to reconfigure your parser to export conventional markdown?

In every MD syntax I have ever met *word* is emphasis and **word** is bold. Why reinvent the wheel?

0 Likes

#3

Thanks for this! I’ll have a go at digging into the file and see if I can figure out what needs to be modified.

As for the elephant-in-the-room question… the default MD syntax for boldface and italics seems less-then-perspicuous, to me, and since marked.js makes it trivial to enable/disable syntax extensions, I don’t see a reason not to adjust the syntax to suit my preferences. It doesn’t actually break anything, and the markdown interpreter I’m building lets that syntax adjustment be disabled to go back to the standard syntax anyway.

0 Likes