jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.87k stars 3.34k forks source link

Allow metaStyles to be converted as `custom-styles` #8527

Open me-kell opened 1 year ago

me-kell commented 1 year ago

Explain the problem.

If the first paragraph has the style Title (or another metaStyle) it cannot be converted to custom-styles:

$ pandoc -f markdown -t docx -o mydoc.docx << EOF
::: {custom-style="Title"}
MyTitle
:::
EOF
$ pandoc mydoc.docx -f docx+styles -t markdown
no output

$ pandoc mydoc.docx -f docx+styles -t markdown --standalone
---
title: MyTitle
---

Only if there are some paragraphs before can they be converted to custom-styles.

$ pandoc -f markdown -t docx -o mydoc.docx << EOF
some text

::: {custom-style="Title"}
MyTitle
:::
EOF
$ pandoc mydoc.docx -f docx+styles -t markdown
::: {custom-style="First Paragraph"}
some text
:::

::: {custom-style="Title"}
MyTitle
:::

$ pandoc mydoc.docx -f docx+styles -t markdown --standalone
::: {custom-style="First Paragraph"}
some text
:::

::: {custom-style="Title"}
MyTitle
:::

Pandoc version?

$ pandoc --version
pandoc 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.2.1
Scripting engine: Lua 5.4
tarleb commented 1 year ago

Do you have a mechanism / interface change in mind that would allow this?