Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists over 9 items long break with indented content #410

Open
FossPrime opened this issue May 11, 2022 · 0 comments
Open

Lists over 9 items long break with indented content #410

FossPrime opened this issue May 11, 2022 · 0 comments

Comments

@FossPrime
Copy link

FossPrime commented May 11, 2022

The following html

<ol start="9">
<li>
	<p><strong>I came in like a wrecking ball</strong></p>
	<p><img src="https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg" alt=""></p>
</li>
<li>
	<p><strong>I never hit so hard in love</strong></p>
	<p><img src="https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg" alt=""></p>
</li>
</ol>

Should be converted to:

 9. **I came in like a wrecking ball**

    ![](https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg)

10. **I never hit so hard in love**

    ![](https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg)

But instead it's converted to this non-commonmark compliant code:

9.  **I came in like a wrecking ball**
    
    ![](https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg)
    
10.  **I never hit so hard in love**
    
    ![](https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg)

Which creates a code_block instead of regular text and images because of the following CommonMark spec:

Proposed solution

Remove whatever is adding the unwanted indentation between the list number and the list title. If this is intentional indentation, then move it to the beginning of the line, not between the list item.

That currently breaks 14 tests:

not ok 103 should be equal
not ok 104 should be equal
not ok 105 should be equal
not ok 106 should be equal
not ok 107 should be equal
not ok 108 should be equal
not ok 115 should be equal
not ok 116 should be equal
not ok 119 should be equal
not ok 120 should be equal
not ok 127 should be equal
not ok 128 should be equal
not ok 139 should be equal
not ok 140 should be equal

Additional notes:

  • The strong emphasis ** is not needed to reproduce the problem.
  • A space before the 9 looks nice, but isn't absolutely necessary in my testing
  • Offending code:
    prefix = (start ? Number(start) + index : index + 1) + '. '
@FossPrime FossPrime changed the title Turndown indents list items that were not previously indented Turndown lists over 9 items long break with indented content May 11, 2022
@FossPrime FossPrime changed the title Turndown lists over 9 items long break with indented content Lists over 9 items long break with indented content May 11, 2022
FossPrime added a commit to FossPrime/turndown that referenced this issue May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant