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

Highlight warn not the current node location #8093

Closed
yves-chevallier opened this issue Aug 10, 2020 · 3 comments
Closed

Highlight warn not the current node location #8093

yves-chevallier opened this issue Aug 10, 2020 · 3 comments

Comments

@yves-chevallier
Copy link
Contributor

In writer/html5.py/visit_literal_block we find this:

    highlighted = self.highlighter.highlight_block(
        node.rawsource, lang, opts=opts, linenos=linenos,
        location=(self.builder.current_docname, node.line), **highlight_args
    )

The good news is that it works in most cases. However if a node is moved during the build process, you'll get an error with the wrong document name as we use the node.line, but the current docname.

Wouldn't be better to use node.source and node.line?

@tk0miya
Copy link
Member

tk0miya commented Aug 10, 2020

I think current_docname is intentionally used here. Could you check node.source is working fine on dirhtml or singlehtml builders?

@yves-chevallier
Copy link
Contributor Author

In either case (html, dirhtml, singlehtml, latex), node.source equals the absolute path of the file :

'/home/me/test-sandbox/other.rst'

The value of self.builder.current_docname is less verbose, it is

'other'

But the output is in either case the abs path and it work with all builders.

@tk0miya
Copy link
Member

tk0miya commented Aug 11, 2020

Ah, my last comment was wrong. Absolutely you're right. We have to use location=node instead of current_docname. It uses node.source internally.

@tk0miya tk0miya added this to the 3.3.0 milestone Aug 11, 2020
tk0miya added a commit that referenced this issue Aug 12, 2020
Use current node location in case of error (related to #8093)
@tk0miya tk0miya closed this as completed Aug 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants