From 4889ce541e2830af71cdcbfdb15a1027d328526a Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Thu, 2 May 2024 11:07:49 +0200 Subject: [PATCH] fix: render full bibliography --- Cargo.lock | 10 +++++ Cargo.toml | 1 + .../index.md} | 10 ++--- .../{typeclasses.md => typeclasses/index.md} | 38 ------------------- content/posts/typeclasses/ref.bib | 32 ++++++++++++++++ src/gen/load.rs | 4 +- src/main.rs | 9 ++--- src/text/md.rs | 3 ++ src/ts/configs.rs | 16 ++++++-- 9 files changed, 70 insertions(+), 53 deletions(-) rename content/posts/{hisasiburi-no-toukou.md => hisasiburi-no-toukou/index.md} (77%) rename content/posts/{typeclasses.md => typeclasses/index.md} (86%) create mode 100644 content/posts/typeclasses/ref.bib diff --git a/Cargo.lock b/Cargo.lock index d6ffb61..4b65688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -898,6 +898,7 @@ dependencies = [ "tree-sitter-python", "tree-sitter-regex", "tree-sitter-rust", + "tree-sitter-scheme", "tree-sitter-toml", "tree-sitter-typescript", ] @@ -1117,6 +1118,15 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "tree-sitter-scheme" +version = "0.6.0" +source = "git+https://github.com/6cdh/tree-sitter-scheme?rev=85b6188fb77c03dfb01d13e58e2844450506860c#85b6188fb77c03dfb01d13e58e2844450506860c" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-toml" version = "0.20.0" diff --git a/Cargo.toml b/Cargo.toml index 50ca918..df1fb17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,5 +34,6 @@ tree-sitter-md = "0.1" tree-sitter-python = "0.20" tree-sitter-regex = "0.20" tree-sitter-rust = "0.20" +tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "85b6188fb77c03dfb01d13e58e2844450506860c" } tree-sitter-toml = "0.20" tree-sitter-typescript = "0.20" diff --git a/content/posts/hisasiburi-no-toukou.md b/content/posts/hisasiburi-no-toukou/index.md similarity index 77% rename from content/posts/hisasiburi-no-toukou.md rename to content/posts/hisasiburi-no-toukou/index.md index afad2a3..9f97f34 100644 --- a/content/posts/hisasiburi-no-toukou.md +++ b/content/posts/hisasiburi-no-toukou/index.md @@ -11,22 +11,22 @@ date: 2023-12-17T12:47:29.753Z あくる日、親に引かれている橇で乗っている嬉しそうな子供を見た。 あらゆる公園が白くなって、白すぎて見えた。 -![白すぎる公園](@assets/posts/hisasiburi-no-toukou/IMG_20231204_105929.jpg) +![白すぎる公園](IMG_20231204_105929.jpg) その時から雪が全部解けちゃった。 最近、ヴロツワフではクリスマスマーケットが始まっているので、見に行った。 そこでたくさんの人がいて、いろんな出店もあり、色々なものを買って楽しむことができた。 -![眩しいクリスマスライト](@assets/posts/hisasiburi-no-toukou/IMG_20231209_182036.jpg) +![眩しいクリスマスライト](IMG_20231209_182036.jpg) もっと進んでいくと、大きなレストランみたいなビルに出くわしたんだ。 あのビルでは、「グジャニエッツ」という飲み物を買って楽しむことができた。 -![グジャニエッツのビル](@assets/posts/hisasiburi-no-toukou/IMG_20231209_183410.jpg) +![グジャニエッツのビル](IMG_20231209_183410.jpg) グジャニエッツとは、ポーランドの伝統的な温かいスパイス入りの飲み物。 通常は赤ワインやオレンジ、シナモン、クローブが使われる。 -クリスマスマーケットってとても素晴らしいイベントの一つだけど、値段が高く過ぎるからあんまり買い物しなかったwww - +クリスマスマーケットってとても素晴らしいイベントの一つだけど、 +値段が高く過ぎるからあんまり買い物しなかったwww diff --git a/content/posts/typeclasses.md b/content/posts/typeclasses/index.md similarity index 86% rename from content/posts/typeclasses.md rename to content/posts/typeclasses/index.md index 712391c..19dea88 100644 --- a/content/posts/typeclasses.md +++ b/content/posts/typeclasses/index.md @@ -241,41 +241,3 @@ scala ### Rust rust - - -## Bibliography - -:::bibtex -@inproceedings{10.1145/1238844.1238856, - author = {Hudak, Paul and Hughes, John and Peyton Jones, Simon and Wadler, Philip}, - title = {A History of Haskell: Being Lazy with Class}, - year = {2007}, - isbn = {9781595937667}, - publisher = {Association for Computing Machinery}, - address = {New York, NY, USA}, - url = {https://doi.org/10.1145/1238844.1238856}, - doi = {10.1145/1238844.1238856}, - abstract = {This paper describes the history of Haskell, including its genesis and principles, technical contributions, implementations and tools, and applications and impact.}, - booktitle = {Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages}, - pages = {12–1–12–55}, - location = {San Diego, California}, - series = {HOPL III} -} - -@online{youtube, - title = {Escape from the ivory tower: the Haskell journey}, - date = {2017}, - organization = {Youtube}, - author = {Simon {Peyton Jones}}, - url = {https://youtu.be/re96UgMk6GQ}, -} - -@book{skinner2023effective, - title = {Effective Haskell: Solving Real-World Problems with Strongly Typed Functional Programming}, - author = {Skinner, R.}, - isbn = {9781680509342}, - series = {Pragmatic Bookshelf}, - year = {2023}, - publisher = {O'Reilly Media} -} -::: diff --git a/content/posts/typeclasses/ref.bib b/content/posts/typeclasses/ref.bib new file mode 100644 index 0000000..37b8175 --- /dev/null +++ b/content/posts/typeclasses/ref.bib @@ -0,0 +1,32 @@ +@inproceedings{10.1145/1238844.1238856, + author = {Hudak, Paul and Hughes, John and Peyton Jones, Simon and Wadler, Philip}, + title = {A History of Haskell: Being Lazy with Class}, + year = {2007}, + isbn = {9781595937667}, + publisher = {Association for Computing Machinery}, + address = {New York, NY, USA}, + url = {https://doi.org/10.1145/1238844.1238856}, + doi = {10.1145/1238844.1238856}, + abstract = {This paper describes the history of Haskell, including its genesis and principles, technical contributions, implementations and tools, and applications and impact.}, + booktitle = {Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages}, + pages = {12–1–12–55}, + location = {San Diego, California}, + series = {HOPL III} +} + +@online{youtube, + title = {Escape from the ivory tower: the Haskell journey}, + date = {2017}, + organization = {Youtube}, + author = {Simon {Peyton Jones}}, + url = {https://youtu.be/re96UgMk6GQ}, +} + +@book{skinner2023effective, + title = {Effective Haskell: Solving Real-World Problems with Strongly Typed Functional Programming}, + author = {Skinner, R.}, + isbn = {9781680509342}, + series = {Pragmatic Bookshelf}, + year = {2023}, + publisher = {O'Reilly Media} +} diff --git a/src/gen/load.rs b/src/gen/load.rs index 945f5c8..b563f4e 100644 --- a/src/gen/load.rs +++ b/src/gen/load.rs @@ -1,4 +1,6 @@ -use std::{collections::HashSet, fs::{self, File}, io::Write} ; +use std::collections::HashSet; +use std::fs::{self, File}; +use std::io::Write; use camino::{Utf8Path, Utf8PathBuf}; use glob::glob; diff --git a/src/main.rs b/src/main.rs index 58f8adc..a7511c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -183,9 +183,7 @@ fn to_index(item: PipelineItem) -> PipelineItem _ => return item, }; - // FIXME: clean this up - let dir = meta.path.parent().unwrap(); - let dir = dir.strip_prefix("content").unwrap(); + let dir = meta.path.parent().unwrap().strip_prefix("content").unwrap(); let dir = match meta.path.file_stem().unwrap() { "index" => dir.to_owned(), name => dir.join(name), @@ -223,8 +221,7 @@ fn to_bundle(item: PipelineItem) -> PipelineItem { _ => return item, }; - let dirs = meta.path.strip_prefix("content").unwrap().parent().unwrap(); - let path = dirs.join(meta.path.file_name().unwrap()).to_owned(); + let path = meta.path.strip_prefix("content").unwrap().to_owned(); match meta.path.extension() { // any image @@ -308,7 +305,7 @@ fn main() { kind: Asset { kind: gen::AssetKind::Html(Box::new(|_| { let data = std::fs::read_to_string("content/index.md").unwrap(); - let (_, html, bib) = text::md::parse(&data, None); + let (_, html, _) = text::md::parse(&data, None); html::home(Raw(html)).render().to_owned().into() })).into(), meta: gen::FileItem { diff --git a/src/text/md.rs b/src/text/md.rs index 5129339..e73ce70 100644 --- a/src/text/md.rs +++ b/src/text/md.rs @@ -88,6 +88,9 @@ fn make_bib<'a, 'b>(stream: Vec>, lib: &'b Library) -> (Vec> } } + // add fake citation to make all entries show up + driver.citation(CitationRequest::from_items(lib.iter().map(CitationItem::with_entry).collect(), &STYLE, &LOCALE)); + let res = driver.finish(BibliographyRequest { style: &STYLE, locale: None, locale_files: &LOCALE }); let mut n = 0; diff --git a/src/ts/configs.rs b/src/ts/configs.rs index 47e9d96..416f8fd 100644 --- a/src/ts/configs.rs +++ b/src/ts/configs.rs @@ -24,14 +24,15 @@ pub static EXTENSIONS: Lazy> = Lazy::new(|| ("md", "markdown"), ("mdx", "markdown"), ("py", "python"), - ("query", "query"), - // ("scm", "scheme"), - ("scss", "scss"), + ("query", "scheme"), + ("scm", "scheme"), + ("scss", "css"), ("ts", "javascript"), ("typescript", "javascript") ]) }); +#[inline(always)] fn config_for( lang: Language, highlights: &str, @@ -142,6 +143,15 @@ pub static CONFIGS: Lazy> = Lazy:: "", ) ), + ( + "scheme", + config_for( + tree_sitter_scheme::language(), + tree_sitter_scheme::HIGHLIGHTS_QUERY, + "", + "", + ) + ), ( "toml", config_for(