class DoctorNinja::Parsers::Paragraph

Public Class Methods

applicable_to?(node) click to toggle source
# File lib/doctor_ninja/parsers/paragraph.rb, line 10
def self.applicable_to?(node)
  node.name == "p" && node.xpath("./w:pPr/w:numPr").length == 0
end

Public Instance Methods

parse() click to toggle source
# File lib/doctor_ninja/parsers/paragraph.rb, line 14
def parse
  @context[:has_text] = false
  content = parse_children
  attrs = {}
  style = {}
  style["text-align"] = "center" unless @context[:has_text]

  attrs["style"] = style.map{|k,v| "#{k}:#{v};"}.join(" ") if style.length > 0

  attrs = attrs.map{|k,v| " #{k}=\"#{v}\""}.join("")
  "<#{tag}#{attrs}>#{content}</#{tag}>"
end
style() click to toggle source
# File lib/doctor_ninja/parsers/paragraph.rb, line 33
def style
  @node.xpath("./w:pPr/w:pStyle").first.attributes["val"].value 
rescue
  nil
end
tag() click to toggle source
# File lib/doctor_ninja/parsers/paragraph.rb, line 27
def tag
  style == nil ? "p" : @@style_map.select do |k,v|
    k =~ style
  end.first[1]
end