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

Section links when converting Markdown to RST #1627

Open
HealthyPear opened this issue Sep 1, 2021 · 4 comments
Open

Section links when converting Markdown to RST #1627

HealthyPear opened this issue Sep 1, 2021 · 4 comments
Labels

Comments

@HealthyPear
Copy link

Not sure if is it a bug or something I didn't understand.

I have a Jupyter notebook in which I made a markdown table of contents like the following,

## Table of contents
- [A](#A)
    - [A1](#A1)
- [B](#B)
- [C](#C)
    - [C1](#C1)
    - [C2](#C2)

and then I call each section like so,

## A
[back to top](#Table-of-contents)

If I use the notebook as it is it works well, but I have the need to convert it to RST in my sphinx-based documentation (using directly HTML seemed more difficult and I didn't want to add to my repo the executed notebooks anymore).

So I installed pandoc and then did something like jupyter nbconvert --to rst Untitled.ipynb, so I have my Untitled.rst which get reproduced in my docs.

Problem is, all the links do not work anymore.

In the RST file I see the links as, e.g.

-  `A <#A>`__

and in the html page,

<li><p><a class="reference external" href="#A">A</a></p>

I am not an HTML expert, but at least the RST link seems to me a web link and not a section (or :ref) link.
Am I right? Or am I missing something?

@HealthyPear
Copy link
Author

I think I found the problem and it seems a bug:

all the section links are generated in HTML like this,

<h3>A1<a class="headerlink" href="#a1" title="Permalink to this headline"></a></h3>

but the correspondent one in the table of contents is,

<li><p><a class="reference external" href="#A1">A1</a></p></li>

which is wrong.
In fact if I edit it like

<li><p><a class="reference external" href="#a1">A1</a></p></li>

it works

same with the table of contents, the section link is

<p><a class="reference external" href="#Table-of-contents">back to top</a></p>

while the actual header is

<h2>Table of contents<a class="headerlink" href="#table-of-contents" title="Permalink to this headline"></a></h2>

so it seems that the conversion puts all the header in lower-case, killing the links

I would open a proper "bug" issue, since I cannot change the labeling here, but I'll wait a bit to see if anyone has something else to say,

@HealthyPear
Copy link
Author

I found this was already addressed on pandoc's side

jgm/pandoc#3616

@HealthyPear
Copy link
Author

by the way if the RST output is correct as it is, it could be also a problem in using sphinx

@MSeal MSeal added bug and removed question labels Sep 12, 2021
@MSeal
Copy link
Contributor

MSeal commented Sep 12, 2021

That does look to be a bug someone needs to fix in the templating. I'm not sure if something changed in sphinx to make it more strict or if we had issues with the output for some time.

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

No branches or pull requests

2 participants