Skip to content

feat(typst-community/glossarium/#188): adjust default styling in glossary#190

Open
MoritzFrings wants to merge 3 commits intotypst-community:masterfrom
MoritzFrings:188/adjust-default-styling-in-glossary
Open

feat(typst-community/glossarium/#188): adjust default styling in glossary#190
MoritzFrings wants to merge 3 commits intotypst-community:masterfrom
MoritzFrings:188/adjust-default-styling-in-glossary

Conversation

@MoritzFrings
Copy link
Copy Markdown

Resolves #188

Problem

Currently, if a user defines an entry with internal styling (e.g., using raw() for an acronym), that styling "leaks" into the printed glossary. This creates inconsistent visuals when mixed with plain-text entries.

#let abbreviation_list = (
  (
    key: "mdc",
    short: raw("MDC"),
    long: raw("Mapped Diagnostic Context"),
  ),
  (
    key: "cpu",
    short: "CPU",
    long: "Central Processing Unit",
  ),
)

In the example above, "MDC" would appear in a monospace font while "CPU" follows the document's body font, breaking the visual rhythm of the glossary list.

Solution: get-plain-text

I have introduced a get-plain-text(object) helper. This function recursively digs through Typst content to extract raw strings, effectively "cleaning" the data before default-print-title applies its own consistent styling (like strong or emph).

Why not other approaches

  • While style-entries allows for global customization, it doesn't solve the problem of individual entries containing internal formatting that conflicts with the glossary's design. The glossary should have the final say on the title's appearance to ensure consistency.
  • I think that styling can get into the glossary should not be possible to prevent breaking the visual rhythm of the glossary. Therefore updating the default-print-title function in this case is best from my point of view
  • This approach specifically targets the title of entries. I intentionally left default-print-description untouched, as users often want to use styling within the body of a definition, whereas a title should remain a clean, predictable identifier.

Documentation Updates

The existing internal documentation was technical and sparse. I have updated the docstrings for default-print-title and get-plain-text to be more beginner-friendly, focusing on the "what and why" of the functions.

Feel free to comment on my changes or even suggest a different approach!

…styling in glossary so that applied styling on glossary entry is removed
@MoritzFrings
Copy link
Copy Markdown
Author

Maybe as a small info: I also used ai when updating/writing the signatures/docs. Hope that's fine :)

@quachpas
Copy link
Copy Markdown
Collaborator

Maybe as a small info: I also used ai when updating/writing the signatures/docs. Hope that's fine :)

That's fine as long as you actually read and tested the patched before submitting it.

@quachpas
Copy link
Copy Markdown
Collaborator

Currently, if a user defines an entry with internal styling (e.g., using raw() for an acronym), that styling "leaks" into the printed glossary. This creates inconsistent visuals when mixed with plain-text entries.

I'm sorry to say I fail to see where the problem is. Can you explain your line of thought? IMO, if a user defines a short to be raw(MDC), glossarium does not hold the responsibility to change that formatting. It would actually be less convenient with the proposed behaviour to convert everything back to plain text, in addition to making it easier to throw errors when the internal Typst API changes.

@MoritzDFrings
Copy link
Copy Markdown

MoritzDFrings commented Apr 16, 2026

I'm sorry to say I fail to see where the problem is. Can you explain your line of thought? IMO, if a user defines a short to be raw(MDC), glossarium does not hold the responsibility to change that formatting. It would actually be less convenient with the proposed behaviour to convert everything back to plain text, in addition to making it easier to throw errors when the internal Typst API changes.

Hey!
I agree with your point that when a user styles a short version raw(MDC) that it should be styled like that. But from my understanding I am also interested in using this approach to also centralise the raw-block in all occurences of the short version. When talking about the glossary, I think glossarium should apply a styling that shouldn't change except the user indeed wants that (using a different theme, theuser-print-title(entry) function etc.).

I would say that also applying the raw-block in the glossary by default is in the majority of times NOT the intended behavior the user wants. The user wants a uniform styling in its glossary and therefore I suggest also implementing this to enforce this. If you think that this does not fit with your understanding, what about a feature toggle enforce-theme-styling: true on the print-glossary()? Therefore if a user wants this behaviour, it is at least easily achievable.

In my case I now implemented a custom user-print-title: ... that is the same theme as the default glossarium theme, just also enforcing that glossarium follows it strictly. And I think for this situation glossarium should provide an easier way as I would say that is a common user request.

What is your opinion on that?

p.s.: Sorry for taking so long to reply

…xt` call to `get-plain-text`

During refactoring and renaming the function I did not update all occurrences of the function
@quachpas
Copy link
Copy Markdown
Collaborator

p.s.: Sorry for taking so long to reply

NP!

I would say that also applying the raw-block in the glossary by default is in the majority of times NOT the intended behavior the user wants.

Are you saying that you want MDC to be raw(MDC) for references @MDC but not in the printed glossary?

@MoritzDFrings
Copy link
Copy Markdown

Are you saying that you want MDC to be raw(MDC) for references @MDC but not in the printed glossary?

Yes that's exactly my point. What are your thoughts on that?

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.

Fine-grained styling per entry on glossary and/or references

3 participants