fletcher / peg-multimarkdown

An implementation of MultiMarkdown in C, using a PEG grammar - a fork of jgm's peg-markdown. No longer under active development - see MMD 5.
Other
525 stars 55 forks source link

Tabs Added to Preformatted Text in ODF format #111

Open Frimkron opened 12 years ago

Frimkron commented 12 years ago

I'm having an issue whereby spaces in my code blocks are being converted to tabs when I convert to odf.

For example, the following diagram:

    +-----+      +-----+
    |  A  | ---> |  B  |
    +-----+      +-----+

Gets converted to the following markup (I've added linebreaks for readability):

<text:p text:style-name="Preformatted Text">
    +-----+<text:tab/>  +-----+<text:line-break/>
    |  A  | ---&gt; |  B  |<text:line-break/>
    +-----+<text:tab/>  +-----+<text:line-break/>
</text:p>

The added <text:tab/> elements cause the preformatted text to look wrong when opened in Open Office, for example.

I'm using multimarkdown version 3.5.1

fletcher commented 12 years ago

That's because tabs get converted to 4 spaces during processing, and this is the only way to get tabs back (e.g. converting 4 spaces back to a tab).

There might be a way to change this behavior inside of code blocks, but this is going to be a really low priority for me.

Frimkron commented 12 years ago

It's probably also worth noting that to properly preserve runs of spaces, they should be encoded as <text:s/> elements, like this:

<text:p text:style-name="Preformatted Text">
    +-----+<text:s text:c="6"/>+-----+<text:line-break/>
    |<text:s text:c="2"/>A<text:s text:c="2"/>| ---&gt; |<text:s text:c="2"/>B<text:s text:c="2"/>|<text:line-break/>
    +-----+<text:s text:c="6"/>+-----+</text:line-break/>
</text:p>
fletcher commented 12 years ago

I'll have to look into that. I'm definitely not an expert in ODF. I'm actually a bit surprised it works as well as it does. ;)