Wiki source code of Available Transformations

Last modified by Vincent Massol on 2020/04/24 15:14

Hide last authors
Manuel Smeria 10.2 1 Here's the list of available [[Transformations>>Architecture]] you can use:
Vincent Massol 1.1 2
Vincent Massol 2.1 3 {{toc/}}
4
Vincent Massol 11.3 5 To configure the list of Transformations to execute in your wiki, edit your ##xwiki.properties## file and look for the ##rendering.transformations## configuration key. The default value is (which means you have the Macro Transformation and the Icon Transformation enabled by default in your wiki):
Vincent Massol 11.1 6
7 {{code language="none"}}
8 rendering.transformations = macro, icon
Vincent Massol 11.2 9 {{/code}}
Vincent Massol 11.1 10
Vincent Massol 6.1 11 = Macro Transformation =
12
Vincent Massol 12.2 13 See the [[Macro Transformation documentation>>extensions:Extension.RenderingMacroTransformation.WebHome]].
Vincent Massol 6.1 14
Vincent Massol 2.1 15 = Icon Transformation =
16
Vincent Massol 9.1 17 See the [[Icon Transformation documentation>>extensions:Extension.Icon Transformation]] to understand what this transformation does.
Vincent Massol 2.1 18
Manuel Smeria 10.2 19 Example of usage:
Vincent Massol 4.1 20
21 {{code language="java"}}
22 // Initialize Rendering components and allow getting instances
23 final EmbeddableComponentManager cm = new EmbeddableComponentManager();
24 cm.initialize(this.getClass().getClassLoader());
25
26 XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
27 new SpecialSymbolBlock(')')))));
28
29 Transformation transformation = cm.lookup(Transformation.class, "icon");
30 TransformationContext txContext = new TransformationContext();
31 transformation.transform(xdom, txContext);
32
33 WikiPrinter printer = new DefaultWikiPrinter();
34 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
35 renderer.render(xdom, printer);
36
37 String expected = "image:emoticon_smile";
38
39 Assert.assertEquals(expected, printer.toString());
40 {{/code}}
41
Vincent Massol 5.1 42 It's also possible to configure new emoticons or override existing ones by getting the ##IconTransformationConfiguration## component as shown below (works on XWiki Rendering 3.3M1+):
Vincent Massol 4.1 43
44 {{code language="java"}}
45 // Initialize Rendering components and allow getting instances
46 final EmbeddableComponentManager cm = new EmbeddableComponentManager();
47 cm.initialize(this.getClass().getClassLoader());
48
49 XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
Vincent Massol 5.2 50 new SpecialSymbolBlock(':')))));
Vincent Massol 4.1 51
Vincent Massol 5.1 52 // Test adding a new Icon Mapping.
53 cm.lookup(IconTransformationConfiguration.class).addMapping("::", "something");
Vincent Massol 4.1 54
55 Transformation transformation = cm.lookup(Transformation.class, "icon");
56 TransformationContext txContext = new TransformationContext();
57 transformation.transform(xdom, txContext);
58
59 WikiPrinter printer = new DefaultWikiPrinter();
60 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
61 renderer.render(xdom, printer);
62
Vincent Massol 5.2 63 String expected = "image:box";
Vincent Massol 4.1 64
65 Assert.assertEquals(expected, printer.toString());
66 {{/code}}
67
Vincent Massol 2.1 68 = WikiWord Transformation =
Vincent Massol 3.1 69
Vincent Massol 9.1 70 See the [[WikiWord Transformation documentation>>extensions:Extension.WikiWord Transformation]] to understand what this transformation does.
Vincent Massol 3.1 71
Manuel Smeria 10.2 72 Example of usage:
Vincent Massol 3.1 73
Vincent Massol 4.1 74 {{code language="java"}}
75 // Initialize Rendering components and allow getting instances
76 final EmbeddableComponentManager cm = new EmbeddableComponentManager();
77 cm.initialize(this.getClass().getClassLoader());
78
79 XDOM xdom = new XDOM(
80 Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new WordBlock("WikiWord")))));
81
82 Transformation transformation = cm.lookup(Transformation.class, "wikiword");
83 TransformationContext txContext = new TransformationContext();
84 transformation.transform(xdom, txContext);
85
86 WikiPrinter printer = new DefaultWikiPrinter();
87 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
88 renderer.render(xdom, printer);
89
90 String expected = "[[WikiWord]]";
91
92 Assert.assertEquals(expected, printer.toString());
93 {{/code}}
Vincent Massol 7.1 94
95 = LinkChecker Transformation =
96
Vincent Massol 10.1 97 See the [[Link Checker Transformation documentation>>extensions:Extension.Link Checker Transformation]] to understand what this transformation does and how to use it.
  • Powered by XWiki 15.10.8-node2. Hosted and managed by XWiki SAS

Get Connected