Class: Pslm::LatexOutputter::LettrineFormatter
- Defined in:
- lib/pslm/latexoutputter.rb
Overview
formats the first word of the first verse as a lettrine
Instance Method Summary collapse
-
#initialize(options) ⇒ LettrineFormatter
constructor
A new instance of LettrineFormatter.
- #verse_format(text, verse, strophe, psalm) ⇒ Object
Methods inherited from Formatter
format, #part_format, #psalm_format, #strophe_format, #syllable_format, #word_format
Constructor Details
#initialize(options) ⇒ LettrineFormatter
Returns a new instance of LettrineFormatter.
355 356 357 358 359 360 361 362 |
# File 'lib/pslm/latexoutputter.rb', line 355 def initialize() super() @digraphs = [] if @options and @options[:digraphs] then @digraphs = @options[:digraphs] end @done = false end |
Instance Method Details
#verse_format(text, verse, strophe, psalm) ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/pslm/latexoutputter.rb', line 364 def verse_format(text, verse, strophe, psalm) return text if @done @done = true return text.sub(/^([^\s]+)/) { initial_size = 1 digraph = @digraphs.find {|d| text.downcase.start_with? d } if digraph then initial_size = digraph.size end '\lettrine{'+$1[0...initial_size].upcase+'}{'+$1[initial_size..-1]+'}' } end |