Sha256: a23e94a9cacba243cf32e3375881a2d2fdbab6af943981a1912ec0f6f935b2e3
Contents?: true
Size: 894 Bytes
Versions: 1
Compression:
Stored size: 894 Bytes
Contents
require 'ssmd/processors' require 'rexml/document' module SSMD class Converter attr_reader :input def initialize(input) @input = input end def convert result = processors.inject(input) do |text, processor| process processor.new, text end "<speak>#{result.strip}</speak>" end def strip doc = ::REXML::Document.new input xml_text doc.root end def xml_text(node) if node.is_a? REXML::Text node.to_s else node.children.map { |c| xml_text c }.join end end def processors p = SSMD::Processors [ p::EmphasisProcessor, p::AnnotationProcessor, p::MarkProcessor ] end def process(processor, input) if processor.matches? input process processor, processor.substitute(input) else input end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ssmd-0.2.0 | lib/ssmd/converter.rb |