Skip to content

Commit

Permalink
Handle multiple papers in yaml too
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoWinterhalter committed Oct 28, 2024
1 parent 29503b0 commit 42e383e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
20 changes: 18 additions & 2 deletions pandoc/paper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
40 changes: 33 additions & 7 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ My workflow is usually to use <kbd>Ctrl</kbd> + <kbd>C</kbd> /

## Conference papers

``` paper
``` json {.paper}
"title": "Towards automatic academic pages 2",
"authors": "Templato Urnehm, U. N. Owen, Wan Morotter",
"venue": "Principles of Awesomeness (PAW)",
"year": "2024",
"url": "https://basicpage.github.io"
```

``` paper
``` json {.paper}
"title": "Towards automatic academic pages",
"authors": "Templato Urnehm, U. N. Owen",
"venue": "Principles of Awesomeness (PAW)",
Expand All @@ -59,10 +59,10 @@ My workflow is usually to use <kbd>Ctrl</kbd> + <kbd>C</kbd> /
## 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
Expand All @@ -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)",
Expand All @@ -81,7 +107,7 @@ files:
## Drafts
```paper
``` json {.paper}
"title": "TBD",
"authors": "TBD",
"files": [
Expand All @@ -96,7 +122,7 @@ files:

## Talks

``` papers
``` json {.papers}
{
"title": "Talk 1",
"authors": "Templato Urnehm",
Expand Down

0 comments on commit 42e383e

Please sign in to comment.