OpenDataServices / sphinxcontrib-opendataservices-jsonschema

https://sphinxcontrib-opendataservices-jsonschema.readthedocs.io/en/latest/
Other
3 stars 0 forks source link

sphinxcontrib/jsonschema.py: Replace '_' with '-' in links to HTML anchors #51

Closed duncandewhurst closed 1 year ago

duncandewhurst commented 1 year ago

Sphinx replaces the _ character in HTML anchors with -, per https://docutils.sourceforge.io/docutils/nodes.py:

Docutils identifiers will conform to the regular expression
``[a-z](-?[a-z0-9]+)*``.  For CSS compatibility, identifiers (the "class"
and "id" attributes) should have no underscores, colons, or periods.
Hyphens may be used.

This PR does the same in the links generated when nocrossref isn't specified.

@Bjwebb I'm assuming that you're the right person to review this, but let me know if not!

Bjwebb commented 1 year ago

Would it be better to use make_id from https://docutils.sourceforge.io/docutils/nodes.py directly, so that other cases besides - are handled?

duncandewhurst commented 1 year ago

Good thinking :-) is doing that just a case of replacing ref.lower().replace('_', '-') with make_id(ref)?

Bjwebb commented 1 year ago

Should be, yes.

duncandewhurst commented 1 year ago

@Bjwebb done!

Bjwebb commented 1 year ago

LGTM, but the tests have broken on main since that was last updated. We need to fix that before this can be merged.

odscjames commented 1 year ago

Rebased onto working main, so tests work now. I don't know if this PR needs some tests of it's own?