pandoc shoud trim style before converting docx to md

Created on 4 Feb 2019  路  5Comments  路  Source: jgm/pandoc

Hello

when trying to convert docx to markdown (gfm), when a work is in bold and the space after the word is in bold too, there is an issue in markdown generation:

if the word docx has been filled like this

<bold>this is a bold </bold>

Note: xml is just to illustrate
Note: there is a space after the bold word

it converts to
**this is a bold **

But almost all markdown engines won't renderize well this kind of string because of the space before the 2 stars.

Is it possible to autotrim for these cases?

(I think it should be the same with italic and other decorations)

pandoc 2.6
command:

pandoc -s --toc -f docx -t gfm star.docx
**Blablablbla聽**:
Docx reader

Most helpful comment

It actually does do this in general, but apparently doesn't work if it's at the end of a paragraph. That's a bug and I'll fix it up now.

EDIT: There's something obscure here where visually identical things produce slightly different results. I'm going to have to dig into the xml, so it will take a bit longer.

All 5 comments

Yes, we should. We do that in some of the other readers. There is a utility function extractSpaces in Text.Pandoc.Shared that is designed for just this purpose. @jkr would you like to implement this in the docx reader?

It actually does do this in general, but apparently doesn't work if it's at the end of a paragraph. That's a bug and I'll fix it up now.

EDIT: There's something obscure here where visually identical things produce slightly different results. I'm going to have to dig into the xml, so it will take a bit longer.

I don't get it, why this fixe has been removed from 2.7 milestone?

@nemenemsrouge Don't worry too much, the fix is already in master, so the next version of pandoc will include it (you can even use the nightly version if you are eager to test it).

thx!
I'll test the nightly build !
Thank you again for your reactivity!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elliottslaughter picture elliottslaughter  路  44Comments

jgm picture jgm  路  266Comments

jgm picture jgm  路  62Comments

brainchild0 picture brainchild0  路  66Comments

GiantCrocodile picture GiantCrocodile  路  54Comments