aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-12 09:32:49 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-12 09:32:49 +0200
commit9acd7abc067f15fe15e9a39f0ff681b1ab03b78a (patch)
tree9bfe981436e8c27f8dde2641298d38dad71e9e55
parentb0e85051cb95c0ce3a359f20862f80e4cdb091dd (diff)
remove lines starting with # in code blocks
-rw-r--r--pages/post/[id].tsx5
-rw-r--r--todo.todo1
2 files changed, 4 insertions, 2 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);
}
diff --git a/todo.todo b/todo.todo
deleted file mode 100644
index d8ad265..0000000
--- a/todo.todo
+++ /dev/null
@@ -1 +0,0 @@
-- ignore lines starting with '#' in code blocks