Commit e359308b2b

Nguyễn Gia Phong <mcsinyx@disroot.org>
2023-02-15 22:00:57
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.
1 parent 7199d7c
Changed files (1)
lib
docs
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
+}