Class: Metanorma::Standoc::IndexXrefInlineMacro
- Inherits:
-
Asciidoctor::Extensions::InlineMacroProcessor
- Object
- Asciidoctor::Extensions::InlineMacroProcessor
- Metanorma::Standoc::IndexXrefInlineMacro
- Defined in:
- lib/metanorma/standoc/macros_inline.rb
Instance Method Summary collapse
- #preprocess_attrs(attrs) ⇒ Object
- #process(parent, target, attr) ⇒ Object
- #validate(parent, target, attrs) ⇒ Object
Instance Method Details
#preprocess_attrs(attrs) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/metanorma/standoc/macros_inline.rb', line 19 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
34 35 36 37 38 39 40 41 42 |
# File 'lib/metanorma/standoc/macros_inline.rb', line 34 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
26 27 28 29 30 31 32 |
# File 'lib/metanorma/standoc/macros_inline.rb', line 26 def validate(parent, target, attrs) attrs.size > 1 && attrs.size < 5 and return true e = "invalid index \"#{target}\" cross-reference: wrong number of " \ "attributes in `index:#{target}[#{attrs.values.join(',')}]`" parent.converter.log.add("Crossreferences", parent, e, severity: 0) false end |