Class: Rulex::Tex::Grammar::Command

Inherits:
CustomNode
  • Object
show all
Defined in:
lib/rulex/tex/node_extensions.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rulex/tex/node_extensions.rb', line 54

def content
  h = {type: :command, name: elements[1].text_value}
  if opts_maybe = elements[2].elements
    opts = []
    opts << opts_maybe[1].text_value

    if opts_kleene_s = opts_maybe[2].elements
      opts += opts_kleene_s.map{|e| e.elements[1].text_value}
    end

    h.merge!(options: opts)
  end
  if args_kleene_s = elements[3]
    h.merge!(arguments: args_kleene_s.elements.map{|e| e.elements[1].text_value}) 
  end

  h
end