[+] Markdown: hideSection() function

This commit is contained in:
Hykilpikonna
2021-12-25 00:00:14 -05:00
parent 5d2523e698
commit 72e437b911
+21
View File
@@ -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 <!--{ hideSection() }-->
*
* ... 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)
{