Hi Thomas,
Can you explain the reason for this change? It doesn't sound logical at first
sight that the code macro result isn't wrapped in a verbatim block.
Thanks
-Vincent
On Feb 21, 2010, at 4:14 PM, tmortagne (SVN) wrote:
> Author: tmortagne
> Date: 2010-02-21 16:14:04 +0100 (Sun, 21 Feb 2010)
> New Revision: 27187
>
> Modified:
>
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/main/java/org/xwiki/rendering/internal/macro/code/CodeMacro.java
>
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/test/resources/macrocode10.test
>
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/test/resources/macrocode3.test
>
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/test/resources/macrocode6.test
> Log:
> XWIKI-4915: Code macro 2.0 - inline language=none uses non-monospace font
>
> Modified:
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/main/java/org/xwiki/rendering/internal/macro/code/CodeMacro.java
> ===================================================================
> ---
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/main/java/org/xwiki/rendering/internal/macro/code/CodeMacro.java
> 2010-02-21 14:55:48 UTC (rev 27186)
> +++
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/main/java/org/xwiki/rendering/internal/macro/code/CodeMacro.java
> 2010-02-21 15:14:04 UTC (rev 27187)
> @@ -23,16 +23,18 @@
> import java.util.Collections;
> import java.util.List;
>
> +import org.apache.commons.lang.StringUtils;
> import org.xwiki.component.annotation.Component;
> +import org.xwiki.component.annotation.Requirement;
> import org.xwiki.component.manager.ComponentLookupException;
> import org.xwiki.rendering.block.Block;
> -import org.xwiki.rendering.block.VerbatimBlock;
> import org.xwiki.rendering.macro.MacroExecutionException;
> import org.xwiki.rendering.macro.box.AbstractBoxMacro;
> import org.xwiki.rendering.macro.code.CodeMacroParameters;
> import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor;
> import org.xwiki.rendering.parser.HighlightParser;
> import org.xwiki.rendering.parser.ParseException;
> +import org.xwiki.rendering.parser.Parser;
> import org.xwiki.rendering.transformation.MacroTransformationContext;
>
> /**
> @@ -48,7 +50,7 @@
> * The description of the macro.
> */
> private static final String DESCRIPTION = "Highlights code snippets of
> various programming languages";
> -
> +
> /**
> * Used to indicate that content should not be highlighted.
> */
> @@ -60,6 +62,12 @@
> private static final String CONTENT_DESCRIPTION = "the content to
> highlight";
>
> /**
> + * Used to parse content when language="none".
> + */
> + @Requirement("plain/1.0")
> + private Parser plainTextParser;
> +
> + /**
> * Create and initialize the descriptor of the macro.
> */
> public CodeMacro()
> @@ -81,7 +89,14 @@
> List<Block> result;
> try {
> if (LANGUAGE_NONE.equalsIgnoreCase(parameters.getLanguage())) {
> - result = Collections.<Block> singletonList(new
> VerbatimBlock(content, context.isInline()));
> + if (StringUtils.isEmpty(content)) {
> + result = Collections.emptyList();
> + } else {
> + result = this.plainTextParser.parse(new
> StringReader(content)).getChildren();
> + if (context.isInline()) {
> + result = result.get(0).getChildren();
> + }
> + }
> } else {
> result = highlight(parameters, content);
> }
>
> Modified:
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/test/resources/macrocode10.test
> ===================================================================
> ---
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/test/resources/macrocode10.test
> 2010-02-21 14:55:48 UTC (rev 27186)
> +++
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-code/src/test/resources/macrocode10.test
> 2010-02-21 15:14:04 UTC (rev 27187)
> @@ -16,7 +16,9 @@
> endMacroMarkerStandalone [code] [language=notsupportedsyntax] [Text]
> beginMacroMarkerStandalone [code] [language=none] [Text]
> beginGroup [[class]=[box code]]
> -onVerbatim [Text] [false]
> +beginParagraph
> +onWord [Text]
> +endParagraph
> endGroup [[class]=[box code]]
> endMacroMarkerStandalone [code] [language=none] [Text]
> endDocument
> \ No newline at end of file
[snip]
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs