Skip to content

Commit

Permalink
Locale::Po4a::Test: supported nested lists
Browse files Browse the repository at this point in the history
  • Loading branch information
terceiro committed May 31, 2020
1 parent 357486a commit 57985b3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 30 deletions.
7 changes: 5 additions & 2 deletions lib/Locale/Po4a/Text.pm
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ sub do_paragraph {
my $indent1 = $1;
my $indent2 = "$1" . ( ' ' x length $bullet );
my $text = $4;
while ( $para !~ m/$indent2(?:[-*o+]|([0-9]+[.\)])|\([0-9]+\))\s+/
while ( $para !~ m/^$indent2(?:[-*o+]|([0-9]+[.\)])|\([0-9]+\))\s+/
and $para =~ s/^$indent2(\S[^\n]*\n)//s )
{
$text .= $1;
Expand All @@ -978,7 +978,10 @@ sub do_paragraph {
if ( $text !~ m/\S[ \t][ \t][ \t]+\S/s ) {
my $bullet_regex = quotemeta( $indent1 . $bullet );
$bullet_regex =~ s/[0-9]+/\\d\+/;
if ( $para eq '' or $para =~ m/^$bullet_regex\S/s ) {
if ( $para eq ''
or $para =~ m/^(\s*)((?:[-*o+]|([0-9]+[.\)])|\([0-9]+\))\s+)([^\n]*\n)(.*)$/s
or $para =~ m/^$bullet_regex\S/s )
{
my $trans = $self->translate(
$text,
$self->{ref},
Expand Down
1 change: 0 additions & 1 deletion t/fmt-txt-markdown.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ push @tests,
'input' => "fmt/txt-markdown/NoWrap.md",
},
{
'todo' => "NestedLists: currently broken (https://github.com/mquinson/po4a/issues/131)",
'format' => 'text',
'options' => '-o markdown',
'input' => "fmt/txt-markdown/NestedLists.md",
Expand Down
35 changes: 24 additions & 11 deletions t/fmt/txt-markdown/NestedLists.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,49 @@ msgstr ""
"Content-Transfer-Encoding: 8BIT\n"

#. type: Plain text
#: MarkDownNestedLists.md:1
#: NestedLists.md:2
#, markdown-text
msgid "This serves as testcase for simple lists."
msgstr "THIS SERVES AS TESTCASE FOR SIMPLE LISTS."

#. type: Bullet: ' * '
#: MarkDownNestedLists.md:3
#: NestedLists.md:6 NestedLists.md:15
#, markdown-text
msgid "Item 1"
msgstr "ITEM 1"

#. type: Bullet: ' * '
#: MarkDownNestedLists.md:4
#: NestedLists.md:6 NestedLists.md:15
#, markdown-text
msgid "This item paragraph runs over several lines."
msgstr "THIS ITEM PARAGRAPH RUNS OVER SEVERAL LINES."

#. type: Plain text
#: MarkDownNestedLists.md:1
#: NestedLists.md:8
#, markdown-text
msgid "This serves as testcase for nested lists."
msgstr "THIS SERVES AS TESTCASE FOR NESTED LISTS."

#. type: Bullet: ' * '
#: MarkDownNestedLists.md:6
msgid "Nested item 2"
msgstr "NESTED ITEM 2"
#. type: Bullet: ' * '
#: NestedLists.md:15
#, markdown-text
msgid "Nested item 1"
msgstr "NESTED ITEM 1"

#. type: Bullet: ' * '
#: MarkDownNestedLists.md:5
#. type: Bullet: ' * '
#: NestedLists.md:15
#, markdown-text
msgid "Sub-sub item"
msgstr "SUB-SUB ITEM"

#. type: Bullet: ' * '
#: NestedLists.md:15
#, markdown-text
msgid "Nested item 2"
msgstr "NESTED ITEM 2"

#. type: Plain text
#: MarkDownNestedLists.md:8
#: NestedLists.md:16
#, markdown-text
msgid "Normal paragraph."
msgstr "NORMAL PARAGRAPH."
18 changes: 12 additions & 6 deletions t/fmt/txt-markdown/NestedLists.pot
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ msgid "Item 1"
msgstr ""

#. type: Bullet: ' * '
#: NestedLists.md:6
#: NestedLists.md:6 NestedLists.md:15
#, markdown-text
msgid "This item paragraph runs over several lines."
msgstr ""
Expand All @@ -40,18 +40,24 @@ msgstr ""
msgid "This serves as testcase for nested lists."
msgstr ""

#. type: Bullet: ' * '
#: NestedLists.md:6
#. type: Bullet: ' * '
#: NestedLists.md:15
#, markdown-text
msgid "Nested item 2"
msgid "Nested item 1"
msgstr ""

#. type: Bullet: ' * '
#: NestedLists.md:5
#. type: Bullet: ' * '
#: NestedLists.md:15
#, markdown-text
msgid "Sub-sub item"
msgstr ""

#. type: Bullet: ' * '
#: NestedLists.md:15
#, markdown-text
msgid "Nested item 2"
msgstr ""

#. type: Plain text
#: NestedLists.md:16
#, markdown-text
Expand Down
20 changes: 10 additions & 10 deletions t/fmt/txt-markdown/NestedLists.trans
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
This serves as testcase for simple lists.
THIS SERVES AS TESTCASE FOR SIMPLE LISTS.

* Item 1
* This item paragraph runs over several lines.
* ITEM 1
* THIS ITEM PARAGRAPH RUNS OVER SEVERAL LINES.

This serves as testcase for nested lists.
THIS SERVES AS TESTCASE FOR NESTED LISTS.

* Item 1
* This item paragraph runs over several lines.
* Nested item 1
* Sub-sub item
* Nested item 2
* ITEM 1
* THIS ITEM PARAGRAPH RUNS OVER SEVERAL LINES.
* NESTED ITEM 1
* SUB-SUB ITEM
* NESTED ITEM 2

Normal paragraph.
NORMAL PARAGRAPH.

0 comments on commit 57985b3

Please sign in to comment.