Module: Lydown::Rendering::Markup

Defined in:
lib/lydown/rendering/markup.rb

Class Method Summary collapse

Class Method Details

.convert(str) ⇒ Object



3
4
5
# File 'lib/lydown/rendering/markup.rb', line 3

def self.convert(str)
  convert_line_breaks(str)
end

.convert_line_breaks(str) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/lydown/rendering/markup.rb', line 14

def self.convert_line_breaks(str)
  if str =~/\n/
    lines = str.lines.map {|s| "\\fill-line { \"#{s.chomp}\" }"}
    "\\markup \\column { #{lines.join(' ')} }"
  else
    "\"#{str}\""
  end
end

.convert_styling(str) ⇒ Object



7
8
9
10
11
12
# File 'lib/lydown/rendering/markup.rb', line 7

def self.convert_styling(str)
  str.
    gsub(/__([^_]+)__/) {|m| "\\bold {#{$1} }" }.
    gsub(/_([^_]+)_/) {|m| "\\italic {#{$1} }" }
    gsub(/\^([^\^]+)\^/) {|m| "\\smallCaps {#{$1} }" }
end