Skip to content

Commit

Permalink
Improve paper input
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoWinterhalter committed Oct 25, 2024
1 parent 3ddfbfe commit 7db3cba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 3 additions & 2 deletions pandoc/paper.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function CodeBlock(el)

if el.classes[1] == "paper" then
local data = pandoc.json.decode(el.text, false)
local content = string.format("{ %s }", el.text)
local data = pandoc.json.decode(content, false)

if not data then
error("Failed to decode JSON:\n" .. el.text)
Expand All @@ -10,7 +11,7 @@ function CodeBlock(el)
local div_content = {
pandoc.Header(3, {pandoc.Link(data.title, data.url)}),
pandoc.Para({pandoc.Str(data.authors)}, {class = "authors"}),
pandoc.Para({pandoc.Str(data.venue .. "(" .. data.year .. ")")}, {class = "venue"})
pandoc.Para({pandoc.Str(data.venue .. "(" .. data.year .. ")")}, {class = "venue"}) -- It seems the class cannot be set
}

local div = pandoc.Div(div_content, {class = "paper"})
Expand Down
12 changes: 5 additions & 7 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ My workflow is usually to use <kbd>Ctrl</kbd> + <kbd>C</kbd> /
## Conference papers

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

### Towards automatic academic pages
Expand Down

0 comments on commit 7db3cba

Please sign in to comment.