fix: built-in CSL styles are recognized as path link (#1704)

This commit is contained in:
Luyan Zhou 2025-04-25 13:42:02 +08:00 committed by GitHub
parent 3520c90244
commit 2b3eb252f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 1 deletions

View file

@ -120,7 +120,7 @@ impl LinkStrWorker {
}
"bibliography" => {
self.analyze_reader(node, call, "cite", false);
self.analyze_reader(node, call, "style", false);
self.analyze_bibliography_style(node, call);
self.analyze_reader(node, call, "path", true);
}
"cbor" | "csv" | "image" | "read" | "json" | "yaml" | "xml" => {
@ -134,6 +134,24 @@ impl LinkStrWorker {
}
}
fn analyze_bibliography_style(&mut self, node: &LinkedNode, call: ast::FuncCall) -> Option<()> {
for item in call.args().items() {
match item {
ast::Arg::Named(named) if named.name().get().as_str() == "style" => {
if let ast::Expr::Str(style) = named.expr() {
if hayagriva::archive::ArchivedStyle::by_name(&style.get()).is_some() {
return Some(());
}
}
self.analyze_path_expr(node, named.expr());
return Some(());
}
_ => {}
}
}
Some(())
}
fn analyze_reader(
&mut self,
node: &LinkedNode,

View file

@ -0,0 +1,11 @@
/// path: references.bib
@article{Russell:1908,
Author = {Bertand Russell},
Journal = {American Journal of Mathematics},
Pages = {222--262},
Title = {Mathematical logic based on the theory of types},
Volume = 30,
Year = 1908}
-----
#bibliography("references.bib", style: "alphanumeric");
#bibliography("references.bib", style: "style.csl");

View file

@ -0,0 +1,19 @@
---
source: crates/tinymist-query/src/document_link.rs
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/document_link/bibliography_csl.typ
---
[
{
"range": "0:15:0:29",
"target": "references.bib"
},
{
"range": "1:40:1:49",
"target": "style.csl"
},
{
"range": "1:15:1:29",
"target": "references.bib"
}
]