Method: ConverterBase#convert_main
- Defined in:
- lib/converterbase.rb
#convert_main(io) ⇒ Object
変換処理本体
@text_type: 渡されるテキストの種類。
subtitle, introduction, body, postscript, textfile, chapter, story
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 |
# File 'lib/converterbase.rb', line 1293 def convert_main(io) @write_fp = StringIO.new case @text_type when "introduction" return @write_fp if @setting.enable_erase_introduction when "postscript" return @write_fp if @setting.enable_erase_postscript end = nil if @text_type == "textfile" # タイトル・著者名スキップ = io.gets + io.gets data = io.read else data = io.read end reset_member_values convert_for_all_data(data) = nil if @text_type == "textfile" # convert_for_all_data -> replace_narou_tag # で改行化を行わないと正確な改行数は分からない = ProgressBar.new(data.count("\n") + 1) .output(0) end @read_fp = StringIO.new(data) if @text_type == "subtitle" @write_fp.write(data) else @read_fp.each_with_index do |line, i| .output(i) if @request_skip_output_line = false zenkaku_rstrip(line) if @request_insert_blank_next_line outputs unless blank_line?(line) @request_insert_blank_next_line = false @before_line = "" end (line) if @text_type == "textfile" insert_blank_before_line_and_behind_to_special_chapter(line) insert_blank_line_to_border_symbol(line) outputs(line) unless @delay_outputs_buffer.empty? @write_fp.write(@delay_outputs_buffer) @before_line = @delay_outputs_buffer @delay_outputs_buffer = "" else @before_line = line end end if @text_type == "textfile" end @write_fp.rewind data = @write_fp.string if @text_type == "textfile" if @setting. erase_introduction(data) if @setting.enable_erase_introduction erase_postscript(data) if @setting.enable_erase_postscript end if @setting.enable_enchant_midashi enchant_midashi(data) end end rebuild_illust(data) rebuild_url(data) rebuild_english_sentences(data) rebuild_hankaku_num_and_comma(data) rebuild_kome_to_gaiji(data) rebuild_force_indent_special_chapter(data) if @text_type == "body" || @text_type == "textfile" half_indent_bracket(data) auto_indent(data) end # 再構築された文章にルビがふられる可能性を考慮して、 # この位置でルビの処理を行う narou_ruby(data) if @setting.enable_ruby # 三点リーダーの変換は、ルビで圏点として・・・を使っている場合を考慮して、ルビ処理後にする convert_horizontal_ellipsis(data) # ルビ化されなくて残ったギュメを二重山括弧(の外字)に変換 convert_double_angle_quotation_to_gaiji(data) delete_dust_char(data) if data.replace( + data) end data.rstrip! @write_fp ensure if @text_type == "textfile" && .clear end end |