mirror of
https://github.com/git/git.git
synced 2024-12-18 14:24:11 +08:00
55d2d812e4
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>
29 lines
800 B
Ruby
29 lines
800 B
Ruby
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
|