From 72e437b911ca2b2979765b3bd364e5419b7e940a Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 25 Dec 2021 00:00:14 -0500 Subject: [PATCH] [+] Markdown: hideSection() function --- src/scripts/extended_markdown.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/scripts/extended_markdown.ts b/src/scripts/extended_markdown.ts index 2ab39d7..6ce32e7 100644 --- a/src/scripts/extended_markdown.ts +++ b/src/scripts/extended_markdown.ts @@ -17,6 +17,27 @@ function parseExtensions(raw: string): string const lines = raw.replace('\r\n', '\n').split('\n') let i = 0 + /** + * Hide an entire hn section + * Example: + * + * ### Header3 + * + * ... Hidden items + * + * ### Next Header3 + */ + function hideSection() + { + const r = re.hashes.exec(lines[i]) + if (!r) return + const level = r[0].length + + // Find next same-level or higher-level header's index + let j = i + 1 + while (!(lines[i].startsWith('#') && re.hashes.exec(lines[i])![0].length <= level)) j++ + } + // Run all commands in markdown while (i < lines.length) {