Update Hayagriva (#5088)
34
Cargo.lock
generated
@ -149,9 +149,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "biblatex"
|
||||
version = "0.9.3"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27fe7285040d0227cd8b5395e1c4783f44f0b673eca5a657f4432ae401f2b7b8"
|
||||
checksum = "a35a7317fcbdbef94b60d0dd0a658711a936accfce4a631fea4bf8e527eff3c2"
|
||||
dependencies = [
|
||||
"numerals",
|
||||
"paste",
|
||||
@ -317,11 +317,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "citationberg"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d259fe9fd78ffa05a119581d20fddb50bfba428311057b12741ffb9015123d0b"
|
||||
checksum = "92fea693c83bd967604be367dc1e1b4895625eabafec2eec66c51092e18e700e"
|
||||
dependencies = [
|
||||
"quick-xml 0.31.0",
|
||||
"quick-xml 0.36.2",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@ -866,9 +866,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hayagriva"
|
||||
version = "0.5.3"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d0d20c98b77b86ce737876b2a1653e2e6abbeee84afbb39d72111091191c97a"
|
||||
checksum = "c9e1ae4b9c0537119755702dfb6f838bf6ff5976ddc84501630783f0d7b5ce5e"
|
||||
dependencies = [
|
||||
"biblatex",
|
||||
"ciborium",
|
||||
@ -1861,16 +1861,6 @@ version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.32.0"
|
||||
@ -1880,6 +1870,16 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.36.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
|
@ -51,7 +51,7 @@ env_proxy = "0.4"
|
||||
flate2 = "1"
|
||||
fontdb = { version = "0.21", default-features = false }
|
||||
fs_extra = "1.3"
|
||||
hayagriva = "0.5.3"
|
||||
hayagriva = "0.6.0"
|
||||
heck = "0.5"
|
||||
hypher = "0.1.4"
|
||||
icu_properties = { version = "1.4", features = ["serde"] }
|
||||
|
@ -779,8 +779,11 @@ impl<'a> Generator<'a> {
|
||||
let content = if info.subinfos.iter().all(|sub| sub.hidden) {
|
||||
Content::empty()
|
||||
} else {
|
||||
let mut content =
|
||||
renderer.display_elem_children(&citation.citation, &mut None)?;
|
||||
let mut content = renderer.display_elem_children(
|
||||
&citation.citation,
|
||||
&mut None,
|
||||
true,
|
||||
)?;
|
||||
|
||||
if info.footnote {
|
||||
content = FootnoteElem::with_content(content).pack();
|
||||
@ -835,7 +838,8 @@ impl<'a> Generator<'a> {
|
||||
.first_field
|
||||
.as_ref()
|
||||
.map(|elem| {
|
||||
let mut content = renderer.display_elem_child(elem, &mut None)?;
|
||||
let mut content =
|
||||
renderer.display_elem_child(elem, &mut None, false)?;
|
||||
if let Some(location) = first_occurrences.get(item.key.as_str()) {
|
||||
let dest = Destination::Location(*location);
|
||||
content = content.linked(dest);
|
||||
@ -846,7 +850,7 @@ impl<'a> Generator<'a> {
|
||||
|
||||
// Render the main reference content.
|
||||
let mut reference =
|
||||
renderer.display_elem_children(&item.content, &mut prefix)?;
|
||||
renderer.display_elem_children(&item.content, &mut prefix, false)?;
|
||||
|
||||
// Attach a backlink to either the prefix or the reference so that
|
||||
// we can link to the bibliography entry.
|
||||
@ -876,16 +880,24 @@ impl ElemRenderer<'_> {
|
||||
///
|
||||
/// The `prefix` can be a separate content storage where `left-margin`
|
||||
/// elements will be accumulated into.
|
||||
///
|
||||
/// `is_citation` dictates whether whitespace at the start of the citation
|
||||
/// will be eliminated. Some CSL styles yield whitespace at the start of
|
||||
/// their citations, which should instead be handled by Typst.
|
||||
fn display_elem_children(
|
||||
&self,
|
||||
elems: &hayagriva::ElemChildren,
|
||||
prefix: &mut Option<Content>,
|
||||
is_citation: bool,
|
||||
) -> StrResult<Content> {
|
||||
Ok(Content::sequence(
|
||||
elems
|
||||
.0
|
||||
.iter()
|
||||
.map(|elem| self.display_elem_child(elem, prefix))
|
||||
.enumerate()
|
||||
.map(|(i, elem)| {
|
||||
self.display_elem_child(elem, prefix, is_citation && i == 0)
|
||||
})
|
||||
.collect::<StrResult<Vec<_>>>()?,
|
||||
))
|
||||
}
|
||||
@ -895,9 +907,12 @@ impl ElemRenderer<'_> {
|
||||
&self,
|
||||
elem: &hayagriva::ElemChild,
|
||||
prefix: &mut Option<Content>,
|
||||
trim_start: bool,
|
||||
) -> StrResult<Content> {
|
||||
Ok(match elem {
|
||||
hayagriva::ElemChild::Text(formatted) => self.display_formatted(formatted),
|
||||
hayagriva::ElemChild::Text(formatted) => {
|
||||
self.display_formatted(formatted, trim_start)
|
||||
}
|
||||
hayagriva::ElemChild::Elem(elem) => self.display_elem(elem, prefix)?,
|
||||
hayagriva::ElemChild::Markup(markup) => self.display_math(markup),
|
||||
hayagriva::ElemChild::Link { text, url } => self.display_link(text, url)?,
|
||||
@ -921,6 +936,7 @@ impl ElemRenderer<'_> {
|
||||
let mut content = self.display_elem_children(
|
||||
&elem.children,
|
||||
if block_level { &mut suf_prefix } else { prefix },
|
||||
false,
|
||||
)?;
|
||||
|
||||
if let Some(prefix) = suf_prefix {
|
||||
@ -976,7 +992,7 @@ impl ElemRenderer<'_> {
|
||||
/// Display a link.
|
||||
fn display_link(&self, text: &hayagriva::Formatted, url: &str) -> StrResult<Content> {
|
||||
let dest = Destination::Url(Url::new(url)?);
|
||||
Ok(LinkElem::new(dest.into(), self.display_formatted(text))
|
||||
Ok(LinkElem::new(dest.into(), self.display_formatted(text, false))
|
||||
.pack()
|
||||
.spanned(self.span))
|
||||
}
|
||||
@ -988,8 +1004,18 @@ impl ElemRenderer<'_> {
|
||||
}
|
||||
|
||||
/// Display formatted hayagriva text as content.
|
||||
fn display_formatted(&self, formatted: &hayagriva::Formatted) -> Content {
|
||||
let content = TextElem::packed(formatted.text.as_str()).spanned(self.span);
|
||||
fn display_formatted(
|
||||
&self,
|
||||
formatted: &hayagriva::Formatted,
|
||||
trim_start: bool,
|
||||
) -> Content {
|
||||
let formatted_text = if trim_start {
|
||||
formatted.text.trim_start()
|
||||
} else {
|
||||
formatted.text.as_str()
|
||||
};
|
||||
|
||||
let content = TextElem::packed(formatted_text).spanned(self.span);
|
||||
apply_formatting(content, &formatted.formatting)
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 841 B |
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 403 B |
@ -30,7 +30,7 @@ A @netwok @arrgh @quark B. \
|
||||
A @netwok @arrgh @quark, B.
|
||||
|
||||
#set text(0pt)
|
||||
#bibliography("/assets/bib/works.bib")
|
||||
#bibliography("/assets/bib/works.bib", style: "american-physics-society")
|
||||
|
||||
--- cite-grouping-and-ordering ---
|
||||
@mcintosh_anxiety
|
||||
@ -47,7 +47,7 @@ A @netwok @arrgh @quark, B.
|
||||
@restful
|
||||
|
||||
#show bibliography: none
|
||||
#bibliography("/assets/bib/works.bib")
|
||||
#bibliography("/assets/bib/works.bib", style: "american-physics-society")
|
||||
|
||||
--- issue-785-cite-locate ---
|
||||
// Test citation in other introspection.
|
||||
|
@ -160,7 +160,7 @@ hi
|
||||
@netwok hey " dis
|
||||
|
||||
#show bibliography: none
|
||||
#bibliography("/assets/bib/works.bib")
|
||||
#bibliography("/assets/bib/works.bib", style: "american-physics-society")
|
||||
|
||||
--- show-text-in-citation ---
|
||||
#show "A": "B"
|
||||
|