CrossNox / m2r2

Markdown to reStructuredText converter
https://crossnox.github.io/m2r2
MIT License
107 stars 26 forks source link

Duplicate explicit target name for links #30

Closed matthieucan closed 3 years ago

matthieucan commented 3 years ago

Hello, When a markdown document contains more than 1 link whose name is identical, m2r2 generates those links but fails to make them anonymous references. According to https://github.com/sphinx-doc/sphinx/issues/3921 this doesn't follow ReST specs.

How to reproduce:

% cat foo.md
[foo](https://foo.bar)
[foo](https://bar.foo)
% m2r2 foo.md
% cat foo.rst

`foo <https://foo.bar>`_
`foo <https://bar.foo>`_
% rst2html.py foo.rst > /dev/null
foo.rst:3: (WARNING/2) Duplicate explicit target name: "foo".
CrossNox commented 3 years ago

Hello @matthieucan, I think you'd want to run as m2r2 --anonymous-references foo.md ?

matthieucan commented 3 years ago

Hi @CrossNox, thank you very much, that fixed my problem! :+1:

ItsDrike commented 1 year ago

Is it possible to enable anonymous references when using .. mdinclude within another rst document?

briantist commented 11 months ago

For anyone else who had this issue and wondering how to set the value in conf.py when used with sphinx:

m2r_anonymous_references = True

The sphinx option names can be seen here: https://github.com/CrossNox/m2r2/blob/0408d7acea843485d9ff42ee08a105a79f045493/m2r2.py#L675C27-L675C51