Class: Asciidoctor::Standoc::RelatedTermInlineMacro
- Inherits:
-
Extensions::InlineMacroProcessor
- Object
- Extensions::InlineMacroProcessor
- Asciidoctor::Standoc::RelatedTermInlineMacro
- Defined in:
- lib/asciidoctor/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
161 162 163 164 165 |
# File 'lib/asciidoctor/standoc/macros_terms.rb', line 161 def preprocess_attrs(target) m = /^(?<id><<.+?>>, ?)?(?<rest>.*)$/.match(target) { id: m[:id]&.sub(/^<</, "")&.sub(/>>, ?$/, ""), term: m[:rest] } end |
#process(parent, target, attrs) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/asciidoctor/standoc/macros_terms.rb', line 167 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.message}") end |