From 91937e7d027dbfe18b3ea8f7e4a51203c80ef461 Mon Sep 17 00:00:00 2001 From: gemmaro Date: Fri, 14 Feb 2025 16:22:06 +0900 Subject: [PATCH] Allow Vim language specification for code block beginning * lib/Locale/Po4a/VimHelp.pm: Added support for an optional Vim language specification (">vim" followed by a line end) for the beginning of code blocks, in addition to the existing ">". * t/fmt/vimhelp/basic.norm:, t/fmt/vimhelp/basic.po, t/fmt/vimhelp/basic.pot, t/fmt/vimhelp/basic.trans, t/fmt/vimhelp/basic.txt: Add a test case. --- lib/Locale/Po4a/VimHelp.pm | 6 +++--- t/fmt/vimhelp/basic.norm | 4 ++++ t/fmt/vimhelp/basic.po | 12 ++++++++++++ t/fmt/vimhelp/basic.pot | 12 ++++++++++++ t/fmt/vimhelp/basic.trans | 4 ++++ t/fmt/vimhelp/basic.txt | 4 ++++ 6 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/Locale/Po4a/VimHelp.pm b/lib/Locale/Po4a/VimHelp.pm index 249071c1..53a0cfda 100644 --- a/lib/Locale/Po4a/VimHelp.pm +++ b/lib/Locale/Po4a/VimHelp.pm @@ -141,7 +141,7 @@ sub skip_tags { sub is_tags { my $line = shift; - $line =~ / \A \s* [*] [^*]+ [*] (?: \s+ [*] [^*]+ [*] )* (\s+ [>])? \Z /xms or return; + $line =~ / \A \s* [*] [^*]+ [*] (?: \s+ [*] [^*]+ [*] )* (\s+ [>] (vim)?)? \Z /xms or return; my $codeblock = $1; return { codeblock => $codeblock }; @@ -174,7 +174,7 @@ sub translate_codeblock_with_start_line { } sub is_codeblock_start_line { - return shift =~ / \A [>] \Z /xms; + return shift =~ / \A [>] (vim)? \Z /xms; } sub translate_paragraph { @@ -221,7 +221,7 @@ sub translate_paragraph { sub parse_paragraph_line { my $line = shift; - $line =~ / \A (.*?) (\s+ [>])? \Z /xms or die "unreachable"; + $line =~ / \A (.*?) (\s+ [>] (vim)?)? \Z /xms or die "unreachable"; my $content = $1; my $codeblock = $2; diff --git a/t/fmt/vimhelp/basic.norm b/t/fmt/vimhelp/basic.norm index 2869e246..31b9b962 100644 --- a/t/fmt/vimhelp/basic.norm +++ b/t/fmt/vimhelp/basic.norm @@ -20,3 +20,7 @@ basic15-90123456789012345678901234567890123456789012345678901234567890123456789 basic17-901234567890123456789012345678901234567890123456789012345678901234567あ ---------1---------2---------3---------4---------5---------6---------7--------- + +basic18-1 >vim + basic18-2 +< diff --git a/t/fmt/vimhelp/basic.po b/t/fmt/vimhelp/basic.po index bdcf7565..db5e6424 100644 --- a/t/fmt/vimhelp/basic.po +++ b/t/fmt/vimhelp/basic.po @@ -85,3 +85,15 @@ msgid "" msgstr "" "BASIC17-901234567890123456789012345678901234567890123456789012345678901234567あ\n" "---------1---------2---------3---------4---------5---------6---------7---------" + +#. type: paragraph +#: basic.txt:24 +#, no-wrap +msgid "basic18-1" +msgstr "BASIC18-1" + +#. type: codeblock +#: basic.txt:25 +#, no-wrap +msgid "basic18-2" +msgstr "BASIC18-2" diff --git a/t/fmt/vimhelp/basic.pot b/t/fmt/vimhelp/basic.pot index 913d2d36..c1786851 100644 --- a/t/fmt/vimhelp/basic.pot +++ b/t/fmt/vimhelp/basic.pot @@ -77,3 +77,15 @@ msgid "" "basic17-901234567890123456789012345678901234567890123456789012345678901234567あ\n" "---------1---------2---------3---------4---------5---------6---------7---------" msgstr "" + +#. type: paragraph +#: basic.txt:24 +#, no-wrap +msgid "basic18-1" +msgstr "" + +#. type: codeblock +#: basic.txt:25 +#, no-wrap +msgid "basic18-2" +msgstr "" diff --git a/t/fmt/vimhelp/basic.trans b/t/fmt/vimhelp/basic.trans index e9ddb770..fec54624 100644 --- a/t/fmt/vimhelp/basic.trans +++ b/t/fmt/vimhelp/basic.trans @@ -20,3 +20,7 @@ BASIC15-90123456789012345678901234567890123456789012345678901234567890123456789 BASIC17-901234567890123456789012345678901234567890123456789012345678901234567あ ---------1---------2---------3---------4---------5---------6---------7--------- + +BASIC18-1 >vim + BASIC18-2 +< diff --git a/t/fmt/vimhelp/basic.txt b/t/fmt/vimhelp/basic.txt index 2869e246..31b9b962 100644 --- a/t/fmt/vimhelp/basic.txt +++ b/t/fmt/vimhelp/basic.txt @@ -20,3 +20,7 @@ basic15-90123456789012345678901234567890123456789012345678901234567890123456789 basic17-901234567890123456789012345678901234567890123456789012345678901234567あ ---------1---------2---------3---------4---------5---------6---------7--------- + +basic18-1 >vim + basic18-2 +<