<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Hi Folks.<br></div><div><br></div><div>I am writting  a Parser Grammar in the XTreams package <a href="http://squeaksource.com/@BPfsPY0nJbH9IXBW/wqWrIinC" target="_blank">http://squeaksource.com/@BPfsPY0nJbH9IXBW/wqWrIinC</a><br></div><meta content="text/html; charset=utf-8"><div><br></div><div>to handle the Wikimedia wikitext  <a target="_blank" href="https://en.wikipedia.org/wiki/Help:Wikitext#Text_formatting">https://en.wikipedia.org/wiki/Help:Wikitext#Text_formatting</a><br></div><meta content="text/html; charset=utf-8"><meta content="text/html; charset=utf-8"><div><br></div><div>My grammar looks like this so far:<br></div><div><br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>'Body <- (   Template / Flow )*<br></div><div><br></div><div>LineCharacter <- [^\n]<br></div><div>Flow <-  Bold / Italic / BoldItalic/ LinkShort / LinkFull / LineCharacter /Template<br></div><div>Italic <-  "''''" Flow{"''''"}<br></div><div>Bold <-  "''''''" Flow{"''''''"}<br></div><div>BoldItalic <- "''''''''''''" Flow{"''''''''''''"}<br></div><div><br></div><div>LinkShort <- "[" .{&[>\]]} "]"<br></div><div>LinkFull <- "[" Flow{">"} .{"]"}<br></div><div>Whitespace    <-   [\s\t\n\r]*<br></div><div>Template <-  "{{"  Template "}}" /   "{{"  Flow{"}}"}<br></div><div>Heading4    <-    Whitespace "==== " Flow{" ====\n"}<br></div><div>'<br></div></blockquote><div><br></div></div><div>Italic and Bold work just peachy.<br></div><div><br></div><div>Template works for a simple Templates like: <br></div><div><br></div><pre style="font-family: monospace, monospace; color: rgb(0, 0, 0); background-color: rgb(248, 249, 250); border: 1px solid rgb(234, 236, 240); padding: 1em; white-space: pre-wrap; line-height: 1.3em; overflow-x: hidden; overflow-wrap: break-word; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">{{reflist}}.<br></pre><meta content="text/html; charset=utf-8"><div><br></div><div>My Actor callback, for now just wraps it in a span like this:<br></div><div><br></div><div><span style="text-decoration: underline">reflist</span><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Where things go south is when Templates are nested, for example on Infoboxes which are widely used in wiki markup:<br></div><div>Here is a truncated version of my output:<br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div><span style="text-decoration: underline">Infobox Italian comune   <---This is where the PEGActor callback started to wrap the outmost template.<br></div><div>| name                = Elmas<br></div><div>| official_name       = Comune di Elmas<br></div><div>....</div><div>| area_code           = 070<br></div><div>| website             = {{official website|<a target="_blank" href="http://www.comune.elmas.ca.it/">http://www.comune.elmas.ca.it/</a></span>    <--here is the nested Template. As you can see the Grammar ended the  outermost <span></span> here and never recursed on the inner template.<br></div><div>| footnotes           =<br></div><div>}}  <---here is the outermost template should end.<br></div></blockquote><br></div><div><br></div><div><br></div><div>So...I need a rule that will cover this.<br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>Template <-  "{{"  Template "}}" /   "{{"  Flow{"}}"}<br></div><meta content="text/html; charset=utf-8"></blockquote>should be what?<br><br>Thank you for your help.<br>t</div><meta content="text/html; charset=utf-8"><div><br></div><div><br></div><div><br></div></div><br></body></html>