mquinson / po4a

Maintain the translations of your documentation with ease (PO for anything)
http://po4a.org/
GNU General Public License v2.0
123 stars 61 forks source link

Generated markdown is combining lines #358

Closed PeterNjeim closed 2 years ago

PeterNjeim commented 2 years ago

po4a version 0.66. Using command po4a po4a.conf. As you can see, it's combining multiple lines into one line, making it unusable.

Firstly, any code block/fence syntax shouldn't be interefered with, ```bash should be untouched and remain by itself on its own line, and the final ``` should also be on its own line (same goes for 4 backticks ````). Secondly, the structure inside a code block should be untouched. Every line must remain its own line. I opened another issue (#357) on how to disable wrapping in the generated markdown file. While wrapping doesn't make much of a difference in text, it makes a large difference in code blocks, as each wrapped line is another line of code in the code block. In this example, the generated markdown was supposed to have a very long second line (wrongly, but still it should have a long second line as the po file shows), yet it actually divided it into 2 lines due to wrapping, placing the --open ``` on a separate line. This is no good for code blocks, there must be no wrapping at all.

po4a.conf:

[po_directory] po/

[options] --addendum-charset UTF-8 --localized-charset UTF-8 --master-charset UTF-8 --master-language en --msgmerge-opt '--no-wrap' --porefs file --wrap-po no --package-version 1.2.3 -k 0 neverwrap nowrap

[po4a_alias:markdown] text markdown

[type:markdown] source/README.md $lang:i18n/$lang/README.md

en.po:

#. type: Plain text
#: source/webmscore-pwa/README.md
msgid "```bash npm run dev"
msgstr ""

#. type: Plain text
#: source/webmscore-pwa/README.md
msgid "# or start the server and open the app in a new browser tab npm run dev -- --open ```"
msgstr ""

Source:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Output:

# or start the server and open the app in a new browser tab npm run dev --
--open ```
PeterNjeim commented 2 years ago

Bullet lists are being converted to non-lists: image

Lists inside quote blocks are ruined: image

Spaced quote blocks are also ruined: image

Unspaced quote blocks, which should act like one continuous code block, are also ruined since the second > symbol isn't removed: image

There seems to be a misunderstanding as to what a newline in markdown means. It does not simply equal a space when there is text on the next line, it depends on what syntax is around the line. There should be a mode where each line is its own line for markdown, no extra formatting needed.

PeterNjeim commented 2 years ago

Actually with some manual labour I can fix it up.

en.po:

#. type: Plain text
#: source/webmscore-pwa/README.md
msgid "```bash npm run dev"
msgstr ""
"```bash\n"
"npm run dev"

#. type: Plain text
#: source/webmscore-pwa/README.md
msgid "# or start the server and open the app in a new browser tab npm run dev -- --open ```"
msgstr ""
"# or start the server and open the app in a new browser tab\n"
"npm run dev -- --open\n"
"```"

However wrapping is still a problem.

en.po:

#. type: Plain text
#: source/webmscore-pwa/README.md
msgid "```bash npm run dev"
msgstr ""
"```bash\n"
"npm run dev"

#. type: Plain text
#: source/webmscore-pwa/README.md
msgid "# or start the server and open the app in a new browser tab npm run dev -- --open ```"
msgstr ""
"# or start the server and open the app in a new browser tab asd asd as das d asd asd as das d \n"
"npm run dev -- --open\n"
"```"

Output:

```bash
npm run dev

# or start the server and open the app in a new browser tab asd asd as das d
asd asd as das d
npm run dev -- --open


The comment goes to the next line, making it no longer a comment. I'm closing this issue in favor of #357 since this is work-aroundable, just the wrapping needs to be disabled.