summaryrefslogtreecommitdiff
path: root/Documentation/asciidoctor-extensions.rb
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2019-09-22 11:57:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-09-28 08:37:56 (GMT)
commitdba3734103e781bcf8c43db9c23acca4568521ae (patch)
treedf31bb9514924c4a5d674ea7d8976d256dc9a014 /Documentation/asciidoctor-extensions.rb
parentfd5b820d9c1688fde9505effd48a0d98be6a24cb (diff)
downloadgit-dba3734103e781bcf8c43db9c23acca4568521ae.zip
git-dba3734103e781bcf8c43db9c23acca4568521ae.tar.gz
git-dba3734103e781bcf8c43db9c23acca4568521ae.tar.bz2
asciidoctor-extensions.rb: handle "book" doctype in linkgit
user-manual.txt is the only file we process using the "book" doctype. When we use AsciiDoc, user-manual.conf ensures that the linkgit macro expands into something like <ulink url="git-foo.html">git-foo(1)</ulink> in user-manual.xml, which we then process into a clickable link, both in user-manual.html and user-manual.pdf. With Asciidoctor, user-manual.conf is ignored (this is expected) and our Asciidoctor-specific implementation of linkgit kicks in: <citerefentry> <refentrytitle>git-foo</refentrytitle><manvolnum>1</manvolnum> </citerefentry> This eventually renders as "git-foo(1)", which is not bad, but it doesn't turn into a link. Teach our Asciidoctor-specific implementation of the linkgit macro that if the doctype is "book", we should emit <ulink .../> just like we do with AsciiDoc. While we're doing this, future-proof by supporting a "prefix". The implementation in user-manual.conf doesn't support this, and we don't need this for now because user-manual.txt is the only file we process this way (and it's immediately in Documentation/). Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/asciidoctor-extensions.rb')
-rw-r--r--Documentation/asciidoctor-extensions.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb
index 0089e0c..70a0956 100644
--- a/Documentation/asciidoctor-extensions.rb
+++ b/Documentation/asciidoctor-extensions.rb
@@ -9,8 +9,11 @@ module Git
named :chrome
def process(parent, target, attrs)
- if parent.document.basebackend? 'html'
- prefix = parent.document.attr('git-relative-html-prefix')
+ prefix = parent.document.attr('git-relative-html-prefix')
+ if parent.document.doctype == 'book'
+ "<ulink url=\"#{prefix}#{target}.html\">" \
+ "#{target}(#{attrs[1]})</ulink>"
+ elsif parent.document.basebackend? 'html'
%(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
elsif parent.document.basebackend? 'docbook'
"<citerefentry>\n" \