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

Markdown containing relative links fails with the 'pending_xref' node is not yet supported #370

Open
1 task done
alightwing opened this issue Oct 19, 2022 · 2 comments
Open
1 task done
Labels
bug crash rinohtype aborts due to an uncaught exception

Comments

@alightwing
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Sphinx or rinoh output

alightwing@DESKTOP-536J1FP:/mnt/c/Users/Andrew/vm/development-texts$ rinoh test3.md --format CommonMark
/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document
  warn("Container node skipped: type={0}".format(mdnode.t))
Traceback (most recent call last):
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 27, in map_node
    return cls._mapping[node_name.replace('-', '_')](node, **context)
KeyError: 'pending_xref'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alightwing/.pyenv/versions/3.9.5/bin/rinoh", line 8, in <module>
    sys.exit(main())
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/__main__.py", line 307, in main
    document_tree = reader.parse(args.input)
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/rst/__init__.py", line 139, in parse
    return from_doctree(doctree, **context)
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/rst/__init__.py", line 149, in from_doctree
    return mapped_tree.flowable()
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 132, in flowable
    flowable, = self.flowables()
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/rst/nodes.py", line 207, in build_flowable
    return rt.Paragraph(self.process_content(), style=self.style)
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/rst/__init__.py", line 85, in process_content
    children_text = (child.styled_text() for child in self.getchildren())
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 64, in getchildren
    return [self.map_node(child, **self.context)
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 64, in <listcomp>
    return [self.map_node(child, **self.context)
  File "/home/alightwing/.pyenv/versions/3.9.5/lib/python3.9/site-packages/rinoh/frontend/__init__.py", line 30, in map_node
    raise NotImplementedError("{}:{} the '{}' node is not yet supported "
NotImplementedError: test3.md:3 the 'pending_xref' node is not yet supported (rinoh.frontend.rst.nodes)

Source files

https://github.com/VisualMeaning/development-texts/blob/master/README.md

We have a repository with a bunch of markdown text documents, where the README.md acts as an index page that links to interesting documents inside the same repository. I grabbed this README.md to throw into rinohtype to test how it would convert markdown to PDF and got the above error.

Further prodding indicates that if you cut that README down to just the following line:

[Rethinking zoom](comments/rethinking_zoom.md)

It fails identically, indicating it's unhappy with relative links. Changing the above to:

[Rethinking zoom](http:comments/rethinking_zoom.md)

causes it to run successfully.

Versions

rinohtype 0.5.4
Sphinx 5.3.0
Python 3.9.5 (default, May 19 2021, 13:35:51)
[GCC 9.3.0]
Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.31
@alightwing alightwing added bug crash rinohtype aborts due to an uncaught exception labels Oct 19, 2022
@brechtm
Copy link
Owner

brechtm commented Oct 19, 2022

For Markdown support, rinohtype currently depends on recommonmark, which was deprecated some time ago. Therefore, we'll need to migrate to another Markdown-to-docutils parser. Candidates are:

Related: #265

@brechtm
Copy link
Owner

brechtm commented Oct 19, 2022

I replaced recommonmark with MyST. Please try with the current development version of rinohtype:

pip install https://github.com/brechtm/rinohtype/archive/refs/heads/master.zip

Now rinoh will render your document, but the relative links aren't handled properly. I'm not sure whether this requires a different syntax or is just a bug. The markdown-it command line tool does seem to handle them fine (versus the myst-docutils-* tools), so I'm thinking this would be a MyST bug. Please file a bug report with that project regarding this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug crash rinohtype aborts due to an uncaught exception
Projects
None yet
Development

No branches or pull requests

2 participants