Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting for :markdown filter is too greedy #16

Open
TrevorBurnham opened this issue Nov 21, 2011 · 4 comments
Open

Syntax highlighting for :markdown filter is too greedy #16

TrevorBurnham opened this issue Nov 21, 2011 · 4 comments

Comments

@TrevorBurnham
Copy link

Here's a test case:

!!!5
  p
    :markdown
      This looks fine.
    p Why is this blue?

This renders as

http://cl.ly/030K0s3J1D1g3l0n1v2v

Jade correctly interprets the p as being a separate element, not part of the Markdown, so the highlighting is inaccurate.

@TrevorBurnham
Copy link
Author

Here's another case where the highlighting for the :markdown filter isn't greedy enough:

!!! 5
  p
    :markdown
      This is Markdown

      This is Markdown, too

http://cl.ly/3D040O0g0E2w1y1R3a2A

@TrevorBurnham
Copy link
Author

In the "not greedy enough case," the Markdown highlighting continues if and only if the blank line between the two paragraphs is indented. Jade, however, doesn't care whether it's indented or not.

@enyo
Copy link

enyo commented Jan 23, 2012

Thanks TrevorBurnham for pointing out that inserting intended blank lines "fixes" this behavior. This is at least a workaround.

@KelseyHigham
Copy link

Apparently this is caused by Markdown's treatment of any indented text as raw <pre><code>.

Markdown's Language Grammar, lines 126~130:

    raw_block = {
        begin = '(^|\G)([ ]{4}|\t)';
        name = 'markup.raw.block.markdown';
        while = '(^|\G)([ ]{4}|\t)';
    };

(If you're not fluent in regex, what that says, as best as I can tell, is that while Markdown sees indented code (4 spaces or a literal indent character), it will keep treating text as raw <pre><code>. That's why inserting an unindented line stops the greedy parsing.)

I'm not sure why the markup.raw.block.markdown continues after the actual text.html.markdown should stop, but it implies another workaround:

  1. Go to Bundles > Edit Bundles… > Jade > Language Grammars > Jade
  2. Search for "Markdown" (or go to lines 17~21, if your file looks exactly like mine)
  3. Remove the string include = 'text.html.markdown';, or replace it with include = 'plain.text';

(TextMate will automatically create a copy of your Jade bundle at ~/Library/Application Support/("TextMate" for TM 1, "Avian" for TM 2)/Bundles/Jade.tmbundle; the original is preserved at /Pristine Copy/Bundles. So you don't need to worry about editing the bundle.)

This still doesn't restore Markdown's syntax highlighting, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants