mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
fix: built-in CSL styles are recognized as path link (#1704)
This commit is contained in:
parent
3520c90244
commit
2b3eb252f0
3 changed files with 49 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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");
|
|
@ -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"
|
||||
}
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue