Skip to content

Commit

Permalink
Cleanup and add neurolibre lua filter
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Sep 27, 2023
1 parent f74303d commit bbde5e9
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 1,221 deletions.
9 changes: 5 additions & 4 deletions data/defaults/neurolibre.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ filters:
path: draft.lua
- type: lua
path: self-citation.lua
- type: lua
path: neurolibre-handle-crowd.lua
variables:
# styling options
colorlinks: true
linkcolor: '[rgb]{0.0, 0.5, 1.0}'
urlcolor: '[rgb]{0.0, 0.5, 1.0}'

linkcolor: '[rgb]{1.0, 0.0, 0.0}'
urlcolor: '[rgb]{1.0, 0.0, 0.0}'

template: '${.}/../templates/neurolibre4.latex'
template: '${.}/../templates/neurolibrenew.tex'
13 changes: 0 additions & 13 deletions data/filters/draft.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
function CountAuthors(meta)
if meta['author'] then
-- Check if there is a single author or multiple authors
if type(meta['author']) == 'table' then
num_authors = #meta['author']
else
num_authors = 1
end
end
return num_authors
end

--- Removes and alters metadata for draft output
function Meta (meta)
if meta.draft and meta.draft ~= '' then
Expand All @@ -18,7 +6,6 @@ function Meta (meta)
meta.article.volume = '0'
meta.published = 'unpublished'
meta.published_parts = os.date('*t')
meta.author_number = CountAuthors(meta)
return meta
end
end
73 changes: 73 additions & 0 deletions data/filters/neurolibre-handle-crowd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
local stringify = pandoc.utils.stringify

function CountAuthors(meta)
if meta['author'] then
-- Check if there is a single author or multiple authors
if type(meta['author']) == 'table' then
num_authors = #meta['author']
else
num_authors = 1
end
end
return num_authors
end

function joinTableToString(table)
-- Check if the table is empty
if #table == 0 then
return ""
end

-- Initialize an empty string to hold the joined elements
local joinedString = stringify(table[1])

-- Iterate over the elements of the table and concatenate them with commas and spaces
for i = 2, #table do
joinedString = joinedString .. ", " .. stringify(table[i])
end

return joinedString
end

--- Removes and alters metadata for draft output
function Meta (meta)

local authors = meta['author']
local authorString = ""
for i, author in ipairs(authors) do
if author['equal-contrib'] then
authorString = authorString .. "*"
end
authorString = authorString .. "{\\Authfont " .. author.name .. "}"
-- authorString = authorString .. author.name
for j, affiliation in ipairs(author.affiliation) do
authorString = authorString .. "\\textsuperscript{" .. affiliation .. "}"
if j < #author.affiliation then
authorString = authorString .. "\\textsuperscript{,}"
end
end
if i < #authors then
authorString = authorString .. ", "
end
end

local affiliations = meta.affiliations
local affiliationString = ""

for i, aff in ipairs(affiliations) do
-- affiliationString = affiliationString .. i .. tmp .. "\n"
affiliationString = affiliationString .. " {\\bfseries " .. stringify(i) .. "}\\hspace{3pt} " .. stringify(aff.name)
-- if i < #affiliations then
-- affiliationString = affiliationString .. "\n"
-- end
end

meta.affiliationsList = pandoc.RawInline("latex",affiliationString)
meta.authorsWithAffiliations = pandoc.RawInline("latex",authorString)

-- Check if there are more than 10 authors
meta.moreThanTenAuthors = #authors > 10
meta.noMoreThanTenAuthors = #authors <= 10

return meta
end
14 changes: 7 additions & 7 deletions data/filters/normalize-metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ local List = require 'pandoc.List'
local stringify = pandoc.utils.stringify

local defaults = {
archive_doi = '10.5281',
archive_doi = '10.55458',
editor = {
name = 'Open Journals',
url = 'https://joss.theoj.org',
github_user = '@openjournals',
name = 'NeuroLibre',
url = 'https://neurolibre.org',
github_user = '@roboneuro',
},
citation_author = '¿citation_author?',
issue = '¿ISSUE?',
page = '¿PAGE?',
paper_url = 'NO PAPER URL',
reviewers = {'openjournals'},
software_repository_url = 'https://github.com/openjournals',
software_review_url = 'https://github.com/openjournals',
reviewers = {'roboneuro'},
software_repository_url = 'https://github.com/neurolibre',
software_review_url = 'https://github.com/neurolibre',
volume = '¿VOL?',
}

Expand Down
Loading

0 comments on commit bbde5e9

Please sign in to comment.