markdownpandoc

Pandoc styling of Default Paragraph and Body Text


I have the markdown file input.md:

---
title: My test document
---

## Section 1

Line 1.

Line 2.

Line 3.

## Section 2

Line 1.

Line 2.

Line 3.

I have a very simple reference.odt document.

I convert the markdown to ODT with:

pandoc input.md --reference-doc=reference.odt -o output.odt

Under both headings in the ODT document:

This makes the final document appear badly formatted.

I appreciate that I could change the styling of "Default Paragraph Style" in reference.odt, but that will have knock-on effects elsewhere, such as table of contents, etc.

I also appreciate that I could probably apply the "Body Text" style to a paragraph in the markdown, but that's not preferable, as it overcomplicates the markdown (which is supposed to be simple.)

Is there a way to instruct Pandoc to treat everything under a heading as "Body Text"?

If not, does anyone have any other solutions?

Thanks

I


Solution

  • A Lua filter could do this. The one below wraps all paragraphs such that a custom style is forced for all paragraph, thus overriding the default behavior of using a different style for the first paragraph in a section.

    local paragraph_style = 'Text body'
    function Para (p)
      return pandoc.Div({p}, {['custom-style'] = paragraph_style})
    end
    

    Use the filter by saving it to a file and passing it to pandoc via --lua-filter=/path/to/the/filter.lua.