lib/docbookrx/docbook_visitor.rb
# transfer node type constants from Nokogiri
transfer node type constants from Nokogiri
transfer node type constants from Nokogiri
def process_ui node
    name = node.name
    if name == 'guilabel' && (next_node = node.next) &&
        next_node.type == ENTITY_REF_NODE && ['rarr', 'gt'].include?(next_node.name)
      name = 'guimenu'
    end
    case name
    when 'menuchoice'
      items = node.children.map {|n|
        if (n.type == ELEMENT_NODE) && ['guimenu', 'guisubmenu', 'guimenuitem'].include?(n.name)
          n.instance_variable_set :@skip, true
          n.text
        end
      }.compact
      append_text %(menu:#{items[0]}[#{items[1..-1] * ' > '}])
    when 'guimenu'
      append_text %(menu:#{node.text}[])
    when 'guibutton'
      append_text %(btn:[#{node.text}])
    when 'guilabel'
      append_text %([label]##{node.text}#)
    when 'keycap'
      append_text %(kbd:[#{node.text}])
    end
    false
  end
def process_ui node name = node . name if name == 'guilabel' && ( next_node = node . next ) && next_node . type == ENTITY_REF_NODE && [ 'rarr' , 'gt' ] . include? ( next_node . name ) name = 'guimenu' end case name when 'menuchoice' items = node . children . map { | n | if ( n . type == ELEMENT_NODE ) && [ 'guimenu' , 'guisubmenu' , 'guimenuitem' ] . include? ( n . name ) n . instance_variable_set :@skip , true n . text end } . compact append_text %(menu:#{items[0]}[#{items[1..-1] * ' > '}]) when 'guimenu' append_text %(menu:#{node.text}[]) when 'guibutton' append_text %(btn:[#{node.text}]) when 'guilabel' append_text %([label]##{node.text}#) when 'keycap' append_text %(kbd:[#{node.text}]) end false end
transfer node type constants from Nokogiri
transfer node type constants from Nokogiri
# ex. <menuchoice><guimenu>System</guimenu><guisubmenu>Documentation</guisubmenu></menuchoice> # ex. <guimenu>Files</guimenu> (top-level) # QUESTION when is this needed?? #items = [] #while (node = node.next) && ((node.type == ENTITY_REF_NODE && ['rarr', 'gt'].include?(node.name)) || #  (node.type == ELEMENT_NODE && ['guimenu', 'guilabel'].include?(node.name))) #  if node.type == ELEMENT_NODE #    items << node.text #  end #  node.instance_variable_set :@skip, true #end #append_text %([#{items * ' > '}]) 
node
<not_specific>