github-flavored-markdown-to-html
github-flavored-markdown-to-html copied to clipboard
XMLParsedAsHTMLWarning blocks the usage of gh-md-to-html
I've just discovered this tool and I need it to get my school notes up and running, but I've run into an error which I can't make sense of. This dump appears every time I try to use gh-md-to-html on a file :
/home/rigobert9/.local/lib/python3.10/site-packages/bs4/builder/__init__.py:545: XMLParsedAsHTMLWarning: It looks like you're parsing an XML document using an HTML parser. If this really is an HTML document (maybe it's XHTML?), you can ignore or filter this warning. If it's XML, you should know that using an XML parser will be more reliable. To parse this document as XML, make sure you have the lxml package installed, and pass the keyword argument `features="xml"` into the BeautifulSoup constructor.
warnings.warn(
Traceback (most recent call last):
File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/rigobert9/.local/lib/python3.10/site-packages/gh_md_to_html/__main__.py", line 5, in <module>
cmd_to_main()
File "/home/rigobert9/.local/lib/python3.10/site-packages/gh_md_to_html/__init__.py", line 1618, in cmd_to_main
result = main(**vars(parser.parse_args()))
File "/home/rigobert9/.local/lib/python3.10/site-packages/gh_md_to_html/__init__.py", line 903, in main
html_content = find_and_render_formulas_in_html(html_content, formula_mapper, special_chars_in_code_blocks,
File "/home/rigobert9/.local/lib/python3.10/site-packages/gh_md_to_html/__init__.py", line 431, in find_and_render_formulas_in_html
formula_rendered = formula2svg(formula, amount_of_svg_formulas)
File "/home/rigobert9/.local/lib/python3.10/site-packages/gh_md_to_html/__init__.py", line 400, in formula2svg
svg_element_soup_representation["class"] = "gh-md-to-html-formula"
TypeError: 'NoneType' object does not support item assignment
I've only tried gh-md-to-html file.md and gh-md-to-html --math true --emoji-support 0 --dont-make-images-links true file.md -p \<name\>.pdf which I found in the README so far, but this error probably comes from my own environment. I'm running Fedora 36 Plasma, and I tried to update everything on pip. Any pointers on what could be my problem ?
Otherwise great software, just what I neede, keep at it !
Just tried ignoring the error (by replacing the error lines in the init.py with
svg_element_soup_representation = formula_rendered_soup.find("svg")
if(svg_element_soup_representation is not None):
svg_element_soup_representation["class"] = "gh-md-to-html-formula"
svg_element_soup_representation["style"] = "vertical-align: middle;"
The command-line tool echoes an error, but still proceeds, and then produces an html (or a pdf) with mojibake or whitespace instead of the LaTeX formulas