## NUT macros: linkman, linkdoc
#
# Usage: linkman:command[manpage-section]
#   This macro allows to handle variable manpage location, depending on the
#   document type
#
# Note, {0} is the manpage section, while {target} is the command.
#
# Example: linkman:ups.conf[5]
#
# Show NUT link as: <command>(<section>); if section is defined, else just show
#   the command.
#
################################################################################
#
# Usage: linkdoc:document[display title,[anchor]]
#   This macro allows to handle variable NUT documentation location, depending
#   on the document type
#
# Note, {1} is the display title, {2} is the optional anchor name,
#   {0} is the whole set of args ({1}...{n}) and {target} is the
#   base document name.
# Example:
#   linkdoc:user-manual[user manual,NUT_Security]
#   linkdoc:developer-guide[developer guide,_status_data]

[macros]
(?su)[\\]?(?P<name>linkman):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
(?su)[\\]?(?P<name>linkdoc):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=

ifdef::basebackend-docbook[]
ifdef::xhtml11_format[]
[linkman-inlinemacro]
<ulink url="man/{target}.html">{target}{0?({0})}</ulink>
[linkdoc-inlinemacro]
<ulink url="{target}.html{2?#{2}}">{1}</ulink>
endif::xhtml11_format[]

# FIXME: linkdoc does not support 'anchor'
ifdef::chunked_format[]
[linkman-inlinemacro]
<ulink url="../man/{target}.html">{target}{0?({0})}</ulink>
[linkdoc-inlinemacro]
<ulink url="../{target}.chunked/index.html">{1}</ulink>
endif::chunked_format[]

# PDF output points online versions
# FIXME: linkdoc does not support 'anchor'
ifdef::pdf_format[]
[linkman-inlinemacro]
<ulink url="http://www.networkupstools.org/docs/man/{target}.html">{target}{0?({0})}</ulink>
[linkdoc-inlinemacro]
<ulink url="{target}.pdf">{1}</ulink>
endif::pdf_format[]
endif::basebackend-docbook[]
