Method: ConverterBase#convert_novel_rule
- Defined in:
- lib/converterbase.rb
#convert_novel_rule(data) ⇒ Object
小説のルールに沿うように変換
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/converterbase.rb', line 488 def convert_novel_rule(data) # 括弧の閉じの直前の句点を消す data.gsub!(/。([」』)])/, "\\1") # 原則偶数個を1セットで使うべき文字を偶数個に補正 # MEMO:(―も偶数個セットにするべきだが、記号的な意味で使われる場合もあるので無視) %w(… ‥).each do |target| data.gsub!(/#{target}+/) do |match| len = match.length len += 1 if len.odd? target * len end end # たまに見かける誤字対策 data.gsub!(/。 /, "。") end |