Sha256: ed1a0db24e7a20ddb1ec86fbcea62096b3a5619af86b99ac0cb03e7d3136c147

Contents?: true

Size: 1.9 KB

Versions: 27

Compression:

Stored size: 1.9 KB

Contents

# -*- coding: utf-8 -*-

#
# 対象小説情報
# タイトル: 魔剣ゾルディの女主人公とっかえひっかえ成長記録
# 作者: 木原ゆう
# URL: http://ncode.syosetu.com/n2525bs/
#
converter "魔剣ゾルディの女主人公とっかえひっかえ成長記録" do
  def before(io, text_type)
    super
    io.string.gsub!(/(\/{2,})/) do
      if $1.length == 3
        "❤"
      else
        "❤❤"
      end
    end
    io
  end

  def is_parameter_block?(line)
    !!(line =~ /={2,}/)
  end

  def in_parameter_block?(line)
    unless @in_parameter_block
      if is_parameter_block?(line)
        @in_parameter_block = true
        return true
      end
    end
    return false
  end

  def out_parameter_block?(line)
    if @in_parameter_block
      if is_parameter_block?(line)
        @in_parameter_block = false
        return true
      end
    end
    return false
  end

  def after(io, text_type)
    return io unless text_type == "body"
    write_fp = StringIO.new
    non_close_parameter = false
    @in_parameter_block = false
    io.each do |line|
      line.rstrip!
      if in_parameter_block?(line)
        non_close_parameter = true
        write_fp.puts("[#ここからパラメーター]")
        next
      end
      if out_parameter_block?(line)
        non_close_parameter = false
        write_fp.puts("[#ここでパラメーター終わり]")
        next
      end
      write_fp.puts(line)
    end
    if non_close_parameter
      write_fp.puts("[#ここでパラメーター終わり]")
    end
    data = write_fp.string
    data.lstrip!
    data.gsub!(/\n\n([#ここからパラメーター])/m, "\n\\1")
    data.gsub!(/([#ここでパラメーター終わり]\n\n)/m, "[#ここでパラメーター終わり]\n")
    data.gsub!(" ❤", "❤")
    write_fp
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
narou-1.5.9 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.8 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.7.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.7 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.6.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.6 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.5.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.5 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.4 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.3 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.2.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.2 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.0.2 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.0.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.5.0 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.4.6 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.4.5 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.4.4 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-1.4.3 preset/ncode.syosetu.com/n2525bs/converter.rb