1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.renderer.html5

File AnnotatedHTML5ChainingRenderer.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart4.png
78% of files have more coverage

Code metrics

4
7
4
1
87
35
6
0.86
1.75
4
1.5

Classes

Class Line # Actions
AnnotatedHTML5ChainingRenderer 36 7 0% 6 10
0.3333333433.3%
 

Contributing tests

This file is covered by 37 tests. .

Source view

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.renderer.html5;
21   
22    import java.util.Map;
23   
24    import org.xwiki.rendering.internal.renderer.xhtml.XHTMLMacroRenderer;
25    import org.xwiki.rendering.internal.renderer.xhtml.image.XHTMLImageRenderer;
26    import org.xwiki.rendering.internal.renderer.xhtml.link.XHTMLLinkRenderer;
27    import org.xwiki.rendering.listener.chaining.ListenerChain;
28   
29    /**
30    * Convert listener events to annotated HTML5. See {@link AnnotatedHTML5Renderer} for more details on what Annotated
31    * HTML5 is.
32    *
33    * @version $Id: bb834eca0f9cb5adc46c0a330a1d0452ef5e88b1 $
34    * @since 6.4M3
35    */
 
36    public class AnnotatedHTML5ChainingRenderer extends HTML5ChainingRenderer
37    {
38    /**
39    * Renders a Macro definition into Annotated XHTML.
40    */
41    private XHTMLMacroRenderer macroRenderer;
42   
43    /**
44    * @param linkRenderer the object to render link events into XHTML. This is done so that it's pluggable because link
45    * rendering depends on how the underlying system wants to handle it. For example for XWiki we check if
46    * the document exists, we get the document URL, etc.
47    * @param imageRenderer the object to render image events into XHTML. This is done so that it's pluggable because
48    * image rendering depends on how the underlying system wants to handle it. For example for XWiki we
49    * check if the image exists as a document attachments, we get its URL, etc.
50    * @param listenerChain the chain of listener filters used to compute various states
51    */
 
52  37 toggle public AnnotatedHTML5ChainingRenderer(XHTMLLinkRenderer linkRenderer,
53    XHTMLImageRenderer imageRenderer, ListenerChain listenerChain)
54    {
55  37 super(linkRenderer, imageRenderer, listenerChain);
56   
57  37 this.macroRenderer = new XHTMLMacroRenderer();
58    }
59   
 
60  4 toggle @Override
61    public void onMacro(String id, Map<String, String> parameters, String content, boolean isInline)
62    {
63    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
64    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
65  4 this.macroRenderer.render(getXHTMLWikiPrinter(), id, parameters, content);
66    }
67   
 
68  0 toggle @Override
69    public void beginMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
70    {
71  0 if (getBlockState().getMacroDepth() == 1) {
72    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
73    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
74  0 this.macroRenderer.beginRender(getXHTMLWikiPrinter(), name, parameters, content);
75    }
76    }
77   
 
78  0 toggle @Override
79    public void endMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
80    {
81  0 if (getBlockState().getMacroDepth() == 1) {
82    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
83    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
84  0 this.macroRenderer.endRender(getXHTMLWikiPrinter());
85    }
86    }
87    }