-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
bug: Problems linking to generated targets #58
Comments
Thank you for the bug report / feature request @pekkaklarck, I think it makes a lot of sense. We can definitely consider "slugifying" titles when no identifier is provided (and after having tried with the actual title as id, probably). At first glance, this shouldn't cause any issue if we do this by default, but I'll have a deeper look 🙂 |
That would be awesome! And yes, should first check is there a match with the original title before sluggifying. |
Looking into this. When referencing API docs, it's important to retain case-sensitivity, since object names themselves are most likely case-sensitive (that's the case for Python for example). So how to distinguish when we would like to try and slugify (in case of title not matching as is), and when we wouldn't want that? I think there's a simple answer: if the title is wrapped in backticks, maintain case-sensitivity (and more generally, don't try to slugify the title at all). All the following examples assume there's no direct match with the title unchanged:
We basically want to match a single pair of equally long series of backticks, wrapping the whole string. Might be possible with a simple regex actually? Something like With other features coming up, we could also decide to drop these implicit rules in favor of waiting for a proper, more elaborated syntax, that would allow more flexibility. Such a syntax could be based on Just quick examples of what it could look like
Or we could first implement the implicit slugification, and allow overriding it with custom syntax (attr lists) later. Seems like the best way forward to me. I really don't want to force users to write tons of metadata in cross-references if we can get 95% of all uses right with implicit/default rules. The custom syntax must also not look too magic/obscure, and not be too verbose. |
Does autorefs know that link targets are available? If it does, then it could work like this:
|
It knows. The issue with always falling back is that it's unwanted in some cases. Consider this: class Bicycle:
...
bicycle = Bicycle()
"""This is my bicycle."""
def compare(b1: Bicycle, b2: Bicycle) -> bool:
"""Compare instances of [`Bicycle`][]."""
... Now imagine that |
I might be submitting this to a wrong project, but because I don't know any better place, and this is at least related to autorefs, I decided to submit it here. Feel free to close this if the place is wrong. If you know a better place, please let me know.
Let's first assume I have the following content:
When I have autorefs installed, I can very conveniently link to the Welcome section using this syntax:
This is very similar, and equally convenient, than the syntax I'm used to with reStructuredText and Sphinx:
The problem is that I'd typically like to refer to sections so that the name starts with a capital letter as below, but in this case auto-linking doesn't work:
There's also a problem with headings having spaces. For example, this doesn't work:
I know I can get both of the above to work by including the actual link target as below:
The problem with adding those link targets is that it requires writing redundant content, makes document source less readable and is inconsistent. Inconsistency also means you can easily forget to add the target when in some cases it is not needed. Notice that with reStructuredText and Sphinx these work out-of-the-box:
My first problem that
[Welcome][]
isn't handled case-insensitively feels like a bug to me, because according to the original Markdown spec, reference targets are case-insensitive. There is, for example, an example like this:The odd thing is that the above example is handled fine by MkDocs. It's strange that
[Google][]
works when the references target is[google]:
, but[Welcome][]
doesn't work when the reference target ought to be something similar.My second problem that
[just testing][]
is not linked to the generatedjust-testing
target is something where my wish is against the Markdown spec. This example from the spec wouldn't work if spaces would be automatically replaces with hyphens:Although I'm fighting against the spec, I feel that this syntax would be really convenient. Is it something autorefs could support? If there are backwards compatibility concerns, it didn't need to be enabled by default, but having an option to enable this behavior would be awesome. If this is something autorefs cannot do or it doesn't belong to its scope, do you have ideas how I could enable the behavior otherwise? I'm willing to implement a plugin if needed and would also be ready to provide a PR to autorefs if this feature could be added to it.
Boost priority
The text was updated successfully, but these errors were encountered: