Note: Macro transformation templates got more powerful with release v1.26.1. Make sure to use a current version.
Note
Macro transformation templates replace internal transformation logic of WikiTraccs.Simple Body Replacement
Remove Macros without Body
The following template replaces the macro by its body content, for a list of macros. If the macro has no body, it will be removed.
{{!-- applyto:style,auibuttongroup,auibutton,div,bgcolor,alert,align,bibtex-reference,bibtex-display,center,clickable,auidialog,span,fancy-bullets,footnote,display-footnotes,highlight,auihorizontalnav,htmlcomment,img,table,tr,th,td,thead,tbody,iframe,latex-formatting,ol,li,ul,lozenge,auimessage,p,pre,privacy-policy,privacy-mark,auiprogress,auiprogressstepstatic,roundrect,search-box,span,tooltip,strike,copyright,reg-tm,sm,tm, --}}
{{#if HasBody}}
{{Body}}
{{else}}
{{RemoveMacro}}
{{/if}}
This preserves the macro body, even if it only consists of whitespace or line breaks.
Remove Macros without Body, or with Empty Body
If you want to remove such empty macro bodies as well, use the following approach, which also removes macros with empty body:
{{!-- applyto:style,auibuttongroup,auibutton,div,bgcolor,alert,align,bibtex-reference,bibtex-display,center,clickable,auidialog,span,fancy-bullets,footnote,display-footnotes,highlight,auihorizontalnav,htmlcomment,img,table,tr,th,td,thead,tbody,iframe,latex-formatting,ol,li,ul,lozenge,auimessage,p,pre,privacy-policy,privacy-mark,auiprogress,auiprogressstepstatic,roundrect,search-box,span,tooltip,strike,copyright,reg-tm,sm,tm, --}}
{{#if HasBody}}
{{#unless IsMacroEmpty}}
{{Body}}
{{else}}
{{RemoveMacro}}
{{/unless}}
{{else}}
{{RemoveMacro}}
{{/if}}
LaTeX formulas
WikiTraccs prepares the formula before it runs the template. Use the internal macro name as the file name. For example, mathblock.hbs controls Appfire Math Block and ppl mathjax inline macro.hbs controls The Plugin People’s MathJax Inline macro.
| Field | Value |
|---|---|
Parameter | The original Confluence macro parameters. For example, Parameter.alignment.Value is the alignment from Appfire macro storage. |
Data.latex.source | The formula from the macro parameter or body. |
Data.latex.body | The plain-text macro body when present. |
Data.latex.image | The PNG attachment. Its fields are fileName, width, height, and alt. |
Data.latex.inline, alignment, number, anchor | The formula layout from the rendered macro and any Appfire equation number and anchor. The shipped template uses the number as the image caption. |
Data.latex.reference, Data.latex.entries | A reference or a list of references. Each reference has text, sourceUrl, and a pageUrl for references to other pages. |
Save this example as mathblock.hbs to show the formula source below its image.
{{TraceCharactersOptIn}}
{{#if Data.latex.image}}
{{SetTransformationResult "TransformedWithLayoutOrFunctionalChanges"}}
<p>
<ac:image ac:width="{{Data.latex.image.width}}" ac:height="{{Data.latex.image.height}}"
ac:alt="{{Data.latex.image.alt}}"{{#if Data.latex.alignment}} ac:align="{{Data.latex.alignment}}"{{/if}}>
<ri:attachment ri:filename="{{Data.latex.image.fileName}}" />
{{#if Data.latex.number}}<ac:caption>{{Data.latex.number}}</ac:caption>{{/if}}
</ac:image>
</p>
{{/if}}
{{#if Data.latex.body}}
<pre>{{#TraceCharactersPreserved}}{{Data.latex.body}}{{/TraceCharactersPreserved}}</pre>
{{else}}
{{DefaultPlaceholder}}
{{/if}}