[txmt-dev] Grammar parser multiline match?

Per Persson persquare at mac.com
Mon Nov 4 22:11:44 UTC 2013


Hi,

when working with Markdown, I prefer using Setext title (===) and subheading (---) for level 1 and 2 headings respectively.
However, Setext headings have some quirks in that they 
	1) show up as === or --- in the symbol popup rather than the heading text, and 
	2) the heading text doesn't have a distinct scope assigned


Currently TextMate 2 with the Markdown bundle assign the following scopes: 

   ## Heading2      <-- markup.heading.2.markdown entity.name.section.markdown
   ^                
   |                
   + ------------------ markup.heading.2.markdown punctuation.definition.heading.markdown


   Heading2Setext   <-- meta.paragraph.markdown
   --------------   <-- meta.paragraph.markdown markup.heading.setext.2.markdown


I can live without the symbol popup but for my purposes I needed to be able to scope the heading text, so I set out to augment the Markdown bundle like so:                     

   Heading2Setext   <-- markup.heading.setext.2.markdown entity.name.section.markdown
   --------------   <-- markup.heading.setext.2.markdown punctuation.definition.heading.markdown

Here the underlining would be treated like the ###s above and the text would show up in the popup.


After hammering on the Markdown grammar for a while it dawned on me that while the grammar gladly accepts multiline flags (?m) matching is performed on a line by line basis. 

So, in conclusion:

1. Am I correct in that the grammar parser cannot match something like '(?m:foo\nbar)'? 
2. Is the scoping I described above possible with the current parser?
3. Would it be possible to modify the parser to make it work, even if only as an interesting exercise?

Best regards, and thanks for a great editor,
Per











More information about the textmate-dev mailing list