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

Support direct navigation to individual items in def_list #1123

Open
jasper-zanjani opened this issue Mar 26, 2021 · 5 comments
Open

Support direct navigation to individual items in def_list #1123

jasper-zanjani opened this issue Mar 26, 2021 · 5 comments
Labels
extension Related to one or more of the included extensions. feature Feature request. someday-maybe Approved low priority request.

Comments

@jasper-zanjani
Copy link

In a knowledge base with many terms, using the Definition list extension as-is requires use of text search or simply scrolling. This is because there is no way to easily navigate to a specific Definition List item. If an id attribute were generated as it is for headings, users would be able to create links to the specific item in the body of the page.

I have posted a similar request as #2495 in the squidfunk/mkdocs-material repo.

@waylan
Copy link
Member

waylan commented Mar 26, 2021

Have you tried using the attr_list extension, which allows you to define your own IDs on elements?

That said, autogenerated IDs would be a reasonable feature of the def_list extension, perhaps as an optional feature which is enabled by a config option. A PR adding such a feature would certainly be considered.

@waylan waylan added extension Related to one or more of the included extensions. feature Feature request. labels Mar 26, 2021
@waylan
Copy link
Member

waylan commented Mar 26, 2021

Here is an example using the attr_list extension:

foo { #foo }
: bar

key { #key }
: value

which generates the following HTML:

<dl>
<dt id="foo">foo</dt>
<dd>bar</dd>
<dt id="key">key</dt>
<dd>value</dd>
</dl>

@jasper-zanjani
Copy link
Author

jasper-zanjani commented Mar 26, 2021

True, that is an acceptable workaround. If def_list supported a configuration option to automatically create those, it would save a lot of fat-fingering.

@ssbarnea
Copy link

ssbarnea commented Mar 16, 2023

I do not think that this fully works correctly because I do not see the link acting when I hover of the the definitions lists.

I checked and the anchors are created, so you could use them for referencing but users cannot copy a bookmark due to lack of hover option (like we have on headings).

This impacts the UX, as nobody will know how to share a link to a specific definition list entry.

Looking at the source of headers, I see

<h2 id="general-parameters">General parameters<a class="headerlink" href="#general-parameters" title="Permanent link">¶</a></h2>

While the DL entries have the expected id, they lack the magic bit to be made fully usable.

Did anyone managed to implement a full solution for this?

@waylan
Copy link
Member

waylan commented Mar 16, 2023

@ssbarnea this issue is tagged as 'someday-maybe' which suggests that it is a low priority item which is not going to get any attention by the core developers. If someone would like a full solution, then they will need to do the work and submit a PR, which we will be happy to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension Related to one or more of the included extensions. feature Feature request. someday-maybe Approved low priority request.
Projects
None yet
Development

No branches or pull requests

3 participants