diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2017-01-26 00:13:44 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-31 12:18:18 -0800 |
commit | 55d2d812e49aece049b73682ad5980ea84e23839 (patch) | |
tree | 7ce2c800db0fc5755a773cee45b7c7f82588c5ee /Documentation | |
parent | Makefile: add a knob to enable the use of Asciidoctor (diff) | |
download | tgif-55d2d812e49aece049b73682ad5980ea84e23839.tar.xz |
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>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/Makefile | 4 | ||||
-rw-r--r-- | Documentation/asciidoctor-extensions.rb | 28 |
2 files changed, 29 insertions, 3 deletions
diff --git a/Documentation/Makefile b/Documentation/Makefile index 2057a35363..b21e5808b1 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -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 diff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb new file mode 100644 index 0000000000..ec83b4959e --- /dev/null +++ b/Documentation/asciidoctor-extensions.rb @@ -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 |