Skip to content

Commit dba3734

Browse files
Martin Ågrengitster
Martin Ågren
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd5b820 commit dba3734

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Documentation/asciidoctor-extensions.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
99
named :chrome
1010

1111
def process(parent, target, attrs)
12-
if parent.document.basebackend? 'html'
13-
prefix = parent.document.attr('git-relative-html-prefix')
12+
prefix = parent.document.attr('git-relative-html-prefix')
13+
if parent.document.doctype == 'book'
14+
"<ulink url=\"#{prefix}#{target}.html\">" \
15+
"#{target}(#{attrs[1]})</ulink>"
16+
elsif parent.document.basebackend? 'html'
1417
%(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
1518
elsif parent.document.basebackend? 'docbook'
1619
"<citerefentry>\n" \

0 commit comments

Comments
 (0)