Class: Metanorma::Standoc::RelatedTermInlineMacro
- Inherits:
-
Asciidoctor::Extensions::InlineMacroProcessor
- Object
- Asciidoctor::Extensions::InlineMacroProcessor
- Metanorma::Standoc::RelatedTermInlineMacro
- Defined in:
- lib/metanorma/standoc/macros_terms.rb
Overview
Possibilities: related:relation[<<id>>, term] related:relation[<<termbase:id>>, term] related:relation equivalent to a crossreference to term:
Instance Method Summary collapse
Instance Method Details
#preprocess_attrs(target) ⇒ Object
165 166 167 168 169 |
# File 'lib/metanorma/standoc/macros_terms.rb', line 165 def preprocess_attrs(target) m = /^(?<id><<.+?>>, ?)?(?<rest>.*)$/.match(target) { id: m[:id]&.sub(/^<</, "")&.sub(/>>, ?$/, ""), term: m[:rest] } end |
#process(parent, target, attrs) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/metanorma/standoc/macros_terms.rb', line 171 def process(parent, target, attrs) out = preprocess_attrs(attrs["text"]) term = Asciidoctor::Inline.new(parent, :quoted, out[:term]).convert if out[:id] then "<related type='#{target}' key='#{out[:id]}'>" \ "<refterm>#{term}</refterm></related>" else "<related type='#{target}'><termxref>#{term}</termxref>" \ "<xrefrender>#{term}</xrefrender></related>" end rescue StandardError => e raise("processing related:#{target}[#{attrs['text']}]: #{e.}") end |