summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-09-16 01:22:22 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-09-16 01:22:22 -0600
commitaba86b128777a16f895bbfea34e8b24416f2b37b (patch)
tree8b866c6d45b75acd1874799dbb642d4fdc3d0c14
parent07915e1d7ea94fb554d11487e18478cddb2db02f (diff)
update inline macro example to return an Inline object and support different backends
-rw-r--r--docs/modules/extensions/pages/inline-macro-processor.adoc17
1 files changed, 10 insertions, 7 deletions
diff --git a/docs/modules/extensions/pages/inline-macro-processor.adoc b/docs/modules/extensions/pages/inline-macro-processor.adoc
index 8e5a9078..5ae65d84 100644
--- a/docs/modules/extensions/pages/inline-macro-processor.adoc
+++ b/docs/modules/extensions/pages/inline-macro-processor.adoc
@@ -25,16 +25,19 @@ class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
name_positional_attributes 'volnum'
def process parent, target, attrs
+ doc = parent.document
text = manname = target
- suffix = ''
- target = %(#{manname}.html)
- suffix = if (volnum = attrs['volnum'])
- "(#{volnum})"
+ suffix = (volnum = attrs['volnum']) ? %((#{volnum})) : ''
+ if doc.basebackend? 'html'
+ target = %(#{manname}#{doc.outfilesuffix})
+ doc.register :links, target
+ node = create_anchor parent, text, type: :link, target: target
+ elsif doc.backend == 'manpage'
+ node = create_inline parent, :quoted, manname, type: :strong
else
- nil
+ node = create_inline parent, :quoted, manname
end
- parent.document.register :links, target
- %(#{(create_anchor parent, text, type: :link, target: target).convert}#{suffix})
+ create_inline parent, :quoted, %(#{node.convert}#{suffix})
end
end
----