mondeja / mdpo

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

Extra space is inserted on links, now on `<li>` items (see also #147) #155

Closed EuAndreh closed 3 years ago

EuAndreh commented 3 years ago

I found a similar issue to #147 with links inside a <li>...</li> tag.

Sample interactive session:

$ pushd `mktemp -d`
/tmp/tmp.eumfknLzp8 ~/dev/libre/git-permalink
$ cat <<EOF > sample.md
> [paragraph link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it)
>
> - [list item link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it)
> EOF
$ md2po sample.md --po-filepath l.po --save
#
msgid ""
msgstr ""

#: sample.md:block 1 (paragraph)
msgid ""
"[paragraph link name](https://example.com/a-big-link-with-a-very-very-long-"
"and-big-url-name-on-it)"
msgstr ""

#: sample.md:block 2 (unordered list)
msgid ""
"[list item link name](https://example.com/a-big-link-with-a-very-very-long-"
"and-big-url-name-on-it)"
msgstr ""

$ po2md sample.md --pofiles l.po --save sample.l.md
$ cat sample.l.md
[paragraph link
name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it)

- [list item link name](https://example.com/a-big-link-with-a-very-very-long-
and-big-url-name-on-it)
$ pandoc -i sample.md -w html
<p><a href="https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it">paragraph link name</a></p>
<ul class="incremental">
<li><a href="https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it">list item link name</a></li>
</ul>
$ pandoc -i sample.l.md -w html
<p><a href="https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it">paragraph link name</a></p>
<ul class="incremental">
<li><a href="https://example.com/a-big-link-with-a-very-very-long-%20and-big-url-name-on-it">list item link name</a></li>
</ul>
$ md2po --version
.md2po-real 0.3.54
pushd `mktemp -d`

cat <<EOF > sample.md
[paragraph link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it)

- [list item link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it)
EOF

md2po sample.md --po-filepath l.po --save
po2md sample.md --pofiles l.po --save sample.l.md
cat sample.l.md
pandoc -i sample.md -w html
pandoc -i sample.l.md -w html
md2po --version

The generated pofile is equivalent, but reconstruction of it into the markdown that seems to be failing. I'm don't think this is intentational, so I came here to report back the issue.

I've only now encountered it, after using mdpo a bit more, with the equivalent <p>...</p> issue fixed.

I'm not yet entirely sure how you prefer to handle these, and if you're OK with me showing up every once in a while to point out a problem, and maybe try to write the code to address it.

If so, I'm happy to keep doing it. Otherwise, I'm also open to alternatives that suit you better.

mondeja commented 3 years ago

I'm not yet entirely sure how you prefer to handle these, and if you're OK with me showing up every once in a while to point out a problem, and maybe try to write the code to address it.

Thank you for the report. Any problem, keep reporting its really useful 👍🏼

mondeja commented 3 years ago

Fixed in v0.3.63.

EuAndreh commented 3 years ago

Thanks!

EuAndreh commented 3 years ago

Hmm, a different issue came up, and it may be related: an extra <li> is added after the link when a - something is present.

Sample interactive session:

$ pushd `mktemp -d`
/tmp/tmp.BAOuydpVAf ~
$ echo '- [list item link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it) - 2021-07-16' > sample.md
$ md2po sample.md --po-filepath l.po --save
#
msgid ""
msgstr ""

#: sample.md:block 1 (unordered list)
msgid ""
"[list item link name](https://example.com/a-big-link-with-a-very-very-long-"
"and-big-url-name-on-it) - 2021-07-16"
msgstr ""

$ po2md sample.md --pofiles l.po --save sample.l.md
$ cat sample.l.md
- [list item link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it)
- 2021-07-16
$ md2po --version
.md2po-real 0.3.63
$

Extracted steps to reproduce:

pushd `mktemp -d`
echo '- [list item link name](https://example.com/a-big-link-with-a-very-very-long-and-big-url-name-on-it) - 2021-07-16' > sample.md
md2po sample.md --po-filepath l.po --save
po2md sample.md --pofiles l.po --save sample.l.md
cat sample.l.md
md2po --version

The generated pofile looks fine, the generation of the markdown that looks to be the issue.

EuAndreh commented 3 years ago

Should we file a new issue?

mondeja commented 3 years ago

Is not an issue, it is the expected behaviour. Is parsed as a list with one item, but the wrapping moves - 2021-07-16 to a new line. Could you check with --wrapwidth 999? You should see it in one line.

EuAndreh commented 3 years ago

Indeed, --wrapwidth 999 worked. Thanks again.