(text, includes)
| 200 | } |
| 201 | |
| 202 | function getStartCode(text, includes) { |
| 203 | let found = /\n```(.*?\bstartCode:.*)\n([^]*?\n)```/.exec(text); |
| 204 | if (!found) return "" |
| 205 | |
| 206 | let snippet = found[2].replace(/(\n|^)\s*\/\/ →.*\n/g, "$1"); |
| 207 | let directive = String(PJSON.parse(found[1]).startCode), m; |
| 208 | if (m = directive.match(/top_lines:\s*(\d+)/)) |
| 209 | snippet = snippet.split("\n").slice(0, Number(m[1])).join("\n") + "\n"; |
| 210 | if (m = directive.match(/bottom_lines:\s*(\d+)/)) { |
| 211 | let lines = snippet.trimRight().split("\n"); |
| 212 | snippet = lines.slice(lines.length - Number(m[1])).join("\n") + "\n"; |
| 213 | } |
| 214 | if (guessType(snippet) == "html") |
| 215 | return prepareHTML(snippet, includes); |
| 216 | else |
| 217 | return snippet; |
| 218 | } |
| 219 | |
| 220 | function chapterZipFile(meta, chapter) { |
| 221 | let spec = meta.match(/\bzip: ("(?:\\.|[^"\\])*")/); |
no test coverage detected