jonschlinkert / sublime-markdown-extended

Top 100 Sublime Text plugin! Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3. Goes great with Assemble.
https://github.com/jonschlinkert
MIT License
660 stars 96 forks source link

Support kramdown style fenced code blocks #35

Closed raphinesse closed 10 years ago

raphinesse commented 10 years ago

This adds support for highlighting in kramdown style fenced code blocks.

jonschlinkert commented 10 years ago

Thanks!

raphinesse commented 10 years ago

That was fast :+1:

raphinesse commented 10 years ago

Unfortunately I just discovered that kramdown allows you to open a code block with three or more ~ characters. As far as I can see it GFM does not allow this. To fix this the language definition would have to be amended to something like this:

<dict>
  <key>begin</key>
  <!-- changed -->
  <string>(```|(~){3,})\s*(java)\s*$</string>
  <key>captures</key>
  <dict>
    <key>1</key>
    <dict>
      <key>name</key>
      <string>punctuation.definition.fenced.markdown</string>
    </dict>
    <!-- changed -->
    <key>3</key>
    <dict>
      <key>name</key>
      <string>variable.language.fenced.markdown</string>
    </dict>
  </dict>
  <key>end</key>
  <!-- changed -->
  <string>(\1\2*)\n</string>
  <key>name</key>
  <string>markup.raw.block.markdown markup.raw.block.fenced.markdown</string>
  <key>patterns</key>
  <array>
    <dict>
      <key>include</key>
      <string>source.java</string>
    </dict>
  </array>
</dict>

I'm not that firm with these TextMate definitions, so it would be nice if you could take a look at it before I make the necessary changes.

jonschlinkert commented 10 years ago

perhaps I should just include a kramdown version?

raphinesse commented 10 years ago

On second glance that would probably be the right way to do it. Could be quite some work though. As I said, I don't know that much about the capabilities of TextMate grammars but there could be some features which might be tricky to get right. But on the other hand kramdown's syntax is very thoroughly defined.