diff mbox series

[10/11] doc: asciidoctor: add support for baseurl

Message ID 20210514121435.504423-11-felipe.contreras@gmail.com (mailing list archive)
State Superseded
Headers show
Series doc: asciidoctor: direct man page creation and fixes | expand

Commit Message

Felipe Contreras May 14, 2021, 12:14 p.m. UTC
So that we can present relative links correctly.

Reduces the doc-diff:

   NOTES
  -        1. “Understanding history: What is a branch?”
  -           file:///$HOME/share/doc/git-doc/user-manual.html#what-is-a-branch
  +       [1]    “Understanding history: What is a branch?”
  +              user-manual.html#what-is-a-branch

   NOTES
  -        1. “Understanding history: What is a branch?”
  +       [1]    “Understanding history: What is a branch?”
                 file:///$HOME/share/doc/git-doc/user-manual.html#what-is-a-branch

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/Makefile                  | 1 +
 Documentation/asciidoctor-extensions.rb | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/Documentation/Makefile b/Documentation/Makefile
index a514a4e72c..cc5ff54d92 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -193,6 +193,7 @@  ASCIIDOC_DOCBOOK = docbook5
 override ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
 override ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
 override ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
+override ASCIIDOC_EXTRA += -abaseurl='$(MAN_BASE_URL)'
 ASCIIDOC_DEPS = asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
 DBLATEX_COMMON =
 XMLTO_EXTRA += --skip-validation
diff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb
index 42133ee6c3..2ed92c3055 100644
--- a/Documentation/asciidoctor-extensions.rb
+++ b/Documentation/asciidoctor-extensions.rb
@@ -17,7 +17,9 @@  module Asciidoctor
 
         footnote = doc.footnotes.find { |e| e.id == node.target }
         if !footnote
-          footnote_text = "%s\n\e.RS\n\e\\%%%s\n\e.RE" % [node.text, node.target]
+          target = node.target
+          target = doc.attributes['baseurl'] + target unless target.include? ':'
+          footnote_text = "%s\n\e.RS\n\e\\%%%s\n\e.RE" % [node.text, target]
           index = doc.counter('footnote-number')
           footnote = Document::Footnote.new(index, node.target, footnote_text)
           doc.register(:footnotes, footnote)