Skip to content

Commit

Permalink
Provide papers to handle multiple papers
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoWinterhalter committed Oct 25, 2024
1 parent 46cc4a8 commit b0afb0d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
33 changes: 25 additions & 8 deletions pandoc/paper.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,24 @@ My workflow is usually to use <kbd>Ctrl</kbd> + <kbd>C</kbd> /

## 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

Expand Down

0 comments on commit b0afb0d

Please sign in to comment.