claude-export icon indicating copy to clipboard operation
claude-export copied to clipboard

`OL` is not numbered correctly

Open 7shi opened this issue 1 year ago • 0 comments

Nodes other than li are enumerated, so ol is not numbered correctly.

It can be worked around by counting the numbers.

--- a/src/exportMarkdown.js
+++ b/src/exportMarkdown.js
@@ -43,12 +47,13 @@ const getContents = require("./util/getContents");

           // Get list items
           if (tag === "OL") {
-            childNode.childNodes.forEach((listItemNode, index) => {
+            var index = 0;
+            childNode.childNodes.forEach((listItemNode) => {
               if (
                 listItemNode.nodeType === Node.ELEMENT_NODE &&
                 listItemNode.tagName === "LI"
               ) {
-                markdown += `${index + 1}. ${
+                markdown += `${++index}. ${
                   listItemNode.textContent
                 }\n`;
               }

7shi avatar Apr 30 '24 13:04 7shi