Documentation: implement linkgit macro for Asciidoctor
AsciiDoc uses a configuration file to implement macros like linkgit, while Asciidoctor uses Ruby extensions. Implement a Ruby extension that implements the linkgit macro for Asciidoctor in the same way that asciidoc.conf does for AsciiDoc. Adjust the Makefile to use it by default. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ec3366eb52
commit
55d2d812e4
@ -179,9 +179,7 @@ ASCIIDOC = asciidoctor
|
||||
ASCIIDOC_CONF =
|
||||
ASCIIDOC_HTML = xhtml5
|
||||
ASCIIDOC_DOCBOOK = docbook45
|
||||
ifdef ASCIIDOCTOR_EXTENSIONS_LAB
|
||||
ASCIIDOC_EXTRA = -I$(ASCIIDOCTOR_EXTENSIONS_LAB) -rasciidoctor/extensions -rman-inline-macro
|
||||
endif
|
||||
ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
|
||||
ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
|
||||
DBLATEX_COMMON =
|
||||
endif
|
||||
|
28
Documentation/asciidoctor-extensions.rb
Normal file
28
Documentation/asciidoctor-extensions.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require 'asciidoctor'
|
||||
require 'asciidoctor/extensions'
|
||||
|
||||
module Git
|
||||
module Documentation
|
||||
class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
use_dsl
|
||||
|
||||
named :chrome
|
||||
|
||||
def process(parent, target, attrs)
|
||||
if parent.document.basebackend? 'html'
|
||||
prefix = parent.document.attr('git-relative-html-prefix')
|
||||
%(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>\n)
|
||||
elsif parent.document.basebackend? 'docbook'
|
||||
"<citerefentry>\n" \
|
||||
"<refentrytitle>#{target}</refentrytitle>" \
|
||||
"<manvolnum>#{attrs[1]}</manvolnum>\n" \
|
||||
"</citerefentry>\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Asciidoctor::Extensions.register do
|
||||
inline_macro Git::Documentation::LinkGitProcessor, :linkgit
|
||||
end
|
Loading…
Reference in New Issue
Block a user