Permalink
Browse files

accents may be bold instead of underlining

  • Loading branch information...
1 parent 1b30030 commit b53aacc685a3f33b8cfd6dd4ad1cb11932ea9c0a @igneus committed May 12, 2012
Showing with 23 additions and 4 deletions.
  1. +23 −4 nastroje/psalmpreprocessor.rb
@@ -188,12 +188,23 @@ def initialize(io)
end
class UnderlineAccentsOutputStrategy < Strategy
- def initialize(io, first_halfverse=2, second_halfverse=2, flex=1)
+
+ # different style of emphasizing the accentuated syllable
+ ACCENT_STYLES = {
+ :underline => ["\\underline{", "}"],
+ :bold => ["\\textbf{", "}"]
+ }
+
+ def initialize(io, first_halfverse=2, second_halfverse=2, flex=1, style=:underline)
super(io)
@first_hv = first_halfverse
@second_hv = second_halfverse
@flex = flex
+ @style = style
+ @emphopen = ACCENT_STYLES[@style][0]
+ @emphclose = ACCENT_STYLES[@style][1]
+
@accent_error = false # place for second 'return value'
# of #underline_last_accent
end
@@ -238,9 +249,9 @@ def underline_last_accent(str)
@accent_error = false
s = str
i = s.rindex "["
- s[i] = "\\underline{" if i
+ s[i] = @emphopen if i
j = s.rindex "]"
- s[j] = "}" if j
+ s[j] = @emphclose if j
if (!i && j) || (i && !j) then
@accent_error = "Non-complete pair of square brackets on line '#{s}'"
@@ -623,6 +634,7 @@ def count_accents(s)
setup = {
:accents => [2,2],
+ :accent_style => :underline,
:has_title => true,
:title_pattern => nil,
:no_formatting => false,
@@ -653,6 +665,13 @@ def count_accents(s)
setup[:accents][1] = a2.to_i
end
end
+ opts.on "-s", "--accents-style SYM", "underline (default) | bold" do |s|
+ sym = s.to_sym
+ unless UnderlineAccentsOutputStrategy::ACCENT_STYLES.include? sym
+ raise "Unknown style '#{sym}'"
+ end
+ setup[:accent_style] = sym
+ end
opts.on "-t", "--no-title", "Don't consider the first line to contain a psalm title" do
setup[:has_title] = false
end
@@ -745,7 +764,7 @@ def output_procedure(input, fwn, setup)
output = NovyDvurNewlinesOutputStrategy.new output
end
- output = UnderlineAccentsOutputStrategy.new output, setup[:accents][0], setup[:accents][1]
+ output = UnderlineAccentsOutputStrategy.new output, setup[:accents][0], setup[:accents][1], 1, setup[:accent_style]
output = BreakableAccentsOutputStrategy.new output

0 comments on commit b53aacc

Please sign in to comment.