mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-16 19:06:45 +03:00
Ability to create Glossary (in-line definitions) for words... #5043
Closed
opened 2026-02-05 09:36:14 +03:00 by OVERLORD
·
8 comments
No Branch/Tag Specified
development
l10n_development
release
v25-12
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
pull-request
Mirrored from GitHub Pull Request
No Label
🔨 Feature Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#5043
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kristiandg on GitHub (Nov 11, 2024).
Describe the feature you'd like
The ability to create a Glossary, and have words that match the Glossary auto-underlined within a Book/Page, so when the user hovers over that underlined word, a small popup appears describing that item.
In the pictures below, you can see that the word "DNS" has been placed in the Glossary of this example website, and is auto-underlined wherever that word appears.

When you hover over that word, it then displays the definition for the user:

(In the example pics, there's also a note of who created the dictionary entry, as well as the option to vote on the description. I don't care about that portion of the feature - others might though - but in general, the ability to define a list of words you'd want to provide a definition for, and hover over the word to read the definition).
Because BookStack is so versatile, it would be highly limiting to assign definitions globally for the server.
For example, one book may have DNS as Domain Name System, and another book may have DNS as Distributed Normal Slouchiness. :), I'm thinking either a definition list per book (though that seems like a lot of redundant work), or (ideally) a section within BookStack to build/manage glossary terms (naming each glossary), and when you edit the book, you can apply one (or many) to that book. The reason for "many" is that you could have a Glossary of "technical terms" and apply it to the book, but then you could also have another glossary for a product-specific item, and apply it to the book as well. Whereas if you could only apply one, you may end up having to create duplicate terms in several glossaries. By being able to assign multiple, you could create very specific glossaries for sub-sections of an item, and all those that apply to the book, then get assigned.
Describe the benefits this would bring to existing BookStack users
This would allow the user to get detailed descriptions of the meaning of a word without having to leave the site.
Can the goal of this request already be achieved via other means?
As far as I know, no such function exists within BookStack that I have found or read in documentation.
Have you searched for an existing open/closed issue?
How long have you been using BookStack?
Under 3 months
Additional context
WIKI does something similar to this, by having clickable links instead. I personally don't like the clickable links, because they look like off-page resources. The underline option, to me, is much cleaner.
@ssddanbrown commented on GitHub (Nov 11, 2024):
Thanks for the request @kristiandg, but I would consider this a duplicate of #428 so will likely close this off.
It's probably possible to create a JavaScript hack though which looks up from a specific glossary page(s) for display in the desired manner. If desired, I could maybe whip a quick example but it just won't be officially supported at all.
@kristiandg commented on GitHub (Nov 12, 2024):
I never thought of that. I’m also not skilled in coding but would be very appreciative if you could. That would be wonderful. On Nov 11, 2024, at 2:55 PM, Dan Brown @.***> wrote:
Thanks for the request @kristiandg, but I would consider this a duplicate of #428 so will likely close this off.
It's probably possible to create a JavaScript hack though which looks up from a specific glossary page(s) for display in the desired manner. If desired, I could maybe whip a quick example but it just won't be officially supported at all.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
@ssddanbrown commented on GitHub (Nov 12, 2024):
Okay, here's a basic example I've spent some time on.
To keep the scope reasonable and to limit spending loads of time, there's some important limitations:
Here's the code:
View Code
Add all of that the the "Custom HTML Head Content" customization setting.
This will look up to a global glossary, defined via a single page on line 2 of the code (tweak this URL to the path of your own global glossary page, but keep the path format the same) while also looking up a page of URL slug (typically name)
Glossaryin the book for the current page you're viewing.Glossary pages should have their content written like so:
Terms are matched case-insensitive.
Glossaries are cached in the browser to prevent needing a lookup on each page load. They can be force reloaded by simply viewing the changed glossary page.
Note: there may be further bugs and limitations of this, I've only quickly tested and this if all unofficial hackery.
Let me know if that works for you. If it does, I may clean it up and add it to our hacks site for others to easily use.
@kristiandg commented on GitHub (Nov 12, 2024):
@ssddanbrown , THANK YOU SO MUCH!!!
I want to make sure I'm doing the URL replacement properly.
const urlPath = window./books/global-glossary(/^.*?\/books\//, '/books/');Is the above correct, or do I need the full Server URL (since the rest appears to be coded as relative path, I figured this would work).

In that book, I created a page called "glossary" and built one test entry:
Permission-wise, I have the access to view that Glossary page, so that shouldn't be a limiting factor.
Here's where I pasted your code:

In my test book, I've used the term VPN in a couple of locations, but am not seeing it bubble up or highlight. I have no doubt I'm doing something wrong.
@ssddanbrown commented on GitHub (Nov 12, 2024):
No, sorry, I should have been more clear, it's line 2 overall, so the value of the
defaultGlossaryPagevariable.Edit: To add more context, you just need to change the
my-bookandmain-glossaryparts of that text to match the URL sub-path for your main global/default/fallback glossary page.Should not need to touch any other lines.
@kristiandg commented on GitHub (Nov 12, 2024):
Oh, for god sakes. LOL. You were crystal clear (line 2 - line 2 - jeez). I just hadn't had my coffee yet.
Works beautifully. THANK YOU SO MUCH.
Even the nice little touch with the cursor becoming a ? - VERY NICE. :)
@JNR8 commented on GitHub (Nov 20, 2024):
After implementting a global glossary to test this out I have come across a few issues:
1: Terms in a header are highlighted, when perhaps they should not be.

2: The term being highlighted is duplicated (but not all the time, see attached image).
3: Terms are not always displayed. Different browsers have different results. MS Edge for example throws an exception:
@kristiandg commented on GitHub (Jan 12, 2025):
I did just find an oddity on this... I got around the "single word" thing by simply smashing the multiple words together for a glossary (such as "Call Queue" becomes "CallQueue". But I noticed this (and it doesn't happen on every occurrence of the word):
Original text (during editing):

Modified text (during viewing):

Here's the relevant section of the Glossary:

It's odd, I'm not sure why it's adding "NightMode" onto the end of that particular definition, but it's not doing it all the time, doing that.
It did it one other time in the document (inside of a table, it doubled up on it's "plural" version of the definition:

I also noticed, when Glossary finds a match in a Callout, the floating window is constrained to the size of the callout window, making it now scroll (this one's kinda funny):
