I have input.md
:
---
title: My example document
---
## Overview
*I am italic*
**I am bold**
If I run:
pandoc input.md -o output.odt
I get an odt file with the expected formatting. However, in order to prepare the document for conversion to a PDF/UA-compliant PDF, I have to manually remove the bold and italic formatting and style those text items as "Strong Emphasis" and "Emphasis", respectively, from the Styles menu.
I want to automate this, so I created custom_styles.lua
:
function Strong(elem)
return pandoc.Span(elem.content, {class = "StrongEmphasis"})
end
function Emph(elem)
return pandoc.Span(elem.content, {class = "Emphasis"})
end
If I run:
pandoc --lua-filter=custom_styles.lua -o output.odt input.md
My odt document now shows "No Character Style" for the text that was bold and italic.
Can somebody explain what I should be doing to achieve this?
Thanks I
This should work, but the custom styles must already exist in the reference odt.
To create the reference ODT, first run
pandoc --output=my-refdoc.odt --print-default-data-file=reference.odt
Edit the resulting file my-refdoc.odt
, add the custom styles, and then pass the modified file to pandoc via --reference-doc=my-refdoc.odt
when doint the conversion.
The filter should set the custom-style
attribute, so the code should use {['custom-style'] = "StrongEmphasis"}
.
Everything should work once those things are in place.