<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I'm trying to put together a grammar and having a hard time getting the pattern matching right.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>The line I'm interested in will be in the following format--</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>KW: [any text except a percentage sign can go in here] % (fold)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>What I want to do is apply the scope comment.line.percentage from the % sign to the end of the line, and variable.notes to everything in between KW: and the percent sign.  I also want to be able to use Markdown-style italics within the variable.notes section.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Here is the patterns block as I have constructed it thus far:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>patterns = (</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">         </SPAN>{<SPAN class="Apple-tab-span" style="white-space:pre">   </SPAN>name = 'comment.line.percentage';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                    </SPAN>match = '%.*$';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">              </SPAN>},</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">           </SPAN>{<SPAN class="Apple-tab-span" style="white-space:pre">   </SPAN>begin = '^KW:';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                      </SPAN>end = '% \(fold\)|$';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                        </SPAN>patterns = (</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                         </SPAN>{<SPAN class="Apple-tab-span" style="white-space:pre">   </SPAN>name = 'markup.italic.notes.variable';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                                       </SPAN>match = '\*[^\*]+?\*';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                               </SPAN>},</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                   </SPAN>);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                   </SPAN>contentName = 'variable.notes';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">              </SPAN>},</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">           </SPAN>{<SPAN class="Apple-tab-span" style="white-space:pre">   </SPAN>name = 'markup.italic.notes';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                        </SPAN>match = '\*[^\*]+?\*';</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">               </SPAN>},<SPAN class="Apple-tab-span" style="white-space:pre">  </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">     </SPAN>);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This does everything correctly except the % (fold) only acquires the scope of the whole grammar and not the comment scope.  Anything following a percentage sign on a line that doesn't begin with KW: is matched fine.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Any help on how to construct the grammar to match the end of this line would be appreciated!</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Colin Hahn</DIV><DIV><I style="font-style: italic; "><SPAN class="Apple-style-span" style="font-style: italic; "><SPAN class="Apple-style-span" style="font-style: italic; ">»Geben Sie mir Kaffee, dann mache ich Phänomenologie daraus.«</SPAN></SPAN></I></DIV><DIV>"Give me my coffee so that I can make phenomenology out of it." -- Edmund Husserl</DIV><BR class="Apple-interchange-newline"></SPAN></SPAN> </DIV><BR></DIV></BODY></HTML>