For these type of task, pandocomatic supports preprocessors, postprocessors, filters, setup scripts, and cleanup scripts in its templates.
For your specific issue, and this is a general pandoc solution, filters with side effects could work. For example, you can write a filter that would extract and inspect the metadata and writes it to to an RSS XML file.
In Paru¹, the Ruby wrapper and interface to pandoc, a very naive solution could look like:
#!/usr/bin/env ruby
require "paru/filter"
require "rss"
RSS_FILE = "my-rss-file.rss"
title = "No title"
date = Time.now.to_s
# Collect metadata information while filtering a document with pandoc
Paru::Filter.run do
title = metadata["title"] if metadata.has_key? "title"
date = metadata["date"] if metadata.has_key? "date"
end
# Create new Atom item
new = RSS::Maker.make("atom") do |maker|
maker.channel.author = maker.channel.about = maker.channel.title = ""
maker.channel.updated = Time.now.to_s
maker.items.new_item do |item|
item.title = title
item.updated = date
item.link = "Some link"
end
end
# Add new item to existing Atom RSS feed
rss = RSS::Parser.parse(File.read(RSS_FILE), false)
rss.items.concat new.items
File.write(RSS_FILE, rss)
(My apologies for the bad code, this is my first attempt at working with RSS/Atom)
For your specific issue, and this is a general pandoc solution, filters with side effects could work. For example, you can write a filter that would extract and inspect the metadata and writes it to to an RSS XML file.
In Paru¹, the Ruby wrapper and interface to pandoc, a very naive solution could look like:
(My apologies for the bad code, this is my first attempt at working with RSS/Atom)¹ https://heerdebeer.org/Software/markdown/paru/#writing-and-u...