Skip to content

Commit

Permalink
markdown: avoid searching for bullets in code blocks
Browse files Browse the repository at this point in the history
Closes: #546
Signed-off-by: Alexander Golubev <[email protected]>
  • Loading branch information
Fat-Zer authored and mquinson committed Jan 28, 2025
1 parent a132ab5 commit b3ede29
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
6 changes: 5 additions & 1 deletion lib/Locale/Po4a/Text.pm
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,11 @@ sub parse_markdown {
$paragraph .= "$nextline";
( $nextline, $nextref ) = $self->shiftline();
}
do_paragraph( $self, $paragraph, $wrapped_mode, $type );
my $t = $self->translate(
$paragraph, $self->{ref}, $type,
"wrap" => 0
);
$self->pushline($t);
$self->pushline($nextline);
$paragraph = "";
$end_of_paragraph = 1;
Expand Down
5 changes: 5 additions & 0 deletions t/fmt/txt-markdown/PandocFencedCodeBlocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
qsort (filter (>= x) xs)
```
```diff
- Code block that includes bullet-like text.
- Ensure that it doesn't get interpreted.
```
This first pandoc fenced_div is non-nested.
::::: {#special .sidebar}
Expand Down
5 changes: 5 additions & 0 deletions t/fmt/txt-markdown/PandocFencedCodeBlocks.norm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
qsort (filter (>= x) xs)
```

```diff
- Code block that includes bullet-like text.
- Ensure that it doesn't get interpreted.
```

This first pandoc fenced_div is non-nested.

::::: {#special .sidebar}
Expand Down
24 changes: 17 additions & 7 deletions t/fmt/txt-markdown/PandocFencedCodeBlocks.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-04-28 18:23+0200\n"
"POT-Creation-Date: 2025-01-28 09:30+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -69,14 +69,24 @@ msgstr ""
"LINE2\n"
"``````````\n"

#. type: Fenced code block (diff)
#: PandocFencedCodeBlocks.md:51
#, no-wrap
msgid ""
"- Code block that includes bullet-like text.\n"
"- Ensure that it doesn't get interpreted.\n"
msgstr ""
"- cODE BLOCK THAT INCLUDES BULLET-LIKE TEXT.\n"
"- eNSURE THAT IT DOESN'T GET INTERPRETED.\n"

#. type: Plain text
#: PandocFencedCodeBlocks.md:52
#: PandocFencedCodeBlocks.md:57
#, markdown-text
msgid "This first pandoc fenced_div is non-nested."
msgstr "tHIS FIRST PANDOC FENCED DIV IS NON-NESTED."

#. type: Fenced div block ({#special .sidebar})
#: PandocFencedCodeBlocks.md:53
#: PandocFencedCodeBlocks.md:58
#, no-wrap
msgid ""
"Here is a paragraph.\n"
Expand All @@ -88,13 +98,13 @@ msgstr ""
"aND ANOTHER.\n"

#. type: Plain text
#: PandocFencedCodeBlocks.md:59
#: PandocFencedCodeBlocks.md:64
#, markdown-text
msgid "The second pandoc fenced div is nested."
msgstr "tHE SECOND PANDOC FENCED DIV IS NESTED."

#. type: Fenced div block (Warning ::::::)
#: PandocFencedCodeBlocks.md:60
#: PandocFencedCodeBlocks.md:65
#, no-wrap
msgid ""
"This is a warning.\n"
Expand All @@ -104,13 +114,13 @@ msgstr ""
"\n"

#. type: Fenced div block (Warning ::::::|Danger)
#: PandocFencedCodeBlocks.md:60
#: PandocFencedCodeBlocks.md:65
#, no-wrap
msgid "This is a warning within a warning.\n"
msgstr "tHIS IS A WARNING WITHIN A WARNING.\n"

#. type: Plain text
#: PandocFencedCodeBlocks.md:68
#: PandocFencedCodeBlocks.md:73
#, markdown-text
msgid "Some extra text."
msgstr "sOME EXTRA TEXT."
22 changes: 15 additions & 7 deletions t/fmt/txt-markdown/PandocFencedCodeBlocks.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-04-28 18:23+0200\n"
"POT-Creation-Date: 2025-01-28 09:44+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -55,14 +55,22 @@ msgid ""
"``````````\n"
msgstr ""

#. type: Fenced code block (diff)
#: PandocFencedCodeBlocks.md:51
#, no-wrap
msgid ""
"- Code block that includes bullet-like text.\n"
"- Ensure that it doesn't get interpreted.\n"
msgstr ""

#. type: Plain text
#: PandocFencedCodeBlocks.md:52
#: PandocFencedCodeBlocks.md:57
#, markdown-text
msgid "This first pandoc fenced_div is non-nested."
msgstr ""

#. type: Fenced div block ({#special .sidebar})
#: PandocFencedCodeBlocks.md:53
#: PandocFencedCodeBlocks.md:58
#, no-wrap
msgid ""
"Here is a paragraph.\n"
Expand All @@ -71,27 +79,27 @@ msgid ""
msgstr ""

#. type: Plain text
#: PandocFencedCodeBlocks.md:59
#: PandocFencedCodeBlocks.md:64
#, markdown-text
msgid "The second pandoc fenced div is nested."
msgstr ""

#. type: Fenced div block (Warning ::::::)
#: PandocFencedCodeBlocks.md:60
#: PandocFencedCodeBlocks.md:65
#, no-wrap
msgid ""
"This is a warning.\n"
"\n"
msgstr ""

#. type: Fenced div block (Warning ::::::|Danger)
#: PandocFencedCodeBlocks.md:60
#: PandocFencedCodeBlocks.md:65
#, no-wrap
msgid "This is a warning within a warning.\n"
msgstr ""

#. type: Plain text
#: PandocFencedCodeBlocks.md:68
#: PandocFencedCodeBlocks.md:73
#, markdown-text
msgid "Some extra text."
msgstr ""
5 changes: 5 additions & 0 deletions t/fmt/txt-markdown/PandocFencedCodeBlocks.trans
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ QSORT (X:XS) = QSORT (FILTER (< X) XS) ++ [X] ++
QSORT (FILTER (>= X) XS)
```

```diff
- cODE BLOCK THAT INCLUDES BULLET-LIKE TEXT.
- eNSURE THAT IT DOESN'T GET INTERPRETED.
```

tHIS FIRST PANDOC FENCED DIV IS NON-NESTED.

::::: {#special .sidebar}
Expand Down

0 comments on commit b3ede29

Please sign in to comment.