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

Target ids are sanitised, so may not align with e.g. references in ref roles #16

Open
mbercx opened this issue May 15, 2021 · 1 comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@mbercx
Copy link

mbercx commented May 15, 2021

Describe the bug

Underscores _ inside a target header seem to get converted into hyphens -, but not for the references. E.g. this .rst snippet:

.. _test_snippet:

.. code-block:: Python

    # This is a test snippet.

Dude, check out that :ref:`test snippet <test_snippet>`!

Gets converted into:

(test-snippet)=

```{code-block} Python

# This is a test snippet.

```#

Dude, check out that {ref}`test snippet <test_snippet>`!

Expected behavior

Either the underscores should be preserved, or both the target header and references should be converted into hyphens, in case this is preferred.

Environment

  • Python Version [e.g. 3.7.1]: 3.8.6
  • Package versions or output of jupyter-book --version:
    $ pip freeze | grep myst
    myst-nb==0.13.0a1
    myst-parser==0.14.0a2
    rst-to-myst==0.1.2
  • Operating System: macOS Big Sur 11.3.1
@mbercx mbercx added the bug Something isn't working label May 15, 2021
@chrisjsewell
Copy link
Member

Heya, docutils id creation is defined here: https://github.com/chrisjsewell/docutils/blob/8adab0660b2097b4f3c32cef7e5ff4cb3c72b084/docutils/docutils/nodes.py#L2196; basically every non-alphanumeric character gets converted to a -, and so actually test_snippet should still match test-snippet (although let me know if you think this is not the case)

I'm going to mark this therefore as an documentation/improvement issue, not a bug; it would be nice to align them, but its a bit tricky to achieve in the code

@chrisjsewell chrisjsewell added documentation Improvements or additions to documentation enhancement New feature or request and removed bug Something isn't working labels Jun 22, 2021
@chrisjsewell chrisjsewell changed the title 🐛 Target header _ get converted into - Target ids are sanitised, so may not align with e.g. references in ref roles Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants