Skip to content

Commit

Permalink
Simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Sep 7, 2024
1 parent b47ccf3 commit fda7c45
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const filter = require("pandoc-filter");

let level = -1;
let level = 0;

function enddetails(l, content) {
for (let i = l; i <= level; i++)
Expand All @@ -11,10 +11,7 @@ function enddetails(l, content) {

filter.stdio(function ({ t, c }, format, meta) {
if (t === "Header") {
if (
level === -1 ||
/^(table-of-contents|appendix-[a-z]-|[a-z]?\d+-)/.test(c[1][0])
) {
if (c[0] === 1 || /^(appendix-[a-z]-|[a-z]?\d+-)/.test(c[1][0])) {
const content = [
filter.RawBlock("html", `<details open><summary>`),
filter.Header(...c),
Expand All @@ -27,7 +24,7 @@ filter.stdio(function ({ t, c }, format, meta) {
c[1][0] = "";
return filter.Header(...c);
}
} else if (t === "HorizontalRule" && level !== -1) {
} else if (t === "HorizontalRule") {
const content = [filter.HorizontalRule()];
enddetails(1, content);
level = 0;
Expand Down

0 comments on commit fda7c45

Please sign in to comment.