2

I wrote some HTML and included class (and then tried ID) attributes to specify things like margin, font-family, etc. A CSS file contains all the "styles."

When using pandoc to convert to ePub, all the attributes get removed. How do I produce an ePub that preserves the styles I want displayed in the text?

For example, say I want the first line of a paragraph to have text-align: left and subsequent lines of that paragraph to have a text-indent (a common presentation for fiction). I prescribe these attributes via the CSS file but pandoc removes it all from the HTML on conversion.

Giacomo1968
  • 58,727
user847
  • 21
  • 1

1 Answers1

5

What you want is not possible using Pandoc due to how that tool works. You will need to find a different tool to retain formatting beyond simple document structure. From the Pandoc manual:

Because pandoc’s intermediate representation of a document is less expressive than many of the formats it converts between, one should not expect perfect conversions between every format and every other. Pandoc attempts to preserve the structural elements of a document, but not formatting details such as margin size. And some document elements, such as complex tables, may not fit into pandoc’s simple document model. While conversions from pandoc’s Markdown to all formats aspire to be perfect, conversions from formats more expressive than pandoc’s Markdown can be expected to be lossy.

See also this question with the same answer on our sister site: https://stackoverflow.com/questions/58483340/how-do-you-keep-the-styling-when-you-convert-docx-to-pdf-in-pandoc

music2myear
  • 49,799