Hi,
I am experimenting with embedding properties in Objective-C implementations that will be parsed out and placed into a header file, and that also include documentation. They are supposed to look like this:
/*@property BOOL testProperty; Sample Property # Discussion This is documentation in Markdown syntax */
My custom Objective-C language definition includes this pattern:
{ name = 'meta.property.objc.embedded'; begin = '^(/*)(?=@property)'; end = '*/'; beginCaptures = { 0 = { name = 'meta.comment.embedded-property.start'; }; }; endCaptures = { 0 = { name = 'meta.comment.embedded-property.end'; }; }; contentName = 'meta.scope.property.objc.embedded'; patterns = ( { name = 'meta.scope.property.def.objc.embedded'; begin = '(?=@property)'; end = ';\s*\n?'; patterns = ( { include = 'source.objc#interface_innards'; } ); }, { name = 'meta.scope.property.doc.objc.embedded'; begin = '^'; end = '$\n'; // patterns = ( { include = 'text.html.markdown'; } ); }, ); },
That works fine, the /* and */ have the proper start/end scope, the documentation part has the doc scope etc. But as soon as I enabled the uncommented line that is supposed to highlight the embedded documentation with markdown, markdown gobbles up the end markers.
Shouldn't the outer pattern prevent this? And if not, how can I make this work?
Thanks
Gerd
On 26 Nov 2013, at 22:36, Gerd Knops wrote:
[…] as soon as I enabled the uncommented line that is supposed to highlight the embedded documentation with markdown, markdown gobbles up the end markers.
Shouldn't the outer pattern prevent this?
The problem is that Markdown will do nested rules to track indent etc.
So you include a rule that does begin/end and stays inside the included rule’s children array when seeing the newline, which is why the outer rule’s end pattern is not being used.
And if not, how can I make this work?
Including the markdown grammar as-is cannot be made to work. What could work is to only include inline styles from the markdown grammar, as it’s the block level elements that are problematic (and presumably they are problematic beyond the end marker, as for example, indented text is matched as raw, but your comment may itself add to this indent (that should be ignored by markdown)).
Disclaimer: I didn’t actually look through the markdown grammar. It might not be written for allowing including “just the inline styles”, but possibly some refactoring could allow it.