List supported Confluence macros
Last modified by Raphaël Jakse on 2026/06/02 17:55
| This script lets you find out which Confluence macros are supported, looking for which macro converters and Confluence bridges are present on your wiki |
| Type | Snippet |
| Category | Other |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
Table of contents
Description
To use this snippet, copy-paste this code in a page on your wiki.
You will need to have installed the Confluence Migration Toolkit if you want to list macros supported by XWiki SAS as well.
Visiting the page will display a table of supported macros.
you can also provide a CSV to add or alter entries in this table. This CSV file needs to be attached to this page, named "macroSupport.csv" and to have at least these columns:
- Confluence Macro name
- Migration supported
- Comments
{{groovy}}
import org.xwiki.rendering.macro.Macro;
import org.xwiki.contrib.confluence.filter.MacroConverter;
import org.apache.commons.csv.CSVFormat;
Map<String, String> documentationFromCSV = new HashMap<>();
def a = doc.getAttachment("macroSupport.csv")
if (a != null) {
def records = CSVFormat
.RFC4180
.withFirstRecordAsHeader()
.withIgnoreHeaderCase()
.withTrim()
.parse(new InputStreamReader(a.getContentInputStream()));
for (def record : records) {
String confluenceId = record.get("Confluence Macro name").trim().toLowerCase();
documentationFromCSV.put(confluenceId, List.of(record.get("Migration supported"), record.get("Comments")))
}
}
def componentManager = services.component.getComponentManager();
def languageMacros = new TreeSet<String>();
def macros = new TreeSet<String>();
def macrosByKey = new HashMap<>(componentManager.getInstanceMap(MacroConverter.class));
for (Map.Entry<String, MacroConverter> e : macrosByKey) {
def k = e.getKey();
if (k == "default") {
// ignore
} else if (k == "sv-translation" || e.getValue() instanceof org.xwiki.contrib.confluence.filter.internal.macros.LangMacroConverter) {
languageMacros.add(k);
} else {
macros.add(k);
}
}
def allMacros = componentManager.getInstanceMap(Macro.class);
for (Map.Entry<String, Macro> m : allMacros.entrySet()) {
String k = m.getKey();
if (k.startsWith("confluence_")) {
def unprefixed = k.substring("confluence_".length());
macros.add(unprefixed);
macrosByKey.put(unprefixed, m.getValue());
}
}
if (services.confluenceMigration != null) {
for (String unprefixed : services.confluenceMigration.PREFILLED_INPUT_PARAMETERS.get("unprefixedMacros").split(",")) {
macros.add(unprefixed);
macrosByKey.put(unprefixed, componentManager.getInstance(Macro.class, unprefixed));
}
}
macros.addAll(documentationFromCSV.keySet());
println("|=Confluence macro|=Migration Supported|=Support type|=XWiki macro|=Package|=Comment");
for (String confluenceId : macros) {
Object m = macrosByKey.get(confluenceId);
print "|##";
print confluenceId;
print "##|"
def supported = "Yes";
def comment = "-";
def documented = documentationFromCSV.get(confluenceId);
if (documented != null) {
if (documented.get(0).trim() != "No" || m == null) {
supported = documented.get(0).trim();
}
if (!documented.get(1).trim().isEmpty()) {
comment = documented.get(1).trim();
}
}
print supported + "|";
if (m instanceof MacroConverter) {
// TODO handle cases when the macro is converted to something else than a macro
print "Conversion|##";
String xwikiId = null;
try {
xwikiId = m.toXWikiId(confluenceId, Map.of(), "", true);
print xwikiId;
} catch (e) {
print "-";
}
print "##|";
String packageName = '-';
if (xwikiId != null) {
try {
def target = componentManager.getInstance(Macro.class, xwikiId);
if (target != null) {
packageName = target.class.getPackage().getImplementationTitle();
}
} catch (e) {
// ignore
}
}
print packageName;
} else if (m instanceof Macro) {
def descriptor = m.getDescriptor();
def xwikiId = descriptor.getId().getId();
def isBridge = xwikiId.startsWith("confluence_");
print isBridge ? "Bridge" : "Direct equivalent";
print "|(((##";
print xwikiId;
println "##//";
print descriptor.getName();
print "//)))|";
if (m instanceof org.xwiki.rendering.macro.wikibridge.WikiMacro) {
print isBridge ? "Confluence bridges" : "-";
} else {
print m.class.getPackage().getImplementationTitle();
}
} else {
print "-|-|-";
}
println "|" + comment;
}
println "== Langage macros\n\nLanguage macros are translated to localized XWiki documents, or to the ##contentTranslation## macro if language conversion support is disabled in the Confluence migrator.\n";
print "Macro list: ";
boolean started = false;
for (String macroName : languageMacros) {
if (started) {
print ", ";
} else {
started = true;
}
print "##" + macroName + "##";
}
{{/groovy}}