diff --git a/lib/aozora2html/header.rb b/lib/aozora2html/header.rb index 5bda02b..a9cb5de 100644 --- a/lib/aozora2html/header.rb +++ b/lib/aozora2html/header.rb @@ -96,7 +96,7 @@ def build_header_info header_info[:subtitle] = @header[2] header_info[:author] = @header[3] if process_person(@header[4], header_info) == :author - raise Aozora2Html::Error.new("parser encounted author twice") + raise Aozora2Html::Error, "parser encounted author twice" end when 6 header_info[:original_title] = @header[1] @@ -104,7 +104,7 @@ def build_header_info header_info[:original_subtitle] = @header[3] header_info[:author] = @header[4] if process_person(@header[5], header_info) == :author - raise Aozora2Html::Error.new("parser encounted author twice") + raise Aozora2Html::Error, "parser encounted author twice" end end header_info diff --git a/lib/aozora2html/i18n.rb b/lib/aozora2html/i18n.rb index 5d7e16b..13c64e8 100644 --- a/lib/aozora2html/i18n.rb +++ b/lib/aozora2html/i18n.rb @@ -6,7 +6,8 @@ class I18n :undefined_header => "未定義な見出しです", :use_crlf => "改行コードを、「CR+LF」にあらためてください", :error_stop => "エラー(%d行目):%s. \r\n処理を停止します", - :invalid_font_size => "文字サイズの指定が不正です" + :invalid_font_size => "文字サイズの指定が不正です", + :unsupported_ruby => "サポートされていない複雑なルビ付けです" } def self.t(msg, *args) diff --git a/lib/aozora2html/tag.rb b/lib/aozora2html/tag.rb index 073a7a3..09b4ff0 100644 --- a/lib/aozora2html/tag.rb +++ b/lib/aozora2html/tag.rb @@ -49,7 +49,7 @@ def char_type end def syntax_error - raise Aozora2Html::Error.new(I18n.t(:tag_syntax_error)) + raise Aozora2Html::Error, I18n.t(:tag_syntax_error) end end end diff --git a/lib/aozora2html/tag/ruby.rb b/lib/aozora2html/tag/ruby.rb index 4cd9725..d356fe3 100644 --- a/lib/aozora2html/tag/ruby.rb +++ b/lib/aozora2html/tag/ruby.rb @@ -37,7 +37,7 @@ def to_s if @under_ruby.is_a?(Array) and @under_ruby.length > 0 # cell is used, but two way cell is not supported if @rbspan - raise Aozora2Html::Error.new("サポートされていない複雑なルビ付けです") + raise Aozora2Html::Error, I18n.t(:unsupported_ruby) else @rbspan = @under_ruby.length end diff --git a/lib/aozora2html/utils.rb b/lib/aozora2html/utils.rb index 378b1b3..0052e5e 100644 --- a/lib/aozora2html/utils.rb +++ b/lib/aozora2html/utils.rb @@ -38,7 +38,7 @@ def create_midashi_tag(size) elsif size.match(SIZE_LARGE) "h3" else - raise Aozora2Html::Error.new(I18n.t(:undefined_header)) + raise Aozora2Html::Error, I18n.t(:undefined_header) end end module_function :create_midashi_tag @@ -73,7 +73,7 @@ def create_midashi_class(type, tag) "mado-o-midashi" end else - raise Aozora2Html::Error.new(I18n.t(:undefined_header)) + raise Aozora2Html::Error, I18n.t(:undefined_header) end end module_function :create_midashi_class diff --git a/lib/t2hs.rb b/lib/t2hs.rb index d8eb0be..0fec8cf 100755 --- a/lib/t2hs.rb +++ b/lib/t2hs.rb @@ -230,14 +230,14 @@ def implicit_close(type) def ensure_close if n = @indent_stack.last - raise Aozora2Html::Error.new("#{convert_indent_type(n)}ɖ{I܂") + raise Aozora2Html::Error, "#{convert_indent_type(n)}ɖ{I܂" end end def explicit_close(type) n = check_close_match(type) if n - raise Aozora2Html::Error.new("#{n}‚悤Ƃ܂A#{n}ł͂܂") + raise Aozora2Html::Error, "#{n}‚悤Ƃ܂A#{n}ł͂܂" end if tag = @tag_stack.pop push_chars(tag) @@ -258,7 +258,7 @@ def parse when :tail parse_tail else - Aozora2Html::Error.new("encount undefined condition") + raise Aozora2Html::Error, "encount undefined condition" end end @@ -495,7 +495,7 @@ def terpri?(buf) # def general_output if @style_stack.last - raise Aozora2Html::Error.new("#{@style_stack.last_command}ɉs܂Bs܂vfɂ̓ubN\LpĂ") + raise Aozora2Html::Error, "#{@style_stack.last_command}ɉs܂Bs܂vfɂ̓ubN\LpĂ" end # bufferɃCfg^OsȂI if @noprint @@ -1006,7 +1006,7 @@ def exec_inline_end_command(command) elsif @style_stack.last_command.match(encount) push_chars(@style_stack.pop[1]) else - raise Aozora2Html::Error.new("#{encount}I悤Ƃ܂A#{@style_stack.last_command}ł") + raise Aozora2Html::Error, "#{encount}I悤Ƃ܂A#{@style_stack.last_command}ł" end end @@ -1218,26 +1218,26 @@ def rearrange_ruby(targets, upper_ruby, under_ruby = "") [] end if new_upper.length > 1 and new_under.length > 1 - raise Aozora2Html::Error.new("1‚̒P3‚̃r͂‚܂") + raise Aozora2Html::Error, "1‚̒P3‚̃r͂‚܂" end targets.each{|x| if x.is_a?(Aozora2Html::Tag::Ruby) if x.target.is_a?(Array) # inner Aozora2Html::Tag::Ruby is already complex ... give up - raise Aozora2Html::Error.new("ӏ2‚̃r͂‚܂") + raise Aozora2Html::Error, "ӏ2‚̃r͂‚܂" else if x.ruby != "" if new_upper.is_a?(Array) new_upper.push(x.ruby) else - raise Aozora2Html::Error.new("ӏ2‚̃r͂‚܂") + raise Aozora2Html::Error, "ӏ2‚̃r͂‚܂" end else if new_under.is_a?(Array) new_under.push(x.under_ruby) else - raise Aozora2Html::Error.new("ӏ2‚̃r͂‚܂") + raise Aozora2Html::Error, "ӏ2‚̃r͂‚܂" end end new_targets.push(x.target) @@ -1254,12 +1254,12 @@ def rearrange_ruby(targets, upper_ruby, under_ruby = "") if new_under.is_a?(Array) new_under.concat(un) elsif un.to_s.length > 0 - raise Aozora2Html::Error.new("ӏ2‚̃r͂‚܂") + raise Aozora2Html::Error, "ӏ2‚̃r͂‚܂" end if new_upper.is_a?(Array) new_upper.concat(up) elsif up.to_s.length > 0 - raise Aozora2Html::Error.new("ӏ2‚̃r͂‚܂") + raise Aozora2Html::Error, "ӏ2‚̃r͂‚܂" end else new_targets.push(x) @@ -1329,7 +1329,7 @@ def exec_style(targets, command) tag.under_ruby = under tag else - raise Aozora2Html::Error.new("1‚̒P3‚̃r͂‚܂") + raise Aozora2Html::Error, "1‚̒P3‚̃r͂‚܂" end else rearrange_ruby_tag(targets,"",under)