Skip to content

Commit

Permalink
fix case where affiliations have no index numbers but they get inserted
Browse files Browse the repository at this point in the history
by the filter, we make sure there is no index now
  • Loading branch information
iandol committed Mar 28, 2021
1 parent f451733 commit 0a1d560
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions filters/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# My Filters #
Most of the filters here are really aimed to handle academic paper workflows. For scientific papers we normally have multiple authors, each with an affiliation to an Istitution and optionally an address for correspondence. Pandoc offers templates that allow us to convert metadata into this structured content, and for HTML and LaTeX I use this mechanism. Word and LibreOffice do not allow such flexibility, and so we must use filters to transform the metadata to add the correct information to the document body itself.

My YAML metadata normally looks something like this (<$> are Scrivener placeholders):
My YAML metadata normally looks something like this (<$> are Scrivener placeholders):

```yaml
title: "<$projecttitle>"
Expand Down Expand Up @@ -52,7 +52,7 @@ Affiliations: ^1^ — University of X & ^2^ — Institute of Y

As I also prepend comments and keywords, I've created a filter that prepends a "list of metadata entries", which is a bit faster than running sperate prependXXX filters for each item to prepend: [prependAll](https://github.com/iandol/dotpandoc/blob/master/filters/prependAll). [prependAuthor](https://github.com/iandol/dotpandoc/blob/master/filters/prependAuthor) is used to get author information into plain-text outputs.

Other filters here are from other sources or for testing purposes. I do use addToday and removeHR regularly.
Other filters here are from other sources or for testing purposes. I do use `pagebreak.lua`, `addToday` and `removeHR` regularly.

As an alternative to my metadata filter, you could also use Pandoc-Scholar's Lua filter: https://github.com/pandoc-scholar/pandoc-scholar/tree/master/lua-filters/scholarly-metadata

Expand Down
4 changes: 2 additions & 2 deletions filters/assimilateMetadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# You should be able to use several different input styles, including strings
# like 'Joanna Doe^1,2^' and lists without specifying the name: subfield
#
# VERSION: 1.0.0
# VERSION: 1.0.1

require 'paru/filter'

Expand All @@ -33,7 +33,7 @@ def authorSuperscript(input)
def instituteSuperscript(inst, index = 1)
cp = inst.match(/^\s?\^([\w\d]+)\^\s?/)
if cp.nil?
Hash['index' => index.to_s, 'name' => inst]
Hash['name' => inst]
else
Hash['index' => cp[1], 'name' => cp.post_match.strip]
end
Expand Down
6 changes: 2 additions & 4 deletions templates/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ <h1 class="title">$title$</h1>
$if(author)$
<p class="author-list">
$for(author)$
$if(author.last)$and $endif$<span property="author" typeof="Person">
$author.name$</span><sup>$for(author.affiliation)$$author.affiliation$$sep$,$endfor$
$if(author.correspondence)$<a href="mailto:$author.correspondence$"></a>$endif$
$if(author.equal_contributor)$†$endif$</sup>$sep$,
$if(author.last)$ and $endif$<span property="author" typeof="Person">$author.name$</span><sup>$if(author.affiliation)$$for(author.affiliation)$$author.affiliation$$sep$,$endfor$$endif$$if(author.correspondence)$<a href="mailto:$author.correspondence$"></a>$endif$$if(author.equal_contributor)$†$endif$</sup>$sep$,
$endfor$
</p>
$endif$

$if(equal_contributors)$
<p class="author_contributions"><sup></sup> Authors contributed equally to this work.</p>
$endif$
Expand Down
6 changes: 3 additions & 3 deletions templates/custom.latex
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ $endif$
$endif$
$if(author)$
\ifPDFTeX % if pdftex
\author{$for(author)$$it.name$\textsuperscript{$for(author.affiliation)$$it.affiliation$$sep$,$endfor$$if(author.correspondence)$*$endif$$if(author.equal_contributor)$$endif$}$sep$ \and $endfor$}
\author{$for(author)$$it.name$$if(it.affiliation)$\textsuperscript{$for(author.affiliation)$$it.affiliation$$sep$,$endfor$$endif$}$if(author.correspondence)$\textsuperscript{*}$endif$$if(author.equal_contributor)$\textsuperscript{†}$endif$$sep$ \and $endfor$}
\else
\author{$for(author)$$it.name$\textsuperscript{$for(author.affiliation)$$it.affiliation$$sep$,$endfor$$if(author.correspondence)$\fixfontB{✉︎}$endif$$if(author.equal_contributor)$$endif$}$sep$ \and $endfor$}
\author{$for(author)$$it.name$$if(it.affiliation)$\textsuperscript{$for(author.affiliation)$$it.affiliation$$sep$,$endfor$}$endif$$if(author.correspondence)$\textsuperscript{\fixfontB{✉︎}}$endif$$if(author.equal_contributor)$\textsuperscript{†}$endif$$sep$ \and $endfor$}
\fi
$endif$
\date{$date$}
$if(beamer)$
$if(institute)$
\institute{$for(institute)$\textsuperscript{$it.index$} $it.name$$sep$ \and $endfor$}
\institute{$for(institute)$$if(it.index)$\textsuperscript{$it.index$}$endif$ $it.name$$sep$ \and $endfor$}
$endif$
$if(titlegraphic)$
\titlegraphic{\includegraphics{$titlegraphic$}}
Expand Down
3 changes: 3 additions & 0 deletions test.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ subtitle: A test document
author:
- name: Joanna Doe
- name: Joe Doe
institute:
- University of X
- Institute of Y
abstract: This is the abstract for a test file
keywords: pandoc, pandocomatic
date: 1^st^ January 2025
Expand Down

0 comments on commit 0a1d560

Please sign in to comment.