matthewwithanm / matthewwithanm/python-markdownify

Insufficient indentation for nested lists

Open
#211 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.2k
Forks
203
PR merge metrics
No merged PRs in 30d

Description

Hello! I've been using the markdownify library in my app for a long time and it's been working great, but recently I updated and I noticed that the the interpretation for nested lists had changed and it messed up my workflow.

My workflow looks like this:

  • import content as HTML
  • converting the HTML to markdown for editing (using markdownify)
  • editors can edit the content
  • once editing is finished, convert markdown back to HTML for publishing (using Markdown)

I noticed that since this commit, markdownify changed from using tabs for list indentation (/t) to using spaces, which looks like 2 spaces for unordered lists and 3 spaces for ordered lists.

Since Markdown expects nested lists to be indented by 4 spaces, the nested lists output by markdownify aren't currently interpreted by Markdown.

Here's an example of what I mean:

Nested unordered list
original HTML markdownify output final HTML (using Markdown)
original list has 4 levels of indentation only 2 spaces used for nested list indentation final list has 2 levels of indentation
Image Image Image
Nested ordered list
original HTML markdownify output final HTML (using Markdown)
original list has 4 levels of indentation only 3 spaces used for nested list indentation final list has 3 levels of indentation
Image Image Image

I recently created a PR in my app to resolve this by overriding convert_li. If you are interested, I could do a PR on this repo as well.

On the other hand, if there's some configuration option that I am missing that resolves this or Markdown is too-strictly interpreting the spec and you don't believe this is a real issue, that's fine too.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the convert_li entry point and inspect the indentation change referenced in commit c13bdd5. Reproduce nested unordered and ordered lists through markdownify and Markdown, then verify that nested levels round-trip with the expected four-space indentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.