A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Python-Markdown/markdown/issues/1261 below:

PrettifyTreeprocessor AttributeError · Issue #1261 · Python-Markdown/markdown · GitHub

This code section near the bottom of markdown.treeprocessors raises AttributeError if pre[0].text is None.

# Clean up extra empty lines at end of code blocks.
pres = root.iter('pre')
for pre in pres:
    if len(pre) and pre[0].tag == 'code':
        pre[0].text = util.AtomicString(pre[0].text.rstrip() + '\n')

The check should be if len(pre) and pre[0].tag == 'code' and pre[0].text is not None or isinstance(pre[0].text, str), but that may be too strict.

I encountered this with a custom Block/Inline processor. The band-aid fix was just to ensure these elements had text.

for pre in root.iter("pre"):
    if pre[0].text is None:
        pre[0].text = ""

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4