Created
May 22, 2013 15:15
-
-
Save flying-sheep/5628390 to your computer and use it in GitHub Desktop.
Iterator-based code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseTable(title, lines) { | |
let options = new TableOptions(lines.next()); | |
... | |
yield '<table>'; | |
for (let line of lines) { | |
if (line.startsWith(macros.tableEnd)) | |
break; | |
... | |
let buffer = line; | |
while(true) { | |
let open = buffer.match(openRE).length; | |
let close = buffer.match(closeRE).length; | |
if (close >= open) break; | |
buffer += lines.next(); | |
} | |
... | |
} | |
... | |
yield '</table>'; | |
} | |
function parse(lines) { | |
... | |
for (let line of lines) { | |
... | |
if (macro === macros.tableStart) | |
for (let l of parseTable(line, lines)) | |
yield l; | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment