Skip to content

Conversation

breezykermo
Copy link
Contributor

A follow-on from #6894 that hews more closely to the HTML spec in terms of roles and also provides links from citations to their references.

I noticed that the work of finding the appropriate locations was already done when parsing the keys etc from hayagriva, so it seemed more appropriate to surface that in the Works data structure than to do it again. But I am still new to Typst internals, so please let me know if this is the correct approach or if there are downstream consequences of adding a field of which I might not be aware.

Performance implications

The implications of adding the extra hash map to the Works data structure seem (from my naive point of view) acceptable because:

  • Values are only added if the reference is actually printed in the bibliography. In other words, there is not necessarily an entry for every listing in a large .bib file. Thus while it does require some extra memory in the compiler, it is not a large amount (I don't think), and it scales linearly with the number of items that appear in the bibliography.

Questions

It's not entirely clear to me why the CiteGroup doesn't automatically create a LinkElem in the HTML render pathway. I assume from #6917 that it has to be explicitly added for some reason to get an <a> tag to appear in HTML, but I would be happy for someone to point out that there is some easier way to get it than what I have done here.

With thanks to @willcrichton for his help in thinking about this change (though any and all deficiencies in the approach are my responsibility solely!)

Copy link
Contributor

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I wanted to leave some initial thoughts before further opinions from the team. Most of them are related to code style and general quality, but otherwise this is looking nice! Let me know if you have any questions.

By the way, please don't close your pull request in order to apply changes, even if you want to start fresh. This causes the original conversation history and reviews to be lost (or, rather, not attached to the new PR), making it harder to navigate the discussion.

Instead, push any new changes to the pull request's branch in your fork. If you need to reset your changes, you can, for example, push a change where you just replace all files with what they were before you started your work. Thanks! :)

The `.linked` call in the bibliography call didn't automatically affect HTML export, but with the workaround using `DirectLinkElem` (and in the future just direct usage of `LinkElem`), we can use the same linking code across all targets.
This means that the `id` of a bibliography entry is attached to its `<li>` element instead of to the first leaf
This only has an effect for the (rather rare) styles that use `display="left-margin"`.
Just like in outline and footnote list
@laurmaedje laurmaedje added this pull request to the merge queue Oct 1, 2025
Merged via the queue into typst:main with commit 936baa7 Oct 1, 2025
8 checks passed
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.

4 participants