Wiki source code of Available Transformations
Last modified by Vincent Massol on 2020/04/24 15:14
Hide last authors
author | version | line-number | content |
---|---|---|---|
10.2 | 1 | Here's the list of available [[Transformations>>Architecture]] you can use: | |
1.1 | 2 | ||
2.1 | 3 | {{toc/}} | |
4 | |||
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): | |
11.1 | 6 | ||
7 | {{code language="none"}} | ||
8 | rendering.transformations = macro, icon | ||
11.2 | 9 | {{/code}} | |
11.1 | 10 | ||
6.1 | 11 | = Macro Transformation = | |
12 | |||
12.2 | 13 | See the [[Macro Transformation documentation>>extensions:Extension.RenderingMacroTransformation.WebHome]]. | |
6.1 | 14 | ||
2.1 | 15 | = Icon Transformation = | |
16 | |||
9.1 | 17 | See the [[Icon Transformation documentation>>extensions:Extension.Icon Transformation]] to understand what this transformation does. | |
2.1 | 18 | ||
10.2 | 19 | Example of usage: | |
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 | |||
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+): | |
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(':'), | ||
5.2 | 50 | new SpecialSymbolBlock(':'))))); | |
4.1 | 51 | ||
5.1 | 52 | // Test adding a new Icon Mapping. | |
53 | cm.lookup(IconTransformationConfiguration.class).addMapping("::", "something"); | ||
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 | |||
5.2 | 63 | String expected = "image:box"; | |
4.1 | 64 | ||
65 | Assert.assertEquals(expected, printer.toString()); | ||
66 | {{/code}} | ||
67 | |||
2.1 | 68 | = WikiWord Transformation = | |
3.1 | 69 | ||
9.1 | 70 | See the [[WikiWord Transformation documentation>>extensions:Extension.WikiWord Transformation]] to understand what this transformation does. | |
3.1 | 71 | ||
10.2 | 72 | Example of usage: | |
3.1 | 73 | ||
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}} | ||
7.1 | 94 | ||
95 | = LinkChecker Transformation = | ||
96 | |||
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. |