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
Xref does not support slash in the id #1540
Comments
That's because, as far as understand, Here's the regexp we use specifically:
...which is perhaps easier to read in the non-unicode aware variant
Forward slash is not an allowed character. |
I'd also say that these rules for IDs are pretty universal. So much so that it would cause a lot of problems for converters if we were not this strict. |
Keep in mind that the
|
Is this reasoning acceptable? |
This makes sense... I wanted to add a sentence in 29.1. Defining an Anchor. In the HTML backend case, just dropping the complete line without any error is not really nice. |
Definitely. We should be very explicit about what a valid ID is and what to keep in mind when selecting characters. What might help are "good examples" vs "bad examples" kind of thing. It gets the point across well.
I think it just leaves it unparsed, doesn't it? |
Ok this is true. I had something else in mind. The image bloc is broken and therefore the xref links switch to the "anchor not found" mode. |
Hmmm, If the user explicitly requests a given ID, wouldn't it be better to just honor it? E.g. this would be a good ID formation when merging big subjects into smaller topics:
|
Similar for allowing the ID to start with digits, appears legal in HTML5. Also found this related ticket now: #3307 |
The reason for the restricted syntax is historical. It's also because it ensures a valid ID for DocBook (which requires that the ID be a valid XML name). Changing it would diverge with AsciiDoc Python (which I'm not necessarily opposed to). If you want to lift all restrictions today, you can use the See #2777 (comment) for more context. |
Cool, thanks for mentioning the workaround Dan, I didn't know that one. |
I did some thinking about this and I think what a valid ID is should really be up to a validator or the user, not the processor. The one risk with changing the matcher is that it could end up matching lines it didn't previously match. Now, give that the ID is enclosed in double square brackets, I think the risk of that is pretty low. But we still have to put some boundaries on what we're matching. I think a slash is reasonable, as is a leading number. But we have to think hard about what we allow beyond that. |
Thanks for looking into this! Yes, definitely, I understand that all those decisions are hard to make. I wonder if anything would break if we just forbade the |
I would strongly recommend forbidding end of line so if the user makes a mistake with the closing |
That would go way too far, IMO. Of course, we're already line-based, so it would be still be restricted to a single line. But when you think about what it could match, such as a paragraph that starts with |
It seems that some work has been done since and for example ":" and "_" are now allowed in IDs (assuming it really wasn't supported before).
|
It seems that slashes
/
are not supported in key names for the cross-references (id of the xref).This do not work:
This works:
The only difference between the two snippets is the id:
img-sunset
works andimg/sunset
does not work.When slashes are used, it breaks not only the xref:
Tested with version 1.5.2 (used with maven)
The text was updated successfully, but these errors were encountered: