Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #142 #145

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ archive = ["ciborium"]
csl-json = ["citationberg/json"]

[dependencies]
citationberg = "0.3.0"
citationberg = { git = "https://github.com/typst/citationberg.git" }
indexmap = { version = "2.0.2", features = ["serde"] }
numerals = "0.1.4"
paste = "1.0.14"
Expand All @@ -27,7 +27,7 @@ thiserror = "1.0.48"
unic-langid = { version = "0.9.0", features = ["serde"] }
unicode-segmentation = "1.6.0"
unscanny = "0.1.0"
url = { version = "2.4", features = ["serde"] }
url = { version = "2.4", features = ["serde"] }
biblatex = { version = "0.9", optional = true }
ciborium = { version = "0.2.1", optional = true }
clap = { version = "4", optional = true, features = ["cargo"] }
Expand Down
5 changes: 4 additions & 1 deletion src/csl/rendering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ fn render_typed_num<T: EntryLike>(
}
}

fn render_page_range<T: EntryLike>(range: std::ops::Range<i32>, ctx: &mut Context<T>) {
fn render_page_range<T: EntryLike>(
range: std::ops::RangeInclusive<i32>,
ctx: &mut Context<T>,
) {
ctx.style
.csl
.settings
Expand Down
4 changes: 2 additions & 2 deletions src/csl/taxonomy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl EntryLike for Entry {
MaybeTyped::Typed(r) => r.range(),
MaybeTyped::String(_) => None,
})
.map(|r| MaybeTyped::Typed(Cow::Owned(Numeric::from(r.start)))),
.map(|r| MaybeTyped::Typed(Cow::Owned(Numeric::from(*r.start())))),
NumberVariable::PartNumber => self
.bound_select(
&select!(
Expand Down Expand Up @@ -765,7 +765,7 @@ impl EntryLike for citationberg::json::Item {
{
return n
.range()
.map(|r| MaybeTyped::Typed(Cow::Owned(Numeric::from(r.start))));
.map(|r| MaybeTyped::Typed(Cow::Owned(Numeric::from(*r.start()))));
}
}
match self.0.get(&variable.to_string())? {
Expand Down
12 changes: 6 additions & 6 deletions src/types/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl Numeric {
}

/// Returns a range if the value is a range.
pub fn range(&self) -> Option<std::ops::Range<i32>> {
pub fn range(&self) -> Option<std::ops::RangeInclusive<i32>> {
self.value.range()
}

Expand Down Expand Up @@ -376,10 +376,10 @@ pub enum NumericValue {

impl NumericValue {
/// Returns a range if the value is a range.
pub fn range(&self) -> Option<std::ops::Range<i32>> {
pub fn range(&self) -> Option<std::ops::RangeInclusive<i32>> {
match self {
// A single number is seen as a range of length 1. See #103.
Self::Number(n) => Some(*n..(*n + 1)),
Self::Number(n) => Some(*n..=*n),
Self::Set(vec) => {
if vec.len() == 2 {
let start = vec[0].0;
Expand All @@ -391,10 +391,10 @@ impl NumericValue {
|| (first_delim == Some(NumericDelimiter::Ampersand)
&& start + 1 == end))
{
Some(start..end)
Some(start..=end)
} else if first_delim == Some(NumericDelimiter::Hyphen) {
// Handle shorthand notation like `100-4` for `100-104`
Some(start..end)
Some(start..=end)
} else {
None
}
Expand All @@ -409,7 +409,7 @@ impl NumericValue {
}
}

Some(vec[0].0..vec[vec.len() - 1].0)
Some(vec[0].0..=vec[vec.len() - 1].0)
} else {
None
}
Expand Down
1 change: 1 addition & 0 deletions tests/citeproc-pass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ bugreports_SingletonIfMatchNoneFail
bugreports_TitleCase
bugreports_YearSuffixLingers
bugreports_disambiguate
bugreports_effingBug
bugreports_undefinedCrash
collapse_AuthorCollapse
collapse_AuthorCollapseDifferentAuthorsOneWithEtAl
Expand Down
Loading