Skip to content

Commit

Permalink
Remove deprecated parameters, change default value of some parameters. (
Browse files Browse the repository at this point in the history
#547)

unify config parameters to ReVIEW::Configure.values.
remove 'hdnumberingmode' parameter. use --level option.
remove 'deprecated-blocklines' parameter.
change IDGXML 'nolf' parameter from 'false' to 'true'.
  • Loading branch information
kmuto authored and takahashim committed Apr 15, 2016
1 parent 0c74ff1 commit 6b1fb7d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 129 deletions.
24 changes: 1 addition & 23 deletions bin/review-compile
Expand Up @@ -45,20 +45,6 @@ def _main
output_filename = nil

config = ReVIEW::Configure.values
config.merge!({
"secnolevel" => 2, # for IDGXML and HTML
"tableopt" => nil, # for IDGXML
"nolf" => nil, # for IDGXML
"chapref" => nil, # for IDGXML
"structuredxml" => nil, # for IDGXML
"stylesheet" => [], # for HTML
"mathml" => nil, # for HTML
"language" => "ja", # for HTML
"deprecated-blocklines" => nil,
"footnotetext" => false,
"htmlext" => "html",
"htmlversion" => 4,
})

opts = OptionParser.new
opts.version = ReVIEW::VERSION
Expand All @@ -71,13 +57,7 @@ def _main
opts.on('--structuredxml', 'Produce XML with structured sections. (idgxml)') { config["structuredxml"] = true }
opts.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl| config["tableopt"] = tbl }
opts.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') { config["listinfo"] = true }
opts.on('--chapref="before,middle,after"', 'Chapref decoration.') {|cdec| config["chapref"] = cdec }
opts.on('--subdirmode', 'Use chapter/id.ext path style to find images. (deprecated)') do
STDERR.puts "Warning: --subdirmode is deprecated. Images are automatically detected."
end
opts.on('--singledirmode', 'Use id.ext path style to find images. (deprecated)') do
STDERR.puts "Warning: --singledirmode is deprecated. Images are automatically detected."
end
opts.on('--chapref="before,middle,after"', 'Chapref decoration. (idgxml)') {|cdec| config["chapref"] = cdec }
opts.on('--chapterlink', 'make chapref hyperlink') { config["chapterlink"] = true }
opts.on('--stylesheet=file', 'Stylesheet file for HTML (comma separated)') {|files| config["stylesheet"] = files.split(/\s*,\s*/) }
opts.on('--mathml', 'Use MathML for TeX equation in HTML') do
Expand All @@ -91,8 +71,6 @@ def _main
v = v.to_i
config["epubversion"] = v if v == 2 || v == 3
end
opts.on('--hdnumberingmode', 'Output numbering headlines. (deprecated)') { config["hdnumberingmode"] = true }
opts.on('--deprecated-blocklines', 'Disable paragrahs in block tags. Treat physical line as a paragraph. (deprecated)') { config["deprecated-blocklines"] = true }
opts.on('--target=FMT', 'Target format.') {|fmt| target = fmt } unless target
opts.on('--footnotetext',
'Use footnotetext and footnotemark instead of footnote (latex)') {
Expand Down
4 changes: 0 additions & 4 deletions lib/review/compiler.rb
Expand Up @@ -296,10 +296,6 @@ def compile_headline(line)
@headline_indexs[index] = 0 if @headline_indexs[index].nil?
@headline_indexs[index] += 1
close_current_tagged_section(level)
if @chapter.book.config["hdnumberingmode"]
caption = @chapter.on_CHAPS? ? "#{@headline_indexs.join('.')} #{caption}" : caption
warn "--hdnumberingmode is deprecated. use --level option."
end
@strategy.headline level, label, caption
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/review/configure.rb
Expand Up @@ -53,6 +53,12 @@ def self.values
"bib_file" => "bib.re",
"colophon_order" => %w(aut csl trl dsr ill cov edt pbl contact prt),
"externallink" => true,
"tableopt" => nil, # for IDGXML
"listinfo" => nil, # for IDGXML
"nolf" => true, # for IDGXML
"chapref" => nil, # for IDGXML
"structuredxml" => nil, # for IDGXML
"footnotetext" => nil, # for LaTeX
]
conf.maker = nil
conf
Expand Down
64 changes: 14 additions & 50 deletions lib/review/htmlbuilder.rb
Expand Up @@ -266,12 +266,8 @@ def captionblock(type, lines, caption)
unless caption.nil?
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
end
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n")
else
lines.each {|l| puts "<p>#{l}</p>" }
end
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n")
puts '</div>'
end

Expand Down Expand Up @@ -399,12 +395,8 @@ def parasep
end

