aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-02-20 16:33:00 +0100
committerGitHub <noreply@github.com>2023-02-20 16:33:00 +0100
commitdfd182cc7a831ec75ccc03792afd27b292db194b (patch)
tree9498355e09b732f39e6142b750ecfec55abd0055
parent476bdc8b0b02cbd09f6a856aa7dc548dea565109 (diff)
parentb56d4f215061e57dd2f5470c14df0c27b810c8ba (diff)
downloadzig-dfd182cc7a831ec75ccc03792afd27b292db194b.tar.gz
zig-dfd182cc7a831ec75ccc03792afd27b292db194b.zip
Merge pull request #14655 from McSinyx/md-ol
autodoc: fix markdown list rendering
-rw-r--r--lib/docs/main.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/docs/main.js b/lib/docs/main.js
index 7a27f9db4f..579fc79442 100644
--- a/lib/docs/main.js
+++ b/lib/docs/main.js
@@ -3319,14 +3319,16 @@ const NAV_MODES = {
} else if (line.text.startsWith("#")) {
line.type = "h1";
line.text = line.text.substr(1);
- } else if (line.text.startsWith("-")) {
- line.type = "ul";
- line.text = line.text.substr(1);
- } else if (line.text.match(/^\d+\..*$/)) {
- // if line starts with {number}{dot}
- const match = line.text.match(/(\d+)\./);
+ } else if (line.text.match(/^-[ \t]+.*$/)) {
+ // line starts with a hyphen, followed by spaces or tabs
+ const match = line.text.match(/^-[ \t]+/);
line.type = "ul";
line.text = line.text.substr(match[0].length);
+ } else if (line.text.match(/^\d+\.[ \t]+.*$/)) {
+ // line starts with {number}{dot}{spaces or tabs}
+ const match = line.text.match(/(\d+)\.[ \t]+/);
+ line.type = "ol";
+ line.text = line.text.substr(match[0].length);
line.ordered_number = Number(match[1].length);
} else if (line.text == "```") {
line.type = "skip";
@@ -3536,7 +3538,7 @@ const NAV_MODES = {
case "ul":
case "ol":
if (
- !previousLineIs("ul", line_no) ||
+ !previousLineIs(line.type, line_no) ||
getPreviousLineIndent(line_no) < line.indent
) {
html += "<" + line.type + ">\n";
@@ -3545,7 +3547,7 @@ const NAV_MODES = {
html += "<li>" + markdownInlines(line.text) + "</li>\n";
if (
- !nextLineIs("ul", line_no) ||
+ !nextLineIs(line.type, line_no) ||
getNextLineIndent(line_no) < line.indent
) {
html += "</" + line.type + ">\n";
@@ -4067,4 +4069,4 @@ function toggleExpand(event) {
if (!parent.open && parent.getBoundingClientRect().top < 0) {
parent.parentElement.parentElement.scrollIntoView(true);
}
-} \ No newline at end of file
+}