Examples
Concatenate all the journal entries and convert them to another format using pandoc
You can concatenate all the files in your journal and convert them from, for instance, Markdown to another format like HTML, using something like a shell script for the concatenation and a tool like pandoc for the conversion.
What follows is a Lua filter that takes an input document, parses the date from the metadata, and if successful, makes a headline out of it which is then prepended to the body of the document.
-- giornata.lua
function format_date (date)
local pattern = "(%d%d%d%d)-(%d%d)-(%d%d)"
local year, month, day = date:match(pattern)
local time = os.time {year = year, month = month, day = day }
return os.date("%B %d, %Y", time)
end
function Pandoc (doc)
local date = pandoc.utils.stringify(doc.meta.date)
local formatted_date = format_date(date)
local title = pandoc.Header(1, formatted_date)
table.insert(doc.blocks, 1, title)
return doc
end
return {
{ Pandoc = Pandoc },
}
This shell script will traverse the current directory — the
giornata-directory
, process every individual journal entry using the supplied
Lua filter and eventually compile everything into a single document.
# compile.sh
entries=$(find . -regex "./[0-9]+/[0-9]+/[0-9]+" | sort -r | xargs)
for file in $(entries); do \
pandoc $file --from markdown --to html --lua-filter giornata.lua; \
done | pandoc --to html --standalone --output journal.html
Now, run ./compile.sh
to get that sweet, sweet single-page journal.