Class: Asciidoctor::Standoc::ConceptInlineMacro

Inherits:
Extensions::InlineMacroProcessor
  • Object
show all
Defined in:
lib/asciidoctor/standoc/macros.rb

Instance Method Summary collapse

Instance Method Details

#preprocess_attrs(attrs) ⇒ Object

deal with locality attrs and their disruption of positional attrs



69
70
71
72
73
74
75
76
# File 'lib/asciidoctor/standoc/macros.rb', line 69

def preprocess_attrs(attrs)
  attrs.delete("term") if attrs["term"] and !attrs["word"]
  attrs.delete(3) if attrs[3] == attrs["term"]
  a = attrs.keys.reject { |k| k.is_a? String or [1, 2].include? k }
  attrs["word"] ||= attrs[a[0]] if a.length() > 0
  attrs["term"] ||= attrs[a[1]] if a.length() > 1
  attrs
end

#process(parent, _target, attr) ⇒ Object



78
79
80
81
82
83
84
85
86
87
# File 'lib/asciidoctor/standoc/macros.rb', line 78

def process(parent, _target, attr)
  attr = preprocess_attrs(attr)
  localities = attr.keys.reject { |k| %w(id word term).include? k }.
    reject { |k| k.is_a? Numeric }.
    map { |k| "#{k}=#{attr[k]}" }.join(",")
  text = [localities, attr["word"]].reject{ |k| k.nil? || k.empty? }.
    join(",")
  out = Asciidoctor::Inline.new(parent, :quoted, text).convert
  %{<concept key="#{attr['id']}" term="#{attr['term']}">#{out}</concept>}
end