From af2da1781abaf4d11d966bada544b28ad91e3889 Mon Sep 17 00:00:00 2001 From: "Fuji, Goro (gfx)" Date: Tue, 4 Mar 2014 23:16:52 +0900 Subject: [PATCH] fix char convertion for sjis (#14) --- config/id_filter.json | 4 ++-- lib/Text/Md2Inao/Builder.pm | 2 +- t/30_indesign_basic_syntax.t | 2 +- t/32_indesign_free_replacer.t | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/id_filter.json b/config/id_filter.json index 6eec2bd..b4270ef 100644 --- a/config/id_filter.json +++ b/config/id_filter.json @@ -59,10 +59,10 @@ "◆WDB◆" : "#", "㈱" : "<3231>", - "\\(株\\)" : "<3231>", + "(株)" : "<3231>", "✓" : "<2713>", "✖" : "<2716>", - "\" : "<005C><005C>", + "\\" : "<005C><005C>", "~" : "<007E>", "~" : "〜" } diff --git a/lib/Text/Md2Inao/Builder.pm b/lib/Text/Md2Inao/Builder.pm index 4a7295f..a1632d8 100644 --- a/lib/Text/Md2Inao/Builder.pm +++ b/lib/Text/Md2Inao/Builder.pm @@ -64,7 +64,7 @@ sub after_filter { $out =~ s/◆gt◆/>/g; if (my $config = $self->after_filter_config) { for my $k (keys %$config) { - $out =~ s/$k/$config->{$k}/eg; + $out =~ s/\Q$k/$config->{$k}/eg; } } return $out; diff --git a/t/30_indesign_basic_syntax.t b/t/30_indesign_basic_syntax.t index 82be0a4..8fbbf46 100644 --- a/t/30_indesign_basic_syntax.t +++ b/t/30_indesign_basic_syntax.t @@ -248,7 +248,7 @@ __END__ function hoge() { alert(foo); … <2460> alert(bar); … <2461> - alert(c1); // \でエスケープできます + alert(c1); // <005C><005C>でエスケープできます } diff --git a/t/32_indesign_free_replacer.t b/t/32_indesign_free_replacer.t index 81f2b64..b848ae5 100644 --- a/t/32_indesign_free_replacer.t +++ b/t/32_indesign_free_replacer.t @@ -28,7 +28,7 @@ __END__ --- in md2inao AZ --- expected -AZ +AZ === right arrow --- in md2inao @@ -300,13 +300,13 @@ __END__ --- expected -=== +=== --- in md2inao ㈱(株) --- expected <3231><3231> -=== +=== --- in md2inao ✓ --- expected @@ -320,7 +320,7 @@ __END__ === shiftjis --- in md2inao -\ +\\ --- expected <005C><005C>