From e359308b2bf30f6fe5403ddfddcf7925f6ab1f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Thu, 16 Feb 2023 06:00:57 +0900 Subject: [PATCH 1/2] autodoc: fix md list markers matching Both original Markdown and CommonMark require at least one space or tab between the list marker and any following content. Following this allows starting a line with a negative number or one with a decimal point. --- lib/docs/main.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/docs/main.js b/lib/docs/main.js index 7a27f9db4f..feb6a96e50 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"; @@ -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 +} From b56d4f215061e57dd2f5470c14df0c27b810c8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Thu, 16 Feb 2023 06:01:47 +0900 Subject: [PATCH 2/2] autodoc: render ordered lists as such --- lib/docs/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/docs/main.js b/lib/docs/main.js index feb6a96e50..579fc79442 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -3538,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"; @@ -3547,7 +3547,7 @@ const NAV_MODES = { html += "
  • " + markdownInlines(line.text) + "
  • \n"; if ( - !nextLineIs("ul", line_no) || + !nextLineIs(line.type, line_no) || getNextLineIndent(line_no) < line.indent ) { html += "\n";