1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.macro.quote; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import javax.inject.Inject; |
27 |
|
import javax.inject.Named; |
28 |
|
import javax.inject.Singleton; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.component.manager.ComponentManager; |
32 |
|
import org.xwiki.rendering.block.Block; |
33 |
|
import org.xwiki.rendering.block.QuotationBlock; |
34 |
|
import org.xwiki.rendering.block.QuotationLineBlock; |
35 |
|
import org.xwiki.rendering.block.VerbatimBlock; |
36 |
|
import org.xwiki.rendering.macro.AbstractNoParameterMacro; |
37 |
|
import org.xwiki.rendering.macro.MacroContentParser; |
38 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
39 |
|
import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor; |
40 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@version |
46 |
|
@since |
47 |
|
|
48 |
|
@Component |
49 |
|
@Named("quote") |
50 |
|
@Singleton |
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.38 |
|
51 |
|
public class QuoteMacro extends AbstractNoParameterMacro |
52 |
|
{ |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private static final String DESCRIPTION = "Displays inline text with special quote formatting."; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
private static final String CONTENT_DESCRIPTION = "Content to quote"; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@Inject |
67 |
|
private MacroContentParser macroContentParser; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
@Inject |
72 |
|
private ComponentManager componentManager; |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
78 |
1 |
public QuoteMacro()... |
79 |
|
{ |
80 |
1 |
super("Quote", DESCRIPTION, new DefaultContentDescriptor(CONTENT_DESCRIPTION)); |
81 |
1 |
setDefaultCategory(DEFAULT_CATEGORY_FORMATTING); |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
0 |
@Override... |
85 |
|
public boolean supportsInlineMode() |
86 |
|
{ |
87 |
0 |
return false; |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
90 |
1 |
@Override... |
91 |
|
public List<Block> execute(Object parameters, String content, MacroTransformationContext context) |
92 |
|
throws MacroExecutionException |
93 |
|
{ |
94 |
1 |
List<Block> quoteBlocks = new ArrayList<>(); |
95 |
1 |
for (String line : content.split("\\r?\\n")) { |
96 |
3 |
List<Block> lineContentBlocks = Collections.<Block>singletonList(new VerbatimBlock(line, true)); |
97 |
3 |
quoteBlocks.add(new QuotationLineBlock(lineContentBlocks)); |
98 |
|
} |
99 |
1 |
return Collections.<Block>singletonList(new QuotationBlock(quoteBlocks)); |
100 |
|
} |
101 |
|
} |