mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.52k stars 864 forks source link

Is there a way to have a bullet for each level of indentation in nested lists? #446

Open oscadev opened 1 year ago

oscadev commented 1 year ago

Right now, it correctly indents doe nested ul lists, but it only adds one bullet instead of one for each level. For example:

<ul>
          <li>item 1</li>
          <li>item 2</li>
          <ul>
                  <li/>sublist item 1</li>
          </ul>
<ul/>

produces:

When it should (or I would like it to) produce:

I have even tried running str.replace(" ", "* ") but the string replace cannot pickup those gaps even if I copy and paste them from the console log. I would be content with either a way to to it inside the turndown options, or even getting the replace to work. Any thoughts?

za3k commented 1 month ago

What does doe nested mean? The above example is not valid HTML. <ul> must be inside an <li> block, not directly inside another <ul> block.

xuli-cooly commented 2 weeks ago

But the indented content after rich text editing is like this.

.The ideal rule is to increment the count by 2 when encountering a ul, and when encountering an li, to retrieve the content, where the number of spaces in the front end equals the count, followed by a line break.