diff --git a/asciidoctor-extensions.rb b/asciidoctor-extensions.rb new file mode 100644 index 0000000000000000000000000000000000000000..0098be6d260ff05c2435b849f25563a34fe3b335 --- /dev/null +++ b/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) + 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? 'manpage' + "#{target}(#{attrs[1]})" + end + end + end + end +end + +Asciidoctor::Extensions.register do + inline_macro Git::Documentation::LinkGitProcessor, :linkgit +end diff --git a/makefile.locale b/makefile.locale index b6ac09027fee59b2af4beba7e6ea94eb1ae287ab..f678c049465338050c439cf600b55f3055f01a79 100644 --- a/makefile.locale +++ b/makefile.locale @@ -22,7 +22,7 @@ include ../../Makefile XMLTO_EXTRA += --searchpath ../.. ifdef USE_ASCIIDOCTOR -ASCIIDOC_EXTRA += -I../.. +ASCIIDOC_EXTRA += -I../.. -I. -rasciidoctor-extensions else ASCIIDOC_CONF = -f ../../asciidoc.conf endif @@ -43,12 +43,17 @@ ifndef V QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $(lang) $@; endif +-include ../GIT-VERSION-FILE + $(HTML_FILTER): %.html: %.txt - $(QUIET_ASCIIDOC)asciidoctor -b xhtml5 -d manpage $< + $(QUIET_ASCIIDOC)asciidoctor -b xhtml5 -d manpage -d manpage -I.. -I. -rasciidoctor-extensions \ + -amanversion=$(GIT_VERSION) -amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)' $< MANPAGES=$(patsubst %.txt,%.1,$(MAN_FILTER)) $(MANPAGES): %.1: %.txt - $(QUIET_ASCIIDOC)asciidoctor -b manpage -d manpage -o $@ $< + $(QUIET_ASCIIDOC)asciidoctor -b manpage -d manpage -o $@ \ + -I. -I.. -rasciidoctor-extensions \ + -amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)' $< man: $(MANPAGES) html: $(HTML_FILTER)