Path: blob/main/shared/lib/CrossDocumentReferencesMacro/extension.rb
18086 views
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'12include ::Asciidoctor34class CrossDocumentReferencesMacro < Asciidoctor::Extensions::InlineMacroProcessor5use_dsl67# Macro to handle cross references to a different book.8named :extref9name_positional_attributes 'attributes'1011def process parent, target, attrs12destination = target13text = attrs[1]14anchor = ""1516unless attrs[2].nil?17anchor = "#" + attrs[2]18end1920doc = parent.document2122if doc.attributes['isonline'] == "1"23(create_anchor parent, text, type: :link, target: %(#{destination}#{anchor})).render24else25if doc.attributes['doctype'] == "book"26(create_anchor parent, text, type: :link, target: %(../#{destination}/index.html#{anchor})).render27else28(create_anchor parent, text, type: :link, target: %(#{destination}/index.html#{anchor})).render29end30end3132end33end343536