Skip to content

Commit 8b40511

Browse files
committed
[chore] refactor
1 parent 80c5374 commit 8b40511

File tree

1 file changed

+12
-16
lines changed
  • crates/quarto-markdown-pandoc/src/writers

1 file changed

+12
-16
lines changed

crates/quarto-markdown-pandoc/src/writers/qmd.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,12 @@ fn write_cite(cite: &crate::pandoc::Cite, buf: &mut dyn std::io::Write) -> std::
865865

866866
// Check if we have any NormalCitation or SuppressAuthor citations
867867
// These need to be wrapped in brackets together
868-
let has_bracketed = cite
869-
.citations
870-
.iter()
871-
.any(|c| matches!(c.mode, CitationMode::NormalCitation | CitationMode::SuppressAuthor));
868+
let has_bracketed = cite.citations.iter().any(|c| {
869+
matches!(
870+
c.mode,
871+
CitationMode::NormalCitation | CitationMode::SuppressAuthor
872+
)
873+
});
872874

873875
if has_bracketed {
874876
// All citations go in one set of brackets
@@ -894,19 +896,13 @@ fn write_cite(cite: &crate::pandoc::Cite, buf: &mut dyn std::io::Write) -> std::
894896
write!(buf, " ")?;
895897
}
896898
}
897-
898899
// Write the citation itself
899-
match citation.mode {
900-
CitationMode::AuthorInText => {
901-
write!(buf, "@{}", citation.id)?;
902-
}
903-
CitationMode::NormalCitation => {
904-
write!(buf, "@{}", citation.id)?;
905-
}
906-
CitationMode::SuppressAuthor => {
907-
write!(buf, "-@{}", citation.id)?;
908-
}
909-
}
900+
let prefix = if matches!(citation.mode, CitationMode::SuppressAuthor) {
901+
"-@"
902+
} else {
903+
"@"
904+
};
905+
write!(buf, "{}{}", prefix, citation.id)?;
910906

911907
// Write suffix
912908
for inline in &citation.suffix {

0 commit comments

Comments
 (0)