lib/review/tocprinter.rb in review-1.6.0 vs lib/review/tocprinter.rb in review-1.7.0
- old
+ new
@@ -11,50 +11,27 @@
# For details of LGPL, see the file "COPYING".
#
require 'review/htmlutils'
require 'review/htmllayout'
-require 'nkf'
module ReVIEW
class TOCPrinter
def TOCPrinter.default_upper_level
- 99 # no one use 99 level nest
+ 99 # no one use 99 level nest
end
def initialize(print_upper, param)
@print_upper = print_upper
@config = param
end
def print?(level)
level <= @print_upper
end
-
- def nkffilter(line)
- inc = ""
- outc = "-w"
- if @config["inencoding"] =~ /^EUC$/
- inc = "-E"
- elsif @config["inencoding"] =~ /^SJIS$/
- inc = "-S"
- elsif @config["inencoding"] =~ /^JIS$/
- inc = "-J"
- end
-
- if @config["outencoding"] =~ /^EUC$/
- outc = "-e"
- elsif @config["outencoding"] =~ /^SJIS$/
- outc = "-s"
- elsif @config["outencoding"] =~ /^JIS$/
- outc = "-j"
- end
-
- NKF.nkf("#{inc} #{outc}", line)
- end
end
class TextTOCPrinter < TOCPrinter
def print_book(book)
@@ -77,26 +54,26 @@
if node.chapter?
vol = node.volume
printf "%3s %3dKB %6dC %5dL %s (%s)\n",
chapnumstr(node.number),
vol.kbytes, vol.chars, vol.lines,
- nkffilter(node.label), node.chapter_id
+ node.label, node.chapter_id
else
printf "%17s %5dL %s\n",
'', node.estimated_lines,
- nkffilter(" #{' ' * (node.level - 1)}#{number} #{node.label}")
+ " #{' ' * (node.level - 1)}#{number} #{node.label}"
end
end
def chapnumstr(n)
n ? sprintf('%2d.', n) : ' '
end
def volume_columns(level, volstr)
cols = ["", "", "", nil]
cols[level - 1] = volstr
- cols[0, 3] # does not display volume of level-4 section
+ cols[0, 3] # does not display volume of level-4 section
end
end
@@ -184,11 +161,11 @@
end
class IDGTOCPrinter < TOCPrinter
def print_book(book)
puts %Q(<?xml version="1.0" encoding="UTF-8"?>)
- puts nkffilter(%Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>)) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには?
+ puts %Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには?
puts %Q(<ul aid:pstyle='ul-partblock'>)
print_children book
puts %Q(</ul></doc>)
end
@@ -206,18 +183,18 @@
def print_node(seq, node)
if node.chapter?
vol = node.volume
printf "<li aid:pstyle='ul-part'>%s</li>\n",
- nkffilter("#{chapnumstr(node.number)}#{node.label}")
+ "#{chapnumstr(node.number)}#{node.label}"
else
printf "<li>%-#{LABEL_LEN}s\n",
- nkffilter(" #{' ' * (node.level - 1)}#{seq} #{node.label}</li>")
+ " #{' ' * (node.level - 1)}#{seq} #{node.label}</li>"
end
end
def chapnumstr(n)
- n ? nkffilter(sprintf('第%d章 ', n)) : ''
+ n ? sprintf('第%d章 ', n) : ''
end
def volume_columns(level, volstr)
cols = ["", "", "", nil]
cols[level - 1] = volstr