From 2d83077d318a48b5a2b02bd8524bb8510180c98b Mon Sep 17 00:00:00 2001 From: takahashim Date: Wed, 31 Jan 2024 12:06:42 +0900 Subject: [PATCH] remove DakutenKatakana; use Gaiji with kuten2png --- lib/aozora2html.rb | 13 ------------- lib/aozora2html/tag.rb | 1 - lib/aozora2html/tag/dakuten_katakana.rb | 25 ------------------------- test/test_aozora2html.rb | 1 - test/test_dakuten_katakana_tag.rb | 25 ------------------------- 5 files changed, 65 deletions(-) delete mode 100644 lib/aozora2html/tag/dakuten_katakana.rb delete mode 100644 test/test_dakuten_katakana_tag.rb diff --git a/lib/aozora2html.rb b/lib/aozora2html.rb index 61b06f4..610fb7b 100644 --- a/lib/aozora2html.rb +++ b/lib/aozora2html.rb @@ -692,8 +692,6 @@ def dispatch_aozora_command nil elsif command.match?(PAT_REF) exec_frontref_command(command) - elsif command.match?(/1-7-8[2345]/) - apply_dakuten_katakana(command) elsif command.match?(PAT_KAERITEN) Aozora2Html::Tag::Kaeriten.new(self, command) elsif command.match?(PAT_OKURIGANA) @@ -1189,17 +1187,6 @@ def exec_style(targets, command) end end - def apply_dakuten_katakana(command) - n = command.match(/1-7-8([2345])/).to_a[1] - frontref = DAKUTEN_KATAKANA_TABLE[n] - found = search_front_reference(frontref) - if found - Aozora2Html::Tag::DakutenKatakana.new(self, n, found.join, gaiji_dir: @gaiji_dir) - else - apply_rest_notes(command) - end - end - # くの字点の処理 # # くの字点は現状そのまま出力するのでフッタの「表記について」で出力するかどうかのフラグ処理だけ行う diff --git a/lib/aozora2html/tag.rb b/lib/aozora2html/tag.rb index 3b58e23..6ed2648 100644 --- a/lib/aozora2html/tag.rb +++ b/lib/aozora2html/tag.rb @@ -34,7 +34,6 @@ require_relative 'tag/inline_caption' require_relative 'tag/inline_font_size' require_relative 'tag/decorate' -require_relative 'tag/dakuten_katakana' require_relative 'tag/dir' require_relative 'tag/img' diff --git a/lib/aozora2html/tag/dakuten_katakana.rb b/lib/aozora2html/tag/dakuten_katakana.rb deleted file mode 100644 index c822155..0000000 --- a/lib/aozora2html/tag/dakuten_katakana.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class Aozora2Html - class Tag - # 濁点つきカタカナ用 - class DakutenKatakana < Aozora2Html::Tag::Inline - def initialize(parser, num, katakana, gaiji_dir:) - @n = num - @katakana = katakana - @gaiji_dir = gaiji_dir - super - end - - def char_type - :katakana - end - - using StringRefinements - - def to_s - "\""" - end - end - end -end diff --git a/test/test_aozora2html.rb b/test/test_aozora2html.rb index 8592a5a..8b14a54 100644 --- a/test/test_aozora2html.rb +++ b/test/test_aozora2html.rb @@ -94,7 +94,6 @@ def test_char_type assert_equal :hankaku, Aozora2Html::Tag::Accent.new(nil, 123, 'abc', gaiji_dir: nil).char_type assert_equal :else, Aozora2Html::Tag::Okurigana.new(nil, 'abc').char_type assert_equal :else, Aozora2Html::Tag::InlineKeigakomi.new(nil, 'abc').char_type - assert_equal :katakana, Aozora2Html::Tag::DakutenKatakana.new(nil, 1, 'abc', gaiji_dir: nil).char_type assert_equal :hiragana, 'あ'.to_sjis.char_type assert_equal :hiragana, 'っ'.to_sjis.char_type diff --git a/test/test_dakuten_katakana_tag.rb b/test/test_dakuten_katakana_tag.rb deleted file mode 100644 index 94995fd..0000000 --- a/test/test_dakuten_katakana_tag.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' -require 'aozora2html' - -class DakutenKatakanaTagTest < Test::Unit::TestCase - def setup - @parser = Object.new - @gaiji_dir = 'g_dir' - stub(@parser).block_allowed_context? { true } - end - - using Aozora2Html::StringRefinements - - def test_dakuten_katakana_new - tag = Aozora2Html::Tag::DakutenKatakana.new(@parser, 1, 'ア'.to_sjis, gaiji_dir: @gaiji_dir) - assert_equal Aozora2Html::Tag::DakutenKatakana, tag.class - assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline) - end - - def test_to_s - tag = Aozora2Html::Tag::DakutenKatakana.new(@parser, 1, 'ア'.to_sjis, gaiji_dir: @gaiji_dir) - assert_equal '※(濁点付き片仮名「ア」、1-07-81)', tag.to_s.to_utf8 - end -end