## linkgit: macro
#
# Usage: linkgit:command[manpage-section]
#
# Note, {0} is the manpage section, while {target} is the command.
#
# Show Git link as: <command>(<section>); if section is defined, else just show
# the command.

[macros]
(?su)[\\]?(?P<name>linkgit):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
(?P<name>linkman):(?P<target>\w+)\[(?P<attrlist>\d+)]=
(?P<name>linkstgsub):(?P<target>\w+)\[]=
(?P<name>linkstg):(?P<target>\w+)\[]=

[attributes]
asterisk=&#42;
plus=&#43;
caret=&#94;
startsb=&#91;
endsb=&#93;
backslash=&#92;
tilde=&#126;
apostrophe=&#39;
backtick=&#96;
litdd=&#45;&#45;

ifdef::backend-docbook[]
[linkgit-inlinemacro]
{0%{target}}
{0#<citerefentry>}
{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
{0#</citerefentry>}
endif::backend-docbook[]

ifdef::backend-docbook[]
ifndef::stgit-asciidoc-no-roff[]
# "unbreak" docbook-xsl v1.68 for manpages. v1.69 works with or without this.
# v1.72 breaks with this because it replaces dots not in roff requests.
[listingblock]
<example><title>{title}</title>
<literallayout class="monospaced">
ifdef::doctype-manpage[]
&#10;.ft C&#10;
endif::doctype-manpage[]
|
ifdef::doctype-manpage[]
&#10;.ft&#10;
endif::doctype-manpage[]
</literallayout>
{title#}</example>
endif::stgit-asciidoc-no-roff[]

ifdef::stgit-asciidoc-no-roff[]
ifdef::doctype-manpage[]
# The following two small workarounds insert a simple paragraph after screen
[listingblock]
<example><title>{title}</title>
<literallayout class="monospaced">
|
</literallayout><simpara></simpara>
{title#}</example>

[verseblock]
<formalpara{id? id="{id}"}><title>{title}</title><para>
{title%}<literallayout{id? id="{id}"}>
{title#}<literallayout>
|
</literallayout>
{title#}</para></formalpara>
{title%}<simpara></simpara>
endif::doctype-manpage[]
endif::stgit-asciidoc-no-roff[]
endif::backend-docbook[]

ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[header]
template::[header-declarations]
<refentry>
<refmeta>
<refentrytitle>{mantitle}</refentrytitle>
<manvolnum>{manvolnum}</manvolnum>
<refmiscinfo class="source">{mansource}</refmiscinfo>
<refmiscinfo class="version">{manversion}</refmiscinfo>
<refmiscinfo class="manual">{manmanual}</refmiscinfo>
</refmeta>
<refnamediv>
  <refname>{manname}</refname>
  <refpurpose>{manpurpose}</refpurpose>
</refnamediv>
endif::backend-docbook[]
endif::doctype-manpage[]

ifdef::backend-xhtml11,backend-html5[]
[attributes]
git-relative-html-prefix=
[linkgit-inlinemacro]
# <a href="{git-relative-html-prefix}{target}.html">{target}{0?({0})}</a>
<a href="https://git-scm.com/docs/{target}">{target}{0?({0})}</a>
endif::backend-xhtml11,backend-html5[]

## linkman: macro
#
# Usage: linkman:command[manpage-section]
#
# Note, {0} is the manpage section, while {target} is the command.
#
# Show link as: <command>(<section>); if section is defined, else just
# show the command.

ifdef::backend-docbook[]
[linkman-inlinemacro]
{0%{target}}
{0#<citerefentry>}
{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
{0#</citerefentry>}
endif::backend-docbook[]

ifdef::backend-xhtml11,backend-html5[]
[linkman-inlinemacro]
<a href="{target}.html">{target}{0?({0})}</a>
endif::backend-xhtml11,backend-html5[]

## linkstg: macro
#
# Usage: linkstg:command[]
#
# Show StGit link as: stg-<command>(1) in man pages, stg <command> in
# html.

ifdef::backend-docbook[]
[linkstg-inlinemacro]
<citerefentry>
  <refentrytitle>stg-{target}</refentrytitle><manvolnum>1</manvolnum>
</citerefentry>
endif::backend-docbook[]

ifdef::backend-xhtml11,backend-html5[]
[linkstg-inlinemacro]
<a href="stg-{target}.html">stg {target}</a>
endif::backend-xhtml11,backend-html5[]

## linkstgsub: macro
#
# Usage: linkstgsub:command[]
#
# Show StGit link as: <command>.

ifdef::backend-docbook[]
[linkstgsub-inlinemacro]
{target}
endif::backend-docbook[]

ifdef::backend-xhtml11,backend-html5[]
[linkstgsub-inlinemacro]
<a href="stg-{target}.html">{target}</a>
endif::backend-xhtml11,backend-html5[]
