diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-04-12 09:32:49 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-04-12 09:32:49 +0200 |
commit | 9acd7abc067f15fe15e9a39f0ff681b1ab03b78a (patch) | |
tree | 9bfe981436e8c27f8dde2641298d38dad71e9e55 /pages | |
parent | b0e85051cb95c0ce3a359f20862f80e4cdb091dd (diff) |
remove lines starting with # in code blocks
Diffstat (limited to 'pages')
-rw-r--r-- | pages/post/[id].tsx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx index 4f5acf7..b68b790 100644 --- a/pages/post/[id].tsx +++ b/pages/post/[id].tsx @@ -128,7 +128,10 @@ function parseToCRecursive(headings: Array<string>): Array<chapter> { } function parseToC(file: Array<string>): Array<chapter> { - var chapterStrings = file.filter(line => line.startsWith("#")); + var fileAsStr = file.join("\n"); + fileAsStr = fileAsStr.replace(/```.*?```/gs, ""); // filter out code blocks from table of contents + var fileAsArr = fileAsStr.split("\n"); + var chapterStrings = fileAsArr.filter(line => line.startsWith("#")); return parseToCRecursive(chapterStrings); } |