def read(lines)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts %Q[<div class="lead">\n#{blocked_lines.join("\n")}\n</div>]
else
puts %Q[<p class="lead">\n#{lines.join("\n")}\n</p>]
end
blocked_lines = split_paragraph(lines)
puts %Q[<div class="lead">\n#{blocked_lines.join("\n")}\n</div>]
end

alias_method :lead, :read
Expand Down Expand Up @@ -543,42 +535,22 @@ def quotedlist(lines, css_class)
private :quotedlist

def quote(lines)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "<blockquote>#{blocked_lines.join("\n")}</blockquote>"
else
puts "<blockquote><pre>#{lines.join("\n")}</pre></blockquote>"
end
blocked_lines = split_paragraph(lines)
puts "<blockquote>#{blocked_lines.join("\n")}</blockquote>"
end

def doorquote(lines, ref)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts %Q[<blockquote style="text-align:right;">]
puts "#{blocked_lines.join("\n")}"
puts %Q[<p>#{ref}より</p>]
puts %Q[</blockquote>]
else
puts <<-QUOTE
<blockquote style="text-align:right;">
<pre>#{lines.join("\n")}
#{ref}より</pre>
</blockquote>
QUOTE
end
blocked_lines = split_paragraph(lines)
puts %Q[<blockquote style="text-align:right;">]
puts "#{blocked_lines.join("\n")}"
puts %Q[<p>#{ref}より</p>]
puts %Q[</blockquote>]
end

def talk(lines)
puts %Q[<div class="talk">]
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join("\n")}"
else
print '<pre>'
puts "#{lines.join("\n")}"
puts '</pre>'
end
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join("\n")}"
puts '</div>'
end

Expand Down Expand Up @@ -1168,15 +1140,7 @@ def compile_href(url, label)
end

def flushright(lines)
if @book.config["deprecated-blocklines"].nil?
puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"flushright\">")
else
puts %Q[<div style="text-align:right;">]
print %Q[<pre class="flushright">]
lines.each {|line| puts detab(line) }
puts '</pre>'
puts '</div>'
end
puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"flushright\">")
end

def centering(lines)
Expand Down
28 changes: 6 additions & 22 deletions lib/review/idgxmlbuilder.rb
Expand Up @@ -301,11 +301,7 @@ def paragraph(lines)
end

def read(lines)
if @book.config["deprecated-blocklines"].nil?
puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
else
puts %Q[<p aid:pstyle="lead">#{lines.join}</p>]
end
puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
end

alias_method :lead, :read
Expand Down Expand Up @@ -420,12 +416,8 @@ def quotedlist(lines, css_class, caption)
private :quotedlist

def quote(lines)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "<quote>#{blocked_lines.join("")}</quote>"
else
puts "<quote>#{lines.join("\n")}</quote>"
end
blocked_lines = split_paragraph(lines)
puts "<quote>#{blocked_lines.join("")}</quote>"
end

def inline_table(id)
Expand Down Expand Up @@ -903,11 +895,7 @@ def sup_end(level)
end

def flushright(lines)
if @book.config["deprecated-blocklines"].nil?
puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
else
puts "<p align='right'>#{lines.join("\n")}</p>"
end
puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
end

def centering(lines)
Expand All @@ -918,12 +906,8 @@ def captionblock(type, lines, caption, specialstyle = nil)
print "<#{type}>"
style = specialstyle.nil? ? "#{type}-title" : specialstyle
puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join}</#{type}>"
else
puts "#{lines.join("\n")}</#{type}>"
end
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join}</#{type}>"
end

def note(lines, caption = nil)
Expand Down
20 changes: 4 additions & 16 deletions lib/review/latexbuilder.rb
Expand Up @@ -131,14 +131,8 @@ def captionblock(type, lines, caption)
puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n"
end

if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n\n")
else
lines.each do |line|
puts line
end
end
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n\n")

puts "\\end{reviewminicolumn}\n"
end
Expand Down Expand Up @@ -597,14 +591,8 @@ def texequation(lines)
def latex_block(type, lines)
blank
puts macro('begin', type)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n\n")
else
lines.each do |line|
puts line
end
end
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n\n")
puts macro('end', type)
blank
end
Expand Down
14 changes: 0 additions & 14 deletions test/test_idgxmlbuilder.rb
Expand Up @@ -168,13 +168,6 @@ def test_quote
assert_equal %Q|<quote><p>foobar</p><p>buz</p></quote>|, actual
end

def test_quote_deprecated
@book.config["deprecated-blocklines"] = true
actual = compile_block("//quote{\nfoo\n\nbuz\n//}\n")
@book.config["deprecated-blocklines"] = nil
assert_equal %Q|<quote>foo\n\nbuz</quote>|, actual
end

def test_note
actual = compile_block("//note[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q|<note><title aid:pstyle='note-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, actual
Expand All @@ -190,13 +183,6 @@ def test_term
assert_equal %Q|<term><p>test1test1.5</p><p>test<i>2</i></p></term>|, actual
end

def test_term_deprecated
@book.config["deprecated-blocklines"] = true
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
@book.config["deprecated-blocklines"] = nil
assert_equal %Q|<term>test1\ntest1.5\n\ntest<i>2</i></term>|, actual
end

def test_notice
actual = compile_block("//notice[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q|<notice-t><title aid:pstyle='notice-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></notice-t>|, actual
Expand Down

0 comments on commit 6b1fb7d

Please sign in to comment.