Repository navigation
Conversation
- Don't re-wrap an inline element whose ancestor already uses the same markup, e.g. <b>x<b>y</b></b> now gives **xy** instead of **x**y****. - Separate a code span from an immediately preceding code span with a space so <kbd>Ctrl</kbd><kbd>C</kbd> gives `Ctrl` `C` instead of `Ctrl``C`, which renders as a single code span.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #301
This fixes two cases where inline delimiters run together and the output renders wrongly.
Nested elements with the same markup.
abstract_inline_conversionnow returns the text unwrapped when an ancestor already uses the same markup. It finds that out fromparent_tags: each generated converter stores itsmarkup_fn, and the check compares the parent's markup with its own. So<b>inside<strong>and<em>inside<i>are both handled, as is a subclass that defines its own converter withabstract_inline_conversion. HTML-tag markup such assup_symbol='<sup>'is left alone, since nesting it is valid.Adjacent code spans. If a
<code>,<kbd>or<samp>comes straight after another one,convert_codeputs a space before it. Otherwise the two sets of backticks join up and the result renders as one code span. Markdown has no way to put two code spans directly next to each other, so a space seemed like the smallest change that keeps both spans.I checked the new outputs with markdown-it-py (CommonMark) and Python-Markdown. Both now give the expected
<strong>/<em>/<code>elements.Not included: sibling emphasis (
<i>a</i><i>b</i>→*a**b*). A space would change the text, so I'd rather agree on an approach first (see the issue).Tests: I added cases to
test_codeand a newtest_nested_same_markupintests/test_conversions.py.pytest(84 passed),flake8 --ignore=E501,W503 markdownify testsandrestructuredtext-lint README.rstall pass.