Sha256: 292023895e9ac6e4916367456bd0996c31a86d9d9a057da2bd040805ce24b750
Contents?: true
Size: 846 Bytes
Versions: 4
Compression:
Stored size: 846 Bytes
Contents
require 'arti_mark/parser.kpeg' module ArtiMark class Parser def create_item(type, command, children = [], raw: nil) children[0].sub!(/^[[:space:]]+/, '') if !children.nil? && children[0].is_a?(String) item = {:type => type, :children => children, :raw_text => raw }.merge command || {} item[:args] ||= [] item[:named_args] = Hash[*(item[:args].select { |x| x.include?(':') }.map { |x| v = x.split(':', 2); [v[0].strip.to_sym, v[1]]}.flatten)] item end def parse_text(content) content.inject([]) do |result, item| if item.is_a? String s = result.last if s.is_a? String result.pop else s = '' end result.push s + item else result.push item end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
arti_mark-0.1.beta5 | lib/arti_mark/parser.rb |
arti_mark-0.1.beta3 | lib/arti_mark/parser.rb |
arti_mark-0.1.beta2 | lib/arti_mark/parser.rb |
arti_mark-0.1.beta1 | lib/arti_mark/parser.rb |