Method: IsoDoc::PresentationXMLConvert#source_lex

Defined in:
lib/isodoc/presentation_function/sourcecode.rb

#source_lex(elem) ⇒ Object



143
144
145
146
147
148
149
150
# File 'lib/isodoc/presentation_function/sourcecode.rb', line 143

def source_lex(elem)
  lexer = (Rouge::Lexer.find(elem["lang"] || "plaintext") ||
   Rouge::Lexer.find("plaintext"))
  l = Rouge::Lexers::Escape.new(start: "{^^{", end: "}^^}", lang: lexer)
  source = to_xml(elem.children).gsub(/</, "{^^{<").gsub(/>/, ">}^^}")
  l.lang.reset!
  l.lex(@c.decode(source))
end