Sha256: 55f4d938b186b387134c240b1db484649179c91e6eaaee1bcb54b80fc37560de
Contents?: true
Size: 1.36 KB
Versions: 8
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true require_relative 'paragraph/paragraph_properties' require_relative 'paragraph/paragraph_run' require_relative 'paragraph/text_field' module OoxmlParser # Class for parsing `p` tags class Paragraph < OOXMLDocumentObject attr_accessor :properties, :runs, :text_field, :formulas # @return [AlternateContent] alternate content data attr_accessor :alternate_content def initialize(runs = [], formulas = [], parent: nil) @runs = runs @formulas = formulas @runs = [] @parent = parent end alias characters runs alias character_style_array runs alias characters= runs= alias character_style_array= runs= # Parse Paragraph object # @param node [Nokogiri::XML:Element] node to parse # @return [Paragraph] result of parsing def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'pPr' @properties = ParagraphProperties.new(parent: self).parse(node_child) when 'fld' @text_field = TextField.new(parent: self).parse(node_child) when 'r' @runs << ParagraphRun.new(parent: self).parse(node_child) when 'AlternateContent' @alternate_content = AlternateContent.new(parent: self).parse(node_child) end end self end end end
Version data entries
8 entries across 8 versions & 1 rubygems