Class: Asciidoctor::Standoc::ConceptInlineMacro
- Inherits:
-
Extensions::InlineMacroProcessor
- Object
- Extensions::InlineMacroProcessor
- Asciidoctor::Standoc::ConceptInlineMacro
- Defined in:
- lib/asciidoctor/standoc/macros_terms.rb
Instance Method Summary collapse
-
#preprocess_attrs(attrs) ⇒ Object
deal with locality attrs and their disruption of positional attrs.
- #process(parent, _target, attr) ⇒ Object
Instance Method Details
#preprocess_attrs(attrs) ⇒ Object
deal with locality attrs and their disruption of positional attrs
61 62 63 64 65 66 67 68 |
# File 'lib/asciidoctor/standoc/macros_terms.rb', line 61 def preprocess_attrs(attrs) attrs.delete("term") if attrs["term"] && !attrs["word"] attrs.delete(3) if attrs[3] == attrs["term"] a = attrs.keys.reject { |k| k.is_a?(String) || [1, 2].include?(k) } attrs["word"] ||= attrs[a[0]] if !a.empty? attrs["term"] ||= attrs[a[1]] if a.length > 1 attrs end |
#process(parent, _target, attr) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/asciidoctor/standoc/macros_terms.rb', line 70 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 |