Sha256: af3ea03f96f2ad51033958d0eff510039f0bfe7d8883007f875d29fb0f463dbb

Contents?: true

Size: 1.83 KB

Versions: 87

Compression:

Stored size: 1.83 KB

Contents

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

#
# 対象小説情報
# タイトル: 魔剣ゾルディの女主人公とっかえひっかえ成長記録
# 作者: 木原ゆう
# URL: http://ncode.syosetu.com/n2525bs/
#
converter "n2525bs 魔剣ゾルディの女主人公とっかえひっかえ成長記録" 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

87 entries across 87 versions & 1 rubygems

Version Path
narou-3.9.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.9.0 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.8.2 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.8.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.8.0 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.7.2 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.7.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.7.0 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.6.0 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.5.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.5.0.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.5.0 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.8 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.7.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.7 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.6.1 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.6 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.5 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.3 preset/ncode.syosetu.com/n2525bs/converter.rb
narou-3.4.2 preset/ncode.syosetu.com/n2525bs/converter.rb