module DocXify module Element class Paragraph < Base attr_accessor :text, :font, :size, :color, :background, :align, :inline_styling, :tab_stops_cm def initialize(text, options = {}) super() @document = options[:document] @text = text @font = options[:font] || @document&.font || "Times New Roman" @size = options[:size] || @document&.size || 14 @color = options[:color] || @document&.color || "#000000" @highlight = options[:highlight] || false @background = options[:background] if options[:background] @background ||= @document&.background if @document&.background @align = options[:align] || :left @inline_styling = options[:inline_styling] || true @tab_stops_cm = options[:tab_stops_cm] || [] end def to_s(_container = nil) nodes = if @inline_styling parse_simple_html(@text) else [@text] end xml = "" xml << <<~XML XML xml << "" xml << <<~XML #{"" if @highlight} XML nodes.each do |node| xml << "#{node}" end xml << "" end end end end