From 42e383eb1ff3a634a607b7e508864aeea4eca47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Winterhalter?= Date: Mon, 28 Oct 2024 21:56:12 +0100 Subject: [PATCH] Handle multiple papers in yaml too --- pandoc/paper.lua | 20 ++++++++++++++++++-- src/index.md | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/pandoc/paper.lua b/pandoc/paper.lua index a1d6f29..3ad041e 100644 --- a/pandoc/paper.lua +++ b/pandoc/paper.lua @@ -128,7 +128,7 @@ function CodeBlock(el) return paper(yamldata(doc.meta)) end - if el.classes[1] == "paper" then + if el.classes[1] == "paper" and el.classes[2] == "json" then local content = string.format("{ %s }", el.text) local data = pandoc.json.decode(content, false) @@ -140,7 +140,23 @@ function CodeBlock(el) return paper(jsondata(data)) end - if el.classes[1] == "papers" then + if el.classes[1] == "papers" and el.classes[2] == "yaml" then + local content = string.format("---\n%s\n---", el.text) + + local doc = pandoc.read(content) + + if not doc then + error("Failed to decode yaml:\n" .. content) + end + + local content = doc.meta.papers:map(function(d) + return paper(yamldata(d)) + end) + + return pandoc.Blocks(content) + end + + if el.classes[1] == "papers" and el.classes[2] == "json" then local content = string.format("[ %s ]", el.text) local data = pandoc.json.decode(content, false) diff --git a/src/index.md b/src/index.md index d75f4da..c8180a5 100644 --- a/src/index.md +++ b/src/index.md @@ -35,7 +35,7 @@ My workflow is usually to use Ctrl + C / ## Conference papers -``` paper +``` json {.paper} "title": "Towards automatic academic pages 2", "authors": "Templato Urnehm, U. N. Owen, Wan Morotter", "venue": "Principles of Awesomeness (PAW)", @@ -43,7 +43,7 @@ My workflow is usually to use Ctrl + C / "url": "https://basicpage.github.io" ``` -``` paper +``` json {.paper} "title": "Towards automatic academic pages", "authors": "Templato Urnehm, U. N. Owen", "venue": "Principles of Awesomeness (PAW)", @@ -59,10 +59,10 @@ My workflow is usually to use Ctrl + C / ## Journal papers ``` yaml {.paper} -title: Yet another yaml parser +title: Yet another yaml parser 3 authors: Templato Urnehm venue: Proceedings of Nihilism -year: 2025 +year: 2029 files: - text: Paper type: pdf @@ -72,7 +72,33 @@ files: src: foo.bib ``` -``` paper +``` yaml {.papers} +papers: + - title: Yet another yaml parser 2 + authors: Templato Urnehm + venue: Proceedings of Nihilism + year: 2027 + files: + - text: Paper + type: pdf + scr: foo.pdf + - text: Bibtex + type: bib + src: foo.bib + - title: Yet another yaml parser + authors: Templato Urnehm + venue: Proceedings of Nihilism + year: 2025 + files: + - text: Paper + type: pdf + scr: foo.pdf + - text: Bibtex + type: bib + src: foo.bib +``` + +``` json {.paper} "title": "How to tame your wagon", "authors": "Templato Urnehm", "venue": "Journal of Automatic Rejection (JAR)", @@ -81,7 +107,7 @@ files: ## Drafts -```paper +``` json {.paper} "title": "TBD", "authors": "TBD", "files": [ @@ -96,7 +122,7 @@ files: ## Talks -``` papers +``` json {.papers} { "title": "Talk 1", "authors": "Templato Urnehm",