web-dev-qa-db-fra.com

Comment créer des légendes de figures numérotées automatiquement dans Atlassian Confluence?

Existe-t-il des macros ou un autre moyen dans l'outil de documentation Atlassian Confluence (wiki) de créer des légendes de figures/tableaux numérotées automatiquement?

3
MrTJ

Eh bien, je suis venu avec cette macro:

## Macro title: Subtitle
## Macro has a body: Y
##
## Developed by: Janos Tolgyesi
## Date created: 27/04/2012
##
## @param AnchorName:title=Anchor Name|type=string|required=true
## @param SubtitleText:title=Subtitle|type=string|required=true
## @param Prefix:title=Prefix (Figure, Table, etc.)|type=string|required=true

## Hack to detect Table Of Contents macro that messes up numbering
## by calling user macros two times
#set($Q = '"')
#set ($isToc = $content.getBodyAsString().contains("<ac:macro ac:name=${Q}toc${Q} />"))
#if (!$req.getAttribute("${paramAnchorName}SubtitleMacro") && ($isToc == "true"))

## Here we are called first time from TOC macro
#set ($dummy = $req.setAttribute("${paramAnchorName}SubtitleMacro", 1))
#else

## The real code
#set ($counterName = "${paramPrefix}Counter")

#if (!$req.getAttribute($counterName))
$!req.setAttribute($counterName, 0)
#end

#if (!$req.getAttribute("xrefMap"))
$!req.setAttribute("xrefMap", {})
#end

#set ($counter = $req.getAttribute($counterName) + 1)
#set ($fullSubtitle = "$paramPrefix $counter. $paramSubtitleText")
$!req.setAttribute($counterName, $counter)
#set ($dummy = $!req.getAttribute("xrefMap").put($paramAnchorName, $fullSubtitle))

<ac:macro ac:name="anchor">
<ac:default-parameter>$paramAnchorName</ac:default-parameter>
</ac:macro>
<span style="display:inline-block;">
$body
<div style="text-align:center; padding-bottom:1em">$fullSubtitle</div>
</span>

#end
0
MrTJ