File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -291,15 +291,31 @@ auto genGrammar(string fileText)
291291 continue ;
292292
293293 enum grammarKey = " $(GRAMMAR" ;
294- auto text = entry.fileName.readText.find(grammarKey);
295- if (text.length)
296- newContent ~= " $(H2 $(LNAME2 %s, %s))\n " .format(entry.title.toLower, entry.title);
297- for (; text.length; text = text[ grammarKey.length .. $].find(grammarKey))
294+
295+ static string findKey (string s)
296+ {
297+ s = s.find(grammarKey);
298+ // retry if no space after
299+ if (s.length > grammarKey.length && ! s[grammarKey.length].isWhite)
300+ {
301+ return findKey (s[grammarKey.length .. $]);
302+ }
303+ return s;
304+ }
305+ auto text = findKey(entry.fileName.readText);
306+ if (! text.length)
307+ continue ;
308+
309+ newContent ~= " $(H2 $(LNAME2 %s, %s))\n " .format(entry.title.toLower, entry.title);
310+ do
298311 {
299312 newContent ~= grammarKey;
300- newContent ~= text.drop(grammarKey.length).untilClosingParentheses.to! string ;
313+ text.popFrontN(grammarKey.length);
314+ newContent ~= text.untilClosingParentheses.to! string ;
301315 newContent ~= " )\n " ;
316+ text = findKey(text);
302317 }
318+ while (text.length);
303319 }
304320 return updateDdocTag (fileText, ddocKey, newContent);
305321 }
You can’t perform that action at this time.
0 commit comments