Closed mijalche closed 6 years ago
Sorry for the late reply (I don't seem to get alerts when issues are made)!
Where do you want your keywords shown? They should be present in the metadata properties of your Word doc, and it would be possible to make a filter to add them to the actual document too...
Hi, thanks for making a follow up.
I have somehow creatively used your solution and the available variables in Pandoc to make a nice title page. In the reference document I made a keywords style and added in the abstract with span custom-style in order to show it in the text. I used your keywords solution to add keywords in document's metadata. I also used the date variable for the affiliations. Maybe not the perfect solution, but I think it uses at maximum the available options.
Based on that the YAML looks like this
---
title: This is my title
author: John Doe^1^^, ^^2^
keywords:
- for
- meta
- tags
date: ^1^ My University First, ^2^ My University Second
abstract: |
**Abstract:** This is the abstract.
<span custom-style=“Keywords”>**Keywords**: for, in , the, text.</span>
...
OK, that is a cool soloution! If you wanted to try a filter to do this, perhaps something like this may work:
#!/usr/bin/env ruby
# If we have keywords: metadata, convert it to an
# "Keywords" paragraph at the start of the document
# This is because Word template cannot handle this natively
require 'paru/filter'
Paru::Filter.run do
stop! unless metadata.key?('keywords')
kw = metadata['keywords']
text = '**Keywords**: '
if kw.is_a?(String)
text += kw
elsif kw.is_a?(Array)
kw.each_index do |i|
text += kw[i].to_s + ', '
end
text = text[0..-3]
elsif kw[0].is_a?(Hash)
text = 'HASH TODO'
end
p = Paru::PandocFilter::Para.new([])
p.inner_markdown = text
document.prepend(p)
stop!
end
Actually I just pushed a working filter to my dotpandoc repo, this works great for me:
https://github.com/iandol/dotpandoc/blob/master/filters/prependKeywords
Hi, thank you for your solution. It works for me. My question is: