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

[md_inline_extension] Broken with Markdown >= 3.4 #1373

Open
haplo opened this issue Nov 28, 2022 · 0 comments · May be fixed by #1374
Open

[md_inline_extension] Broken with Markdown >= 3.4 #1373

haplo opened this issue Nov 28, 2022 · 0 comments · May be fixed by #1374

Comments

@haplo
Copy link

haplo commented Nov 28, 2022

Markdown 3.2 deprecated markdown.util.etree, which md_inline_extension currently uses. Markdown 3.4 removed the deprecated etree symbol, which causes md_inline_extension plugin to fail to load with this error message:

Markdown is not installed - inline Markdown extension disabled

Updating the import is not enough to get md_inline_extension working again, after that it fails with:

PelicanInlineMarkdownExtension.extendMarkdown() missing 1 required positional argument: 'md_globals'                                                                                                                                                                                                                              

Removing md_globals parameter from PelicanInlineMarkdownExtension.extendMarkdown takes us to yet another error:

'Registry' object has no attribute 'add'                                                                                                                                                                                                                                                                                          

Which is caused by this line in pelican_inline_markdown_extension.py. Updating it from .add to .register takes us to the following error (taken with DEBUG=1 for useful stacktraces):

'<' not supported between instances of 'str' and 'int'                                                                                                                                                                                                                                                                            
Traceback (most recent call last):                                                                                                                                                                                                                                                                                                
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/pelican/generators.py", line 740, in generate_context                                                                                                                                                                                        
    page = self.readers.read_file(                                                                                                                                                                                                                                                                                                
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/pelican/readers.py", line 580, in read_file                                                                                                                                                                                                  
    content, reader_metadata = reader.read(path)                                                                                                                                                                                                                                                                                  
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/pelican/readers.py", line 342, in read                                                                                                                                                                                                       
    self._md = Markdown(**self.settings['MARKDOWN'])                                                                                                                                                                                                                                                                              
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/core.py", line 96, in __init__                                                                                                                                                                                                      
    self.registerExtensions(extensions=kwargs.get('extensions', []),                                                                                                                                                                                                                                                              
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/core.py", line 125, in registerExtensions                                                                                                                                                                                           
    ext.extendMarkdown(self)                                                                                                                                                                                                                                                                                                      
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/extensions/footnotes.py", line 82, in extendMarkdown                                                                                                                                                                                
    md.inlinePatterns.register(FootnoteInlineProcessor(FOOTNOTE_RE, self), 'footnote', 175)                                                                                                                                                                                                                                       
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/util.py", line 331, in register                                                                                                                                                                                                     
    self.deregister(name)                                                                                                                                                                                                                                                                                                         
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/util.py", line 343, in deregister                                                                                                                                                                                                   
    index = self.get_index_for_name(name)                                                                                                                                                                                                                                                                                         
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/util.py", line 307, in get_index_for_name                                                                                                                                                                                           
    self._sort()                                                                                                                                                                                                                                                                                                                  
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/util.py", line 357, in _sort                                                                                                                                                                                                        
    self._priority.sort(key=lambda item: item.priority, reverse=True)                                                                                                                                                                                                                                                             
TypeError: '<' not supported between instances of 'str' and 'int'

Which boils down to register() taking an integer as priority and not a string as Registry.add (now deprecated) did.

Hopeful that this was the last error I try again, but alas another error:

'str' object has no attribute 'ANCESTOR_EXCLUDES'                                                                                                                                                                                                                                                                                 
Traceback (most recent call last):                                                                                                                                                                                                                                                                                                
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/pelican/generators.py", line 740, in generate_context                                                                                                                                                                                        
    page = self.readers.read_file(                                                                                                                                                                                                                                                                                                
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/pelican/readers.py", line 580, in read_file                                                                                                                                                                                                  
    content, reader_metadata = reader.read(path)                                                                                                                                                                                                                                                                                  
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/pelican/readers.py", line 344, in read                                                                                                                                                                                                       
    content = self._md.convert(text)                                                                                                                                                                                                                                                                                              
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/core.py", line 268, in convert                                                                                                                                                                                                      
    newRoot = treeprocessor.run(root)                                                                                                                                                                                                                                                                                             
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/treeprocessors.py", line 367, in run                                                                                                                                                                                                
    self.__handleInline(text), child                                                                                                                                                                                                                                                                                              
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/treeprocessors.py", line 127, in __handleInline                                                                                                                                                                                     
    data, matched, startIndex = self.__applyPattern(                                                                                                                                                                                                                                                                              
  File "/home/fidel/Code/blog.fidelramos.net/virtualenv/lib/python3.10/site-packages/markdown/treeprocessors.py", line 258, in __applyPattern                                                                                                                                                                                     
    for exclude in pattern.ANCESTOR_EXCLUDES:                                                                                                                                                                                                                                                                                     
AttributeError: 'str' object has no attribute 'ANCESTOR_EXCLUDES'                                                                                                                                                                                                                                                                 

At this point I gave up, I will leave a PR in case someone wants to continue, but clearly the Markdown project doesn't care much about backwards-compatibility. :(

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.

1 participant