jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.69k stars 3.39k forks source link

`docx` and `docx+styles` readers process `Source Code` style differently #9183

Open rgaiacs opened 1 year ago

rgaiacs commented 1 year ago

DOCX Minimal Working Example

Given the above minimal working example, reading the DOCX file as docx and docx+styles produces different outputs.

Output of pandoc --from docx --to markdown --standalone pandoc-code-test.docx (when reading as docx):

---
title: PANDOC TEST
---

# Simple Math with Python

    x = 1
    y = x + 1

Note that "Heading 1" style was converted to native heading level 1 and "Source Code" style was converted to native code block.

Output of pandoc --from docx+styles --to markdown --standalone pandoc-code-test.docx (when reading as docx+styles):

---
title: PANDOC TEST
---

# Simple Math with Python

::: {custom-style="Source Code"}
    x = 1
:::

::: {custom-style="Source Code"}
    y = x + 1
:::

Note that "Heading 1" style was converted to native heading level 1 but "Source Code" style was converted into two div blocks custom-style equal to "Source Code" instead of the expected native code block.

Environment

pandoc --version returns

pandoc 3.1.5
Features: +server +lua
Scripting engine: Lua 5.4

and

pandoc 3.1.8
Features: +server +lua
Scripting engine: Lua 5.4
jgm commented 1 year ago

This doesn't look like a bug to me. +custom_styles tells the docx reader to put style information into the custom-style attribute instead of doing what it would normally do with it -- see the manual.

rgaiacs commented 1 year ago

Thanks for the reply.

If +custom_styles tells the docx reader to put style information into the custom-style attribute, why does it not create

::: {custom-style="Heading 1"}
# Simple Math with Python
:::

but instead

# Simple Math with Python
jgm commented 1 year ago

There's obviously some inconsistency here in how different elements are treated. For example, (according to the manual anyway) *emphasis* gets parsed with a span with a custom style.

jgm commented 1 year ago

I'm not sure whether there are other exceptions, aside from headings.