executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
760 stars 196 forks source link

MyST is not generating anchors correctly, and unrelated changes seem to change the behavior #560

Open deepyaman opened 2 years ago

deepyaman commented 2 years ago

Describe the bug

context When I migrate notes from recommonmark to MyST syntax.

expectation I expected anchor generation to be unaffected.

bug But it's not. See reproduction below.

problem This is a problem for people migrating to MyST, or a potential bug in general?

Reproduce the bug

See https://github.com/deepyaman/kedro/commit/67c8a0f12b54d1143dc6a87fdec085d2cc4d7789.

Before the above change to migrate from recommonmark to MyST syntax:

(kedro) WASH-178551-C02X31K9JHD4:kedro deepyaman_datta$ myst-anchors -l 3 docs/source/contribution/developer_contributor_guidelines.md
<h1 id="guidelines-for-contributing-developers"></h1>
<h2 id="introduction"></h2>
<h2 id="before-you-start-development-set-up"></h2>
<h2 id="get-started-areas-of-contribution"></h2>
<h3 id="core-contribution-process"></h3>
<h3 id="extras-contribution-process"></h3>
<h2 id="create-a-pull-request"></h2>
<h3 id="hints-on-pre-commit-usage"></h3>
<h3 id="developer-certificate-of-origin"></h3>
<h2 id="need-help"></h2>

After the change:

(kedro) WASH-178551-C02X31K9JHD4:kedro deepyaman_datta$ myst-anchors -l 3 docs/source/contribution/developer_contributor_guidelines.md
<h1 id="guidelines-for-contributing-developers"></h1>
<h3 id="extras-contribution-process"></h3>
<h2 id="create-a-pull-request"></h2>
<h3 id="hints-on-pre-commit-usage"></h3>
<h3 id="developer-certificate-of-origin"></h3>
<h2 id="need-help"></h2>

After moving just the first note to a new line, things are fixed again:

(kedro) WASH-178551-C02X31K9JHD4:kedro deepyaman_datta$ myst-anchors -l 3 docs/source/contribution/developer_contributor_guidelines.md
<h1 id="guidelines-for-contributing-developers"></h1>
<h2 id="introduction"></h2>
<h2 id="before-you-start-development-set-up"></h2>
<h2 id="get-started-areas-of-contribution"></h2>
<h3 id="core-contribution-process"></h3>
<h3 id="extras-contribution-process"></h3>
<h2 id="create-a-pull-request"></h2>
<h3 id="hints-on-pre-commit-usage"></h3>
<h3 id="developer-certificate-of-origin"></h3>
<h2 id="need-help"></h2>

List your environment

myst-parser==0.17.2 on Python 3.7 on OSX (but problem is replicated in our CI build)

welcome[bot] commented 2 years ago

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: