|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HTMLMacroXHTMLChainingRenderer | Line # 37 | 20 | 0% | 19 | 14 | 69.6% |
0.6956522
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (10) | |||
| Result | |||
|
0.5652174
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.5217391
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.5217391
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.5217391
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.47826087
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.4347826
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.39130434
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.39130434
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.39130434
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.2173913
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.rendering.internal.macro.html; | |
| 21 | ||
| 22 | import java.util.Map; | |
| 23 | ||
| 24 | import org.xwiki.rendering.internal.renderer.xhtml.XHTMLChainingRenderer; | |
| 25 | import org.xwiki.rendering.internal.renderer.xhtml.image.XHTMLImageRenderer; | |
| 26 | import org.xwiki.rendering.listener.chaining.ListenerChain; | |
| 27 | import org.xwiki.rendering.internal.renderer.xhtml.link.XHTMLLinkRenderer; | |
| 28 | ||
| 29 | /** | |
| 30 | * Renderer that generates XHTML from a XDOM resulting from the parsing of text containing HTML mixed with wiki syntax. | |
| 31 | * We override the default XHTML renderer since we want special behaviors, for example to not escape special symbols | |
| 32 | * (since we don't want to escape HTML tags for example). | |
| 33 | * | |
| 34 | * @version $Id $ | |
| 35 | * @since 1.8.3 | |
| 36 | */ | |
| 37 | public class HTMLMacroXHTMLChainingRenderer extends XHTMLChainingRenderer | |
| 38 | { | |
| 39 | /** | |
| 40 | * @param linkRenderer the object to render link events into XHTML. This is done so that it's pluggable because link | |
| 41 | * rendering depends on how the underlying system wants to handle it. For example for XWiki we check if | |
| 42 | * the document exists, we get the document URL, etc. | |
| 43 | * @param imageRenderer the object to render image events into XHTML. This is done so that it's pluggable because | |
| 44 | * image rendering depends on how the underlying system wants to handle it. For example for XWiki we | |
| 45 | * check if the image exists as a document attachments, we get its URL, etc. | |
| 46 | * @param listenerChain the chain of listener filters used to compute various states | |
| 47 | * @since 2.0M3 | |
| 48 | */ | |
| 49 | 11 |
public HTMLMacroXHTMLChainingRenderer(XHTMLLinkRenderer linkRenderer, XHTMLImageRenderer imageRenderer, |
| 50 | ListenerChain listenerChain) | |
| 51 | { | |
| 52 | 11 | super(linkRenderer, imageRenderer, listenerChain); |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * @return true if the current event is generated from a transformation. | |
| 57 | */ | |
| 58 | 192 |
private boolean isInGeneratedBlock() |
| 59 | { | |
| 60 | 192 | return getBlockState().isInMacro(); |
| 61 | } | |
| 62 | ||
| 63 | 89 |
@Override |
| 64 | public void onSpecialSymbol(char symbol) | |
| 65 | { | |
| 66 | 89 | if (!isInGeneratedBlock()) { |
| 67 | 86 | getPrinter().print("" + symbol); |
| 68 | } else { | |
| 69 | 3 | super.onSpecialSymbol(symbol); |
| 70 | } | |
| 71 | } | |
| 72 | ||
| 73 | 46 |
@Override |
| 74 | public void onWord(String word) | |
| 75 | { | |
| 76 | 46 | if (!isInGeneratedBlock()) { |
| 77 | 44 | getPrinter().print(word); |
| 78 | } else { | |
| 79 | 2 | super.onWord(word); |
| 80 | } | |
| 81 | } | |
| 82 | ||
| 83 | 16 |
@Override |
| 84 | public void onNewLine() | |
| 85 | { | |
| 86 | 16 | if (!isInGeneratedBlock()) { |
| 87 | 16 | getPrinter().print("\n"); |
| 88 | } else { | |
| 89 | 0 | super.onNewLine(); |
| 90 | } | |
| 91 | } | |
| 92 | ||
| 93 | 19 |
@Override |
| 94 | public void onSpace() | |
| 95 | { | |
| 96 | 19 | if (!isInGeneratedBlock()) { |
| 97 | 19 | getPrinter().print(" "); |
| 98 | } else { | |
| 99 | 0 | super.onSpace(); |
| 100 | } | |
| 101 | } | |
| 102 | ||
| 103 | 0 |
@Override |
| 104 | public void onEmptyLines(int count) | |
| 105 | { | |
| 106 | 0 | if (!isInGeneratedBlock()) { |
| 107 | // Don't print anything. | |
| 108 | } else { | |
| 109 | 0 | super.onEmptyLines(count); |
| 110 | } | |
| 111 | } | |
| 112 | ||
| 113 | 11 |
@Override |
| 114 | public void beginParagraph(Map<String, String> parameters) | |
| 115 | { | |
| 116 | 11 | if (!isInGeneratedBlock()) { |
| 117 | // Don't print anything. | |
| 118 | } else { | |
| 119 | 0 | super.beginParagraph(parameters); |
| 120 | } | |
| 121 | } | |
| 122 | ||
| 123 | 11 |
@Override |
| 124 | public void endParagraph(Map<String, String> parameters) | |
| 125 | { | |
| 126 | 11 | if (!isInGeneratedBlock()) { |
| 127 | // Don't print anything. | |
| 128 | } else { | |
| 129 | 0 | super.endParagraph(parameters); |
| 130 | } | |
| 131 | } | |
| 132 | ||
| 133 | 0 |
@Override |
| 134 | public void onMacro(String id, Map<String, String> parameters, String content, boolean isInline) | |
| 135 | { | |
| 136 | // Don't print anything since we are already in the html macro. | |
| 137 | } | |
| 138 | ||
| 139 | 6 |
@Override |
| 140 | public void beginMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline) | |
| 141 | { | |
| 142 | // Don't print anything since we are already in the html macro. | |
| 143 | } | |
| 144 | ||
| 145 | 6 |
@Override |
| 146 | public void endMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline) | |
| 147 | { | |
| 148 | // Don't print anything since we are already in the html macro. | |
| 149 | } | |
| 150 | } | |
|
||||||||||||