MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Auto-generated header anchors don't work with absolute file path

Open pohly opened this issue 3 years ago • 2 comments

Describe the bug

context

With myst_heading_anchors = 3 I get the expected anchors:

$ myst-anchors wiki/synchronizing-evolution-http-howto.md 
<h2 id="requirements"></h2>
<h2 id="steps-for-two-computers"></h2>
<h2 id="steps-for-a-computer-and-a-phone"></h2>
<h2 id="synchronizing-additional-databases"></h2>

I can reference that anchor from within the same file and with a relative path from some other file, but not with an absolute path. The other file is wiki/HOWTO.md

This works in wiki/HOWTO.md:

./synchronizing-evolution-http-howto.md#synchronizing-additional-databases
../wiki/synchronizing-evolution-http-howto.md#synchronizing-additional-databases

expectation

Absolute paths should also work.

bug

This doesn't work:

/wiki/synchronizing-evolution-http-howto.md#synchronizing-additional-databases
wiki/HOWTO.md:33: WARNING: 'myst' reference target not found: /wiki/synchronizing-evolution-http-howto.md#synchronizing-additional-databases

problem

I was using absolute paths because they work the same everywhere. Took me a while to find the workaround with relative paths :sweat_smile:

I then realized that the documentation says "paths to other files should be relative to the current file" (emphasis mine). If the implementation cannot be changed to support absolute paths, then the documentation should be changed to "must be relative".

Reproduce the bug

Check out https://gitlab.freedesktop.org/SyncEvolution/syncevolution/-/tree/gitlab-pages, run "make".

List your environment

I am using:

Python 3.9.2

sphinx==5.0.2
myst-parser==0.18.0
ablog==0.10.25
linkify-it-py==2.0.0
pydata-sphinx-theme==0.9.0

pohly avatar Jul 04 '22 07:07 pohly

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Jul 04 '22 07:07 welcome[bot]

~~Hmm, I also have other references where an absolute path does not work although they don't use an anchor. Now I am confused about whether absolute paths are allowed at all or when.~~

The absolute path works, I just had the filename wrong. Sorry for the noise...

pohly avatar Jul 04 '22 07:07 pohly