mquinson / po4a

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

Bullet list getting compressed to one line #378

Closed joelnitta closed 1 year ago

joelnitta commented 1 year ago

I have the following original text file bullet_test.md with contents as follows:

a list

- first
- second
- third

I generated a PO file with po4a-updatepo -f text -m bullet_test.md -p bullet_test.po -o markdown.

In the PO file, the list is all on a single line, instead of one line per bullet:

# SOME DESCRIPTIVE TITLE
# Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2022-08-18 22:02+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. type: Plain text
#: bullet_test.md:2
#, markdown-text
msgid "a list"
msgstr ""

#. type: Plain text
#: bullet_test.md:5
#, markdown-text
msgid "- first - second - third"
msgstr ""

Expected output is each bullet on a separate line.

(It seems like reading the description of Locale::Po4a::Text that this sort of output would be expected with nobullets, but I am not using that, nor is that what I want)

Any help fixing this would be greatly appreciated. Thanks!

po4a version 0.67 running in docker container joelnitta/po4a:0.67

mquinson commented 1 year ago

Hello,

I think that the syntax of your file is to blame. Have a look at the syntax used in our tests: https://raw.githubusercontent.com/mquinson/po4a/master/t/fmt/txt-markdown/NestedLists.md

HTH, Mt

ghostwords commented 1 year ago

I ran into the same issue while getting started with po4a: https://github.com/EFForg/privacybadger-website/commit/95dc35ebf3e15759dcc0fc560be2d3a81e5c154e

Perhaps both * and - should be recognized as valid list markers.

Unordered lists use asterisks, pluses, and hyphens

-- https://daringfireball.net/projects/markdown/syntax

joelnitta commented 1 year ago

Thanks @ghostwords. I can confirm that using asterisks instead of hyphens does produce the expected output:

#. type: Plain text
#: bullet_test.md:2
#, markdown-text
msgid "a list"
msgstr ""

#. type: Bullet: '* '
#: bullet_test.md:5
#, markdown-text
msgid "first"
msgstr ""

#. type: Bullet: '* '
#: bullet_test.md:5
#, markdown-text
msgid "second"
msgstr ""

#. type: Bullet: '* '
#: bullet_test.md:5
#, markdown-text
msgid "third"
msgstr ""

I agree (and would consider this a feature request) that both * and - be recognized as valid list markers. In my experience, using - for lists is quite common in markdown. Obviously, using * in the original md file is a simple work-around, but my use-case here is for translating files that others have written, not myself. I would prefer not to require them to modify their valid markdown.

A related question: does po4a expect (or is scoped to) any particular flavor of markdown?

mquinson commented 1 year ago

Ok, I found and fixed the bug, thanks. Lists were only expected in verbatim paragraphs (ie, starting with some spaces, or starting with an asterisk). Btw, our test suite was expecting the buggy behaviour :) The file testing the rules was wrongly parsing leading hyphens as plain paragraphs...

mquinson commented 1 year ago

As for the specific flavor of markdown that we use, I confess that I have no idea. The same discussion arised for Asciidoc, and I seem to remember that the conclusion was to be pragmatic and cover as many flavors as possible by default. When flavors stop being compatible, then we need to introduce options to let the user pick their choice.

joelnitta commented 1 year ago

Thanks @mquinson!

When flavors stop being compatible, then we need to introduce options to let the user pick their choice.

That sounds reasonable to me.

FWIW + is also a valid list bullet.