mirror of
https://github.com/typst/typst
synced 2025-07-27 14:27:56 +08:00
Compare commits
3 Commits
c5b723f353
...
1399dc2c68
Author | SHA1 | Date | |
---|---|---|---|
|
1399dc2c68 | ||
|
7a3e2dbcbe | ||
|
e9f1b5825a |
@ -160,6 +160,7 @@ strip = true
|
||||
[workspace.lints.clippy]
|
||||
blocks_in_conditions = "allow"
|
||||
comparison_chain = "allow"
|
||||
iter_over_hash_type = "warn"
|
||||
manual_range_contains = "allow"
|
||||
mutable_key_type = "allow"
|
||||
uninlined_format_args = "warn"
|
||||
|
@ -139,6 +139,7 @@ impl Watcher {
|
||||
fn update(&mut self, iter: impl IntoIterator<Item = PathBuf>) -> StrResult<()> {
|
||||
// Mark all files as not "seen" so that we may unwatch them if they
|
||||
// aren't in the dependency list.
|
||||
#[allow(clippy::iter_over_hash_type, reason = "order does not matter")]
|
||||
for seen in self.watched.values_mut() {
|
||||
*seen = false;
|
||||
}
|
||||
|
@ -173,6 +173,7 @@ impl SystemWorld {
|
||||
|
||||
/// Reset the compilation state in preparation of a new compilation.
|
||||
pub fn reset(&mut self) {
|
||||
#[allow(clippy::iter_over_hash_type, reason = "order does not matter")]
|
||||
for slot in self.slots.get_mut().values_mut() {
|
||||
slot.reset();
|
||||
}
|
||||
|
@ -216,13 +216,19 @@ const TERMS_RULE: ShowFn<TermsElem> = |elem, _, styles| {
|
||||
const LINK_MARKER_RULE: ShowFn<LinkMarker> = |elem, _, _| Ok(elem.body.clone());
|
||||
|
||||
const LINK_RULE: ShowFn<LinkElem> = |elem, engine, styles| {
|
||||
let span = elem.span();
|
||||
let body = elem.body.clone();
|
||||
let dest = elem.dest.resolve(engine.introspector).at(elem.span())?;
|
||||
let alt = match elem.alt.get_cloned(styles) {
|
||||
Some(alt) => Some(alt),
|
||||
None => dest.alt_text(engine, styles)?,
|
||||
};
|
||||
Ok(body.linked(dest, alt))
|
||||
// Manually construct link marker that spans the whole link elem, not just
|
||||
// the body.
|
||||
Ok(LinkMarker::new(body, dest.clone(), alt)
|
||||
.pack()
|
||||
.spanned(span)
|
||||
.set(LinkElem::current, Some(dest)))
|
||||
};
|
||||
|
||||
const HEADING_RULE: ShowFn<HeadingElem> = |elem, engine, styles| {
|
||||
|
@ -479,7 +479,7 @@ impl Content {
|
||||
/// Link the content somewhere.
|
||||
pub fn linked(self, dest: Destination, alt: Option<EcoString>) -> Self {
|
||||
let span = self.span();
|
||||
LinkMarker::new(self, dest.clone(), alt, span)
|
||||
LinkMarker::new(self, dest.clone(), alt)
|
||||
.pack()
|
||||
.spanned(span)
|
||||
.set(LinkElem::current, Some(dest))
|
||||
@ -797,9 +797,6 @@ pub struct LinkMarker {
|
||||
#[internal]
|
||||
#[required]
|
||||
pub alt: Option<EcoString>,
|
||||
#[internal]
|
||||
#[required]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Construct for LinkMarker {
|
||||
|
@ -617,7 +617,7 @@ fn convert_error(
|
||||
let span = to_span(*loc);
|
||||
error!(
|
||||
span, "{prefix} missing annotation alt text";
|
||||
hint: "please report this as a bug"
|
||||
hint: "manually add alt text to your links"
|
||||
)
|
||||
}
|
||||
ValidationError::MissingAltText(loc) => {
|
||||
|
@ -71,7 +71,7 @@ pub(crate) fn handle_link(
|
||||
let (alt, span) = if let Some((link, nodes)) = tagging_ctx {
|
||||
nodes.push(TagNode::Placeholder(placeholder));
|
||||
let alt = link.alt.as_ref().map(EcoString::to_string);
|
||||
(alt, link.span)
|
||||
(alt, link.span())
|
||||
} else {
|
||||
(None, Span::detached())
|
||||
};
|
||||
|
@ -535,10 +535,10 @@ impl TagStack {
|
||||
|
||||
pub(crate) fn find_parent_link(
|
||||
&mut self,
|
||||
) -> Option<(LinkId, &LinkMarker, &mut Vec<TagNode>)> {
|
||||
) -> Option<(LinkId, &Packed<LinkMarker>, &mut Vec<TagNode>)> {
|
||||
self.0.iter_mut().rev().find_map(|e| {
|
||||
let (link_id, link) = e.kind.as_link()?;
|
||||
Some((link_id, link.as_ref(), &mut e.nodes))
|
||||
Some((link_id, link, &mut e.nodes))
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user