Link reference in HTML export

This commit is contained in:
Laurenz 2025-07-15 10:44:21 +02:00
parent cf327650ba
commit 12c66e36b5

View File

@ -5,12 +5,13 @@ use crate::diag::{bail, At, Hint, SourceResult};
use crate::engine::Engine; use crate::engine::Engine;
use crate::foundations::{ use crate::foundations::{
cast, elem, Cast, Content, Context, Func, IntoValue, Label, NativeElement, Packed, cast, elem, Cast, Content, Context, Func, IntoValue, Label, NativeElement, Packed,
Repr, Smart, StyleChain, Synthesize, Repr, Smart, StyleChain, Synthesize, TargetElem,
}; };
use crate::introspection::{Counter, CounterKey, Locatable}; use crate::introspection::{Counter, CounterKey, Locatable};
use crate::math::EquationElem; use crate::math::EquationElem;
use crate::model::{ use crate::model::{
BibliographyElem, CiteElem, Destination, Figurable, FootnoteElem, Numbering, BibliographyElem, CiteElem, Destination, Figurable, FootnoteElem, LinkElem,
LinkTarget, Numbering,
}; };
use crate::text::TextElem; use crate::text::TextElem;
@ -346,7 +347,14 @@ fn realize_reference(
content = supplement + TextElem::packed("\u{a0}") + content; content = supplement + TextElem::packed("\u{a0}") + content;
} }
Ok(content.linked(Destination::Location(loc))) Ok(if styles.get(TargetElem::target).is_html() {
LinkElem::new(LinkTarget::Dest(Destination::Location(loc)), content).pack()
} else {
// TODO: We should probably also use `LinkElem` in the paged target, but
// it's a bit breaking and it becomes hard to style links without
// affecting references, so this change should be well-considered.
content.linked(Destination::Location(loc))
})
} }
/// Turn a reference into a citation. /// Turn a reference into a citation.