Skip to content

Commit

Permalink
Merge pull request #3810 from handrews/appendix
Browse files Browse the repository at this point in the history
Correctly handle appendicies in md2html
  • Loading branch information
lornajane committed May 23, 2024
2 parents 994a851 + 29fdf6f commit 3f2e047
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/md2html/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,22 @@ for (let l in lines) {
//if (delta<0) delta = -1;
if (Math.abs(delta)>1) console.warn(delta,line);
let prefix = '';
let newSection = '<section>';
if (line.includes('Appendix')) {
newSection = '<section class="appendix">';
}

// heading level delta is either 0 or is +1/-1, or we're in respec mode
/* respec insists on <section>...</section> breaks around headings */

if (delta === 0) {
prefix = '</section><section>';
prefix = '</section>'+newSection;
}
else if (delta > 0) {
prefix = '<section>'.repeat(delta);
prefix = newSection.repeat(delta);
}
else {
prefix = '</section>'+('</section>').repeat(Math.abs(delta))+'<section>';
prefix = '</section>'+('</section>').repeat(Math.abs(delta))+newSection;
}
prevHeading = heading;
line = prefix+md.render(line);
Expand Down

0 comments on commit 3f2e047

Please sign in to comment.