Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Manual install of pelican_jupyter triggers TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element #124

Open
iacchus opened this issue Jul 20, 2020 · 3 comments

Comments

@iacchus
Copy link

iacchus commented Jul 20, 2020

I have a manual installation of pelican-jupyter, ie., I didn't install via pip but copied the pelican_jupyter directory to the PLUGINS_PATH and enabled with PLUGINS = [..., 'pelican_jupyter.markup', ...]

It generates the .ipynb normally, but when I enable it, it breaks something with the markdown rendering of another .md. What happens is exactly the same as in this bug report, which involves nbconvert as well. It looks like this one also.

The file it fails to convert is md-test.md and it seems to be happening because of the footnotes markdown extension, which is the same issue from the first link above and the debug report below.

It builds the site with all the files, and the converted ipynb, but doesn't convert that .md file (which is huge just to test various markdown extra extensions).

❯ python --version
Python 3.8.3
❯ pelican --version
4.2.0
❯ jupyter notebook --version
6.0.3
❯ jupyter nbconvert --version
5.6.1
❯ make publish
pelican /home/iacchus/git-stuff/iacchus.github.io-pelican/content -o /home/iacchus/git-stuff/iacchus.github.io-pelican/../iacchus.github.io -s /home/iacchus/git-stuff/iacchus.github.io-pelican/publishconf.py 
ERROR:pelican.generators:Could not process ./md-test.md
TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element
ERROR: Could not process ./md-test.md
  | TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element
Done: Processed 9 articles, 0 drafts, 2 pages, 0 hidden pages and 0 draft pages in 7.57 seconds.

Turning DEBUG=1

❯ export DEBUG=1
❯ make publish 2> debug.txt
pelican /home/iacchus/git-stuff/iacchus.github.io-pelican/content -o /home/iacchus/git-stuff/iacchus.github.io-pelican/../iacchus.github.io -s /home/iacchus/git-stuff/iacchus.github.io-pelican/publishconf.py -D
Done: Processed 9 articles, 0 drafts, 2 pages, 0 hidden pages and 0 draft pages in 6.99 seconds.

debug.txt relevant lines:

  89 ERROR:pelican.generators:Could not process ./md-test.md                                                                                                                                       
  90 TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element                                                                                                         
  91 Traceback (most recent call last):                                                                                                                                                            
  92   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/pelican/generators.py", line 618, in generate_context                                                                       
  93     article = self.readers.read_file(                                                                                                                                                         
  94   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/pelican/readers.py", line 594, in read_file                                                                                 
  95     content, reader_metadata = reader.read(path)                                                                                                                                              
  96   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/pelican/readers.py", line 352, in read                                                                                      
  97     content = self._md.convert(text)                                                                                                                                                          
  98   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/core.py", line 267, in convert                                                                                     
  99     newRoot = treeprocessor.run(root)                                                                                                                                                         
 100   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/extensions/footnotes.py", line 388, in run                                                                         
 101     footnotesDiv = self.footnotes.makeFootnotesDiv(root)                                                                                                                                      
 102   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/extensions/footnotes.py", line 181, in makeFootnotesDiv                                                            
 103     self.parser.parseChunk(surrogate_parent, self.footnotes[id])                                                                                                                              
 104   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/blockparser.py", line 105, in parseChunk                                                                           
 105     self.parseBlocks(parent, text.split('\n\n'))                                                                                                                                              
 106   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/blockparser.py", line 123, in parseBlocks                                                                          
 107     if processor.run(parent, blocks) is not False:                                                                                                                                            
 108   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/blockprocessors.py", line 592, in run                                                                              
 109     p = etree.SubElement(parent, 'p')                                           
 110 TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element
 111 ^[[1;31mERROR^[[0;m: Could not process ./md-test.md                             
 112   | TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element
 113 Traceback (most recent call last):                                              
 114   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/pelican/generators.py", line 618, in generate_context
 115     article = self.readers.read_file(                                           
 116   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/pelican/readers.py", line 594, in read_file
 117     content, reader_metadata = reader.read(path)                                
 118   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/pelican/readers.py", line 352, in read
 119     content = self._md.convert(text)                                            
 120   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/core.py", line 267, in convert
 121     newRoot = treeprocessor.run(root)                                           
 122   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/extensions/footnotes.py", line 388, in run
 123     footnotesDiv = self.footnotes.makeFootnotesDiv(root)                        
 124   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/extensions/footnotes.py", line 181, in makeFootnotesDiv
 125     self.parser.parseChunk(surrogate_parent, self.footnotes[id])                
 126   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/blockparser.py", line 105, in parseChunk
 127     self.parseBlocks(parent, text.split('\n\n'))                                
 128   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/blockparser.py", line 123, in parseBlocks
 129     if processor.run(parent, blocks) is not False:                              
 130   File "/home/iacchus/git-stuff/VENV/lib/python3.8/site-packages/markdown/blockprocessors.py", line 592, in run
 131     p = etree.SubElement(parent, 'p')                                           
 132 TypeError: SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element                   
@johnmathews
Copy link

Is there a fix for this? I ran into this issue today and haven't been able to resolve it.

@verga
Copy link

verga commented Dec 30, 2020

Same for me. I just installed pelican-jupyter using pip: it breaks other markdown files,

ERROR: Could not process pages/PS-intro.md | SubElement() argument 1 must be xml.etree.ElementTree.Element, not Element

@jayqi
Copy link

jayqi commented Mar 8, 2023

If anybody else encounters this, it means that you have an old version of defusedxml, which is a dependency of nbconvert. This is fixed in defusedxml>=0.7.

It's not a pelican-jupyter problem, so this can probably be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants