lib/docbookrx/docbook_visitor.rb
# transfer node type constants from Nokogiri
transfer node type constants from Nokogiri
transfer node type constants from Nokogiri
def visit_text node
    in_para = PARA_TAG_NAMES.include?(node.parent.name) || node.parent.name == 'phrase'
    unless node.text.rstrip.empty?
      text = node.text
      if in_para
        leading_space_match = text.match LeadingSpaceRx
        text = strip_whitespace text
        is_first = !node.previous_element
        if is_first
          text = text.lstrip
        elsif leading_space_match && !!(text !~ LeadingSpaceRx)
          if @lines[-1] == "----" || @lines[-1] == "====" 
            text = %(#{leading_space_match[0]}#{text})
          elsif (node_prev = node.previous) &&
                ! ( node_prev.name == "para" || node_prev.name == "text" ) &&
                ( (lines.last.end_with? " ") || (lines.last.end_with? "\n") || lines.last.empty? )
          else
            text = %( #{text})
          end
        end
        if @sentence_per_line
          text = text.gsub(/(?:^|\b)\.[[:blank:]]+(?!\Z)/, %(.#{EOL}))
        end
      end
      if @in_table
        text = text.gsub(/\|/, '\|')
      end
      if ! @nested_formatting.empty?
        if text.start_with? '_','*','+','`','#'
          text = '\\' + text
        end
      end
      if ( @lines[-1].empty? ) && ( text.start_with? '.' )
        text = text.sub( /\A(\.+)/, "$$\\1$$" )
      end
      readd_space = text.end_with? " ","\n"
      if @last_added_was_special
        text = "\n" + text.rstrip
      else
        text.rstrip!
      end
      text = text + " " if readd_space
      append_text text, true
    end
    false
  end
def visit_text node in_para = PARA_TAG_NAMES . include? ( node . parent . name ) || node . parent . name == 'phrase' unless node . text . rstrip . empty? text = node . text if in_para leading_space_match = text . match LeadingSpaceRx text = strip_whitespace text is_first = ! node . previous_element if is_first text = text . lstrip elsif leading_space_match && ! ! ( text !~ LeadingSpaceRx ) if @lines [ - 1 ] == "----" || @lines [ - 1 ] == "====" text = %(#{leading_space_match[0]}#{text}) elsif ( node_prev = node . previous ) && ! ( node_prev . name == "para" || node_prev . name == "text" ) && ( ( lines . last . end_with? " " ) || ( lines . last . end_with? "\n" ) || lines . last . empty? ) else text = %( #{text}) end end if @sentence_per_line text = text . gsub ( / (?:^| \b ) \. [[:blank:]]+(?! \Z ) / , %(.#{EOL}) ) end end if @in_table text = text . gsub ( / \| / , '\|' ) end if ! @nested_formatting . empty? if text . start_with? '_' , '*' , '+' , '`' , '#' text = '\\' + text end end if ( @lines [ - 1 ] . empty? ) && ( text . start_with? '.' ) text = text . sub ( / \A ( \. +) / , "$$\\1$$" ) end readd_space = text . end_with? " " , "\n" if @last_added_was_special text = "\n" + text . rstrip else text . rstrip! end text = text + " " if readd_space append_text text , true end false end
transfer node type constants from Nokogiri
transfer node type constants from Nokogiri
# drop text if empty unless we're processing a paragraph # strips surrounding endlines and indentation on normal paragraphs # TODO factor out this whitespace processing # no leading space before text # FIXME sentence-per-line logic should be applied at paragraph block level only # FIXME move regexp to constant # escape |'s in table cell text
node
<not_specific>