it-swarm.com.de

Wie erstelle ich in Atlassian Confluence automatisch nummerierte Bildunterschriften?

Gibt es Makros oder andere Möglichkeiten im Atlassian Confluence-Dokumentationstool (Wiki), um automatisch nummerierte Bild-/Tabellenüberschriften zu erstellen?

3
MrTJ

Nun, ich habe mir dieses Makro ausgedacht:

## 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