Class: Metanorma::Standoc::IndexXrefInlineMacro

Inherits:
Asciidoctor::Extensions::InlineMacroProcessor
  • Object
show all
Defined in:
lib/metanorma/converter/macros_link.rb

Instance Method Summary collapse

Instance Method Details

#preprocess_attrs(attrs) ⇒ Object



7
8
9
10
11
12
# File 'lib/metanorma/converter/macros_link.rb', line 7

def preprocess_attrs(attrs)
  ret = { primary: attrs[1], target: attrs[attrs.size] }
  ret[:secondary] = attrs[2] if attrs.size > 2
  ret[:tertiary] = attrs[3] if attrs.size > 3
  ret
end

#process(parent, target, attr) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/metanorma/converter/macros_link.rb', line 21

def process(parent, target, attr)
  validate(parent, target, attr) or return
  args = preprocess_attrs(attr)
  ret = "<index-xref also='#{target == 'also'}'>" \
        "<primary>#{args[:primary]}</primary>"
  ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
  ret += "<tertiary>#{args[:tertiary]}</tertiary>" if args[:tertiary]
  ret + "<target>#{args[:target]}</target></index-xref>"
end

#validate(parent, target, attrs) ⇒ Object



14
15
16
17
18
19
# File 'lib/metanorma/converter/macros_link.rb', line 14

def validate(parent, target, attrs)
  attrs.size > 1 && attrs.size < 5 and return true
  parent.converter.log.add("STANDOC_3", parent,
                           params: [target, target, attrs.values.join(",")])
  false
end