1

After reading the online Pandoc manual and browsing pages such as knitr-pandoc-article-template-supporting-keywords and Keywords in Pandoc 2, I haven't figured out yet how to write the values of the thanks and keywords YAML fields from the header of a Markdown file to a docx document through Pandoc conversion. My working version of Pandoc is 2.18.

I have thought that a Lua filter might be the way to proceed, but my knowledge of both Lua and the Pandoc framework at the programmatic level is quite limited.

Any help in this regard would be greatly appreciated.

Although my actual setup is more complex, the following Markdown lines with a YAML header should do for an MWE:

---
title: The Title
author: The Author
thanks: |
  The author wishes to thank certain support.
abstract: |
  This is the abstract.
keywords: [one, two, three, four]
---
   
# A Heading

Text body. 
Marcos
  • 135
  • 1
  • 5

1 Answers1

1

The answer to this depends a little on how you'd want the thanks to be viewed. E.g., if you'd like it to be presented as a footnote to the author, you'd use a Lua filter like this:

function Meta (meta)
  meta.author = meta.author .. {pandoc.Note(meta.thanks)}
  return meta
end

The approach can be adapted to match different requirements.

tarleb
  • 19,863
  • 4
  • 51
  • 80
  • Any way to add the `affiliation` of the author in the YAML file when converting Markdown to docx? There is a [GitHub issue](https://github.com/jgm/pandoc/issues/3696) regarding it, but I have no idea how to do it. – TomBen Jan 07 '23 at 12:17
  • @TomBen: I am using Lua filters for author affiliations, namely, [scholarly-metadata](https://github.com/pandoc/lua-filters/tree/master/scholarly-metadata) and [author-info-blocks](https://github.com/pandoc/lua-filters/tree/master/author-info-blocks). – Marcos Jan 07 '23 at 13:36
  • @tarleb: I am using your approach to set the keywords after the abstract like `meta.abstract = meta.abstract .. {pandoc.Emph("Keywords")} .. meta.keywords`, but I run into the problem that the keywords are set as a list; in particular, starting a new paragraph after the constant string "Keywords" and each value in its own paragraph. How can they be set as a comma-separated list (or a string) in a single line? – Marcos Jan 07 '23 at 13:39
  • @Marcos: The answer would be a bit too long for a comment, can you open a new question? The main idea would be to flatten keywords into a string with `table.concat(meta.keywords:map(pandoc.utils.stringify), ', ')`. – tarleb Jan 07 '23 at 14:58
  • @tarleb: I have just opened a new question as [Print the value of the keywords field in a YAML header as an inline list](https://stackoverflow.com/questions/75041782/convert-the-value-of-the-keywords-field-of-the-yaml-header-in-a-markdown-file-so). – Marcos Jan 07 '23 at 16:07