From 9acd7abc067f15fe15e9a39f0ff681b1ab03b78a Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 12 Apr 2021 09:32:49 +0200 Subject: remove lines starting with # in code blocks --- pages/post/[id].tsx | 5 ++++- todo.todo | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 todo.todo 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): Array { } function parseToC(file: Array): Array { - 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 -- cgit v1.2.3