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

Redundant code in PrettifyTreeprocessor._prettifyETree #1267

Closed
h4b4n3r0 opened this issue Jun 1, 2022 · 2 comments · Fixed by #1269
Closed

Redundant code in PrettifyTreeprocessor._prettifyETree #1267

h4b4n3r0 opened this issue Jun 1, 2022 · 2 comments · Fixed by #1269

Comments

@h4b4n3r0
Copy link

h4b4n3r0 commented Jun 1, 2022

I just saw following code in https://github.com/Python-Markdown/markdown/blob/master/markdown/treeprocessors.py#L398-L412

if self.md.is_block_level(elem.tag) and elem.tag not in ['code', 'pre']:
    ...
    if not elem.tail or not elem.tail.strip():
        elem.tail = i
if not elem.tail or not elem.tail.strip():
    elem.tail = i

In my opinion the two lines in https://github.com/Python-Markdown/markdown/blob/master/markdown/treeprocessors.py#L409-L410

    if not elem.tail or not elem.tail.strip():
        elem.tail = i

are superfluous as they are called regardless identically in https://github.com/Python-Markdown/markdown/blob/master/markdown/treeprocessors.py#L411-L412. Also with the variable i is not changed.

Solution would be to remove the two lines https://github.com/Python-Markdown/markdown/blob/master/markdown/treeprocessors.py#L409-L410

@waylan
Copy link
Member

waylan commented Jun 2, 2022

A PR is welcome.

@h4b4n3r0
Copy link
Author

On its way

sthagen pushed a commit to sthagen/Python-Markdown-markdown that referenced this issue Jun 13, 2022
Lines in 409 and 410 are part of an if-condition-block. However, they are called identically L411 and L412 outside of the if-block anyways. Fixes Python-Markdown#1267.
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 a pull request may close this issue.

2 participants