diff --git a/README.md b/README.md index e0346a2..a85beaf 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,11 @@ For instance: > Make sure to respect JSON syntax, in particular place commas where they are > needed, and only there. Test locally before you push. +> [!TIP] +> You can input multiple files at once by using `papers` (with an `s`) instead +> of `paper`. In that case, papers must be bracketed properly. +> Have a look at `index.md` to see how it's done. + The file that handles papers is `pandoc/paper.lua` and you may modify it to suit your needs. Currently, it expects the fields `title` and `authors` (it will assume them to be empty otherwise), while the other fields (`venue`, `year`, diff --git a/pandoc/paper.lua b/pandoc/paper.lua index efa3bef..8940460 100644 --- a/pandoc/paper.lua +++ b/pandoc/paper.lua @@ -1,10 +1,4 @@ -function paper(content) - - local data = pandoc.json.decode(content, false) - - if not data then - error("Failed to decode JSON:\n" .. content) - end +function paper(data) local title = data.title or "" local url = data.url @@ -83,7 +77,30 @@ function CodeBlock(el) if el.classes[1] == "paper" then local content = string.format("{ %s }", el.text) - return paper(content) + + local data = pandoc.json.decode(content, false) + + if not data then + error("Failed to decode JSON:\n" .. content) + end + + return paper(data) + end + + if el.classes[1] == "papers" then + local content = string.format("[ %s ]", el.text) + + local data = pandoc.json.decode(content, false) + + if not data then + error("Failed to decode JSON:\n" .. content) + end + + local content = data:map(function(d) + return paper(d) + end) + + return pandoc.Blocks(content) end return el diff --git a/src/index.md b/src/index.md index 95e88c6..84cc4d2 100644 --- a/src/index.md +++ b/src/index.md @@ -81,7 +81,24 @@ My workflow is usually to use Ctrl + C / ## Talks -None yet. +``` papers +{ + "title": "Talk 1", + "authors": "Templato Urnehm", + "venue": "My room" +}, +{ + "title": "Secret talk", + "authors": "Templato Urnehm", + "year": "1990" +}, +{ + "title": "Talk 3", + "authors": "Templato Urnehm", + "venue": "Don't remember…", + "year": "???" +} +``` # Education