mondeja / mdpo

Markdown files translation using GNU PO files
https://mondeja.github.io/mdpo/
BSD 3-Clause "New" or "Revised" License
25 stars 5 forks source link

Newlines in table get replaced with space, causing rendering issues #226

Closed keunes closed 2 years ago

keunes commented 2 years ago

Hello!

We're using mdpo for the translation of the AntennaPod website. Now that we're getting in the first translations, we've noticed that newlines in tables are replaced with spaces when the PO(T) are created, and that this messes up the rendering of the table.

The following table:

| Key | Action |
| -- | -- |
|`P` | Play/Pause|
| `J`/`A`/`,` | Rewind media |
| `K`/`D`/`.` | Forward media |
| `+`/`W` | Raise media volume channel |
| `-`/`S` | Lower media volume channel) |
| `M` | Mute/unmute (toggle) media volume channel (only on Android 6 and higher) |

when running

md2po _i18n/en/documentation/*.md --po-filepath _i18n/translation-files/site-documentation.pot --save --quiet

turns into

#: _i18n/en/documentation/playback/shortcuts.md:block 3 (paragraph)
msgid ""
"| Key | Action | | -- | -- | |`P` | Play/Pause| | `J`/`A`/`,` | Rewind media"
" | | `K`/`D`/`.` | Forward media | | `+`/`W` | Raise media volume channel | "
"| `-`/`S` | Lower media volume channel) | | `M` | Mute/unmute (toggle) media"
" volume channel (only on Android 6 and higher) |"
msgstr ""

This, however, creates rendering issues like on this page (en correct, fr not).

I realise that tables are not (yet) part of Commonmark. But given that this actually is just a multiline string, I would expect (based on this article) the PO file to have \n instead of a space.

Would this be possible? Or is there an alternative solution that you can think of (e.g. structuring our MD table slightly differently)?

Many thanks!

mondeja commented 2 years ago

Your table is not correctly formatted because separators must have 3 characters or more, so the second line must be | --- | --- | instead of | -- | -- | to be properly parsed. Cheers!