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

No special treatment of plain anchors <a id="..."> #4753

Closed

Conversation

ralfhandl
Copy link

@ralfhandl ralfhandl commented Jul 10, 2024

Ignore <a id="..."> in addition to <a href="..."> and some other anchor variants.

This style of anchors is the typical (only?) way to create a local link target in Markdown documents.

Fixes #4747

@sidvishnoi
Copy link
Member

This check is too strong. I think this needs some fixing only in core/xref.

@ralfhandl
Copy link
Author

I think this needs some fixing only in core/xref.

Question is what to check for: anchor elements with an id and no content, as anchor elements with content are used for magic cross-referencing?

@sidvishnoi
Copy link
Member

sidvishnoi commented Jul 10, 2024

Is this intended to be used for defining IDs for sharing URL with fragments only? Also, why not using a <dfn> there as it looks like a use of dfn there?

If it's needed regardless, we'd need to update core/link-to-dfn to add that check to ensure it doesn't go into either of possibleExternalLinks or badLinks. Then might also need to update core/anchor-expander so it doesn't try to use other special expansion behavior.

Also, might be ok to use <a name="foo"></a> instead of <a id="foo"></a>? That might be easier to bypass ReSpec's processing.

Also, please add a test first so we know it works as expected and doesn't regress in future.

@ralfhandl
Copy link
Author

might be ok to use <a name="foo"></a> instead of <a id="foo"></a>

Using name runs into the same issues as using id, and name is deprecated, so not where I'd like to go.

@ralfhandl ralfhandl marked this pull request as draft July 10, 2024 13:13
@ralfhandl
Copy link
Author

Also, why not using a <dfn> there as it looks like a use of dfn there?

I can't figure out how to do that.

The specifications are pure markdown, and we do not want to rewrite them, so they are "respec-ified" by a build script.

I could try to rewrite patterns like

<a name="oasSecurity"></a>security

and

<a name="operationSecurity"></a>security

into two different <dfn>s with the same text "url", and then rewrite references to them such as

top-level [`security`](#oasSecurity)`

Unfortunately I can't figure out from the ReSpec documentation whether that is possible at all.

@ralfhandl
Copy link
Author

ralfhandl commented Jul 10, 2024

What seems to work is rewriting

<a name="oasSecurity"></a>security

into

<a id="oasSecurity" class="logo"></a>security

as anchors with this class are already ignored in

"a[data-cite=''], a:not([href]):not([data-cite]):not(.logo):not(.externalDFN)"

@sidvishnoi Does this hack have foreseeable negative side-effects?

@ralfhandl ralfhandl closed this Jul 15, 2024
@ralfhandl ralfhandl deleted the allow-html-anchor-element-with-id branch July 15, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty anchor (<a id="foo></a>) tag creates superfluous reference entry
2 participants