textmate / GitHub-Markdown.tmbundle

:octocat: GitHub Flavoured Markdown for TextMate
MIT License
40 stars 12 forks source link

Support frontmatter #9

Closed noniq closed 8 years ago

noniq commented 8 years ago

Based on https://github.com/textmate/markdown.tmbundle/issues/27

This is not strictly speaking a feature of “GitHub markdown”, so not sure if you want to include it. I could of course create a dedicated bundle for it, too.

The grammar needs to be injected to have precedence over the default Markdown grammar (which parses --- as setext header). Therefore I created a new grammar instead of just adding the rules to the “Markdown (GitHub)”.

I also extended the preview command to strip a YAML frontmatter before converting the document to markdown.

I tested several edge cases (frontmatter only, no end delimiter for frontmatter, …) and both highlighting and preview seem to work fine. I’d be happy to support this in the future, too, if any problems should appear.

MikeMcQuaid commented 8 years ago

Will have a think about this; a dedicated bundle might be best, though.

noniq commented 8 years ago

Makes sense. What would be the best way of extending / changing the preview command from a dedicated bundle? I’m thinking including an adapted copy of redcarpet.rb in the bundle and then setting $TM_MARKDOWN to point to this copy. But setting this variable from within the bundle isn’t possible, is it? (I’d like to avoid the need for manual configuration / installation as much as possible).

Are there any other ways?

MikeMcQuaid commented 8 years ago

I guess I'd look at extending this bundle like how this bundle has done to the Markdown bundle.

noniq commented 8 years ago

This will now be implemented as a separate bundle, see https://github.com/noniq/Markdown-Front-Matter.tmbundle

MikeMcQuaid commented 8 years ago

Thanks @noniq!