Skip to content
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
Binary file modified docs/manual.pdf
Binary file not shown.
10 changes: 5 additions & 5 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,18 @@ fn read_impl(config: Config) -> Result<Bibliography, String> {
.into_iter()
.map(|reference| {
let key = reference.key;
let prefix = reference.first_field;
let reference = reference.content;
let first_field = reference.first_field;
let content = reference.content;

let details = entries
.get(&key)
.cloned()
.expect("key has been found before but not anymore");

Entry {
Reference {
key,
prefix,
reference,
first_field,
content,
details,
}
})
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ pub struct Citation {
#[derive(Serialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")]
pub struct Bibliography {
pub references: Vec<Entry>,
pub references: Vec<Reference>,
#[serde(serialize_with = "wrapper::ser_wrapped_seq")]
pub citations: Vec<ElemChildren>,
pub hanging_indent: bool,
}

#[derive(Serialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")]
pub struct Entry {
pub struct Reference {
pub key: String,
#[serde(serialize_with = "wrapper::ser_wrapped_option")]
pub prefix: Option<ElemChild>,
pub first_field: Option<ElemChild>,
#[serde(serialize_with = "wrapper::ser_wrapped")]
pub reference: ElemChildren,
pub content: ElemChildren,
pub details: hayagriva::Entry,
}

Expand Down
Binary file modified src/alexandria.wasm
Binary file not shown.
27 changes: 13 additions & 14 deletions src/lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,14 @@
/// - `hanging-indent`: a boolean indicating whether the citation style uses a hanging indent for
/// its entries.
///
/// The `references` in turn each contain
/// - `key`: the reference key without prefix.
/// - `reference`: a representation of the Typst content that should be rendered; this is processed
/// by @@render-bibliography() to produce the actual context.
/// - optionally `prefix`: this is _not_ the Alexandria prefix but another Typst content
/// representation for styles that require it. For example, in IEEE style this would represent
/// "[1]" and so on.
/// - `details`: a dictionary containing several fields of structured data about the reference.
/// Among these are `type`, `title`, `author`, `date`, etc. A full list can be found in the
/// The elements of the `references` array have the following fields:
/// - `key`: the original bibliography key (without Alexandria's prefix).
/// - `content`: a Typst representation of the bibliographical entry; used by
/// @@render-bibliography() for rendering bibliographical items.
/// - optional `first-field`: Typst content for certain bibliography styles. For example,
/// in IEEE style it represents "[1]", "[2]", etc.
/// - `details`: a dictionary containing information about this reference, including
/// `type`, `title`, `author`, and `date` fields. The full list can be found in the
/// #link("https://github.com/typst/hayagriva/blob/main/docs/file-format.md")[Hayagriva docs].
///
/// The `citations` are representations of the Typst content that should be rendered at their
Expand Down Expand Up @@ -288,7 +287,7 @@

set par(hanging-indent: 1.5em) if bib.hanging-indent

if bib.references.any(e => e.prefix != none) {
if bib.references.any(e => e.first-field != none) {
grid(
columns: 2,
// rows: (),
Expand All @@ -303,11 +302,11 @@
(
{
[#metadata(none)#label(bib.prefix + e.key)]
if e.prefix != none {
hayagriva.render(e.prefix)
if e.first-field != none {
hayagriva.render(e.first-field)
}
},
hayagriva.render(e.reference),
hayagriva.render(e.content),
)
},
)
Expand All @@ -316,7 +315,7 @@
for (i, e) in bib.references.enumerate() {
if i != 0 { gutter }
[#metadata(none)#label(bib.prefix + e.key)]
hayagriva.render(e.reference)
hayagriva.render(e.content)
}
}
}
Expand Down