Skip to content

Fix crash in markdown-in-html extra (#565)#566

Merged
nicholasserra merged 3 commits intotrentm:masterfrom
Crozzers:fix-indented-opening-tag-causing-crashes
Jan 23, 2024
Merged

Fix crash in markdown-in-html extra (#565)#566
nicholasserra merged 3 commits intotrentm:masterfrom
Crozzers:fix-indented-opening-tag-causing-crashes

Conversation

@Crozzers
Copy link
Contributor

This PR closes #565 by fixing a bug where an HTML snippet inside of a list could cause the library to crash when markdown-in-html is enabled.

The issue is due to how _markdown_in_html handles indentation.

- one two
   <p markdown="1">
  def
  </p>
- three four

In the above snippet, the HTML is placed inside a list because _hash_html_blocks doesn't work in lists (see #514), which means the snippet gets passed to _do_markdown_in_html.
The text is then dedented using _uniform_outdent which removes the smallest common leading indentation. Since the opening tag is indented further than the rest, it is left with a slight indentation.

The block is then passed to _hash_html_block_sub where multiple regular expressions expect the tag to be right at the start of the line. This causes a match to return None and the library fails to get the first match group, causing the crash.

@nicholasserra
Copy link
Collaborator

Thank you!

@nicholasserra nicholasserra merged commit 749ee72 into trentm:master Jan 23, 2024
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

Successfully merging this pull request may close these issues.

regression with markdown-in-html

2 participants