Overview
Comment: | Fix Markdown TOC HTML code to fix numbering |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA3-256: |
840506facfbb5fffffaae9cd4c1ab006 |
User & Date: | bohwaz on 2022-02-02 11:35:02 |
Other Links: | manifest | tags |
Context
2022-02-02
| ||
11:53 | Fix PHP 8.1 warnings check-in: d4e236356f user: bohwaz tags: trunk | |
11:35 | Fix Markdown TOC HTML code to fix numbering check-in: 840506facf user: bohwaz tags: trunk, stable | |
11:33 | PHP 8.1: use KD2 strftime replacement check-in: 235ab83bf1 user: bohwaz tags: trunk, stable | |
Changes
Modified src/include/lib/Garradin/Web/Render/Parsedown.php from [8582efeb8b] to [4ec75d240a].
︙ | ︙ | |||
93 94 95 96 97 98 99 | public function buildTOC(): string { if (!count($this->toc)) { return ''; } | | | | > | | > | > > | > > | > | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | public function buildTOC(): string { if (!count($this->toc)) { return ''; } $out = '<div class="toc">' . PHP_EOL; $level = 0; foreach ($this->toc as $k => $h) { if ($h['level'] < $level) { $out .= "\n" . str_repeat("\t", $level); $out .= str_repeat("</ol></li>\n", $level - $h['level']); $level = $h['level']; } elseif ($h['level'] > $level) { $out .= "\n" . str_repeat("\t", $h['level']); $out .= str_repeat("<ol>\n", $h['level'] - $level); $level = $h['level']; } elseif ($k) { $out .= "</li>\n"; } $out .= str_repeat("\t", $level + 1); $out .= sprintf('<li><a href="#%s">%s</a>', $h['id'], $h['label']); } if ($level > 0) { $out .= "\n"; $out .= str_repeat('</li></ol>', $level); } $out .= '</div>'; return $out; } |
︙ | ︙ |