/** * {@inheritDoc} * * @see org.xwiki.rendering.listener.Listener#onRawText(java.lang.String, org.xwiki.rendering.syntax.Syntax) */ public void onRawText(String rawContent, Syntax syntax) { this.stack.push(new RawBlock(rawContent, syntax)); }
/** * {@inheritDoc} * * @see AbstractBlock#traverse(Listener) */ public void traverse(Listener listener) { listener.onRawText(getRawContent(), getSyntax()); }
/** * {@inheritDoc} * * @see org.xwiki.rendering.macro.Macro#execute(Object, String, MacroTransformationContext) */ public List<Block> execute(HTMLMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { List<Block> blocks; if (!StringUtils.isEmpty(content)) { String normalizedContent = content; // If the user has mentioned that there's wiki syntax in the macro then we parse the content using // a wiki syntax parser and render it back using a special renderer to print the XDOM blocks into // a text representing the resulting XHTML content. if (parameters.getWiki()) { normalizedContent = renderWikiSyntax(normalizedContent, context.getTransformation(), context.getSyntax(), context); } // Clean the HTML into valid XHTML if the user has asked (it's the default). if (parameters.getClean()) { normalizedContent = cleanHTML(normalizedContent, context.isInline()); } blocks = Arrays.asList((Block) new RawBlock(normalizedContent, XHTML_SYNTAX)); } else { blocks = Collections.emptyList(); } return blocks; }
@Override public List<Block> execute(HTMLMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { List<Block> blocks; if (!StringUtils.isEmpty(content)) { String normalizedContent = content; // If the user has mentioned that there's wiki syntax in the macro then we parse the content using // a wiki syntax parser and render it back using a special renderer to print the XDOM blocks into // a text representing the resulting XHTML content. if (parameters.getWiki()) { normalizedContent = renderWikiSyntax(normalizedContent, context.getTransformation(), context); } // Clean the HTML into valid XHTML if the user has asked (it's the default). if (parameters.getClean()) { normalizedContent = cleanHTML(normalizedContent, context); } else if (context.getTransformationContext().isRestricted()) { throw new MacroExecutionException( "The HTML macro may not be used with clean=\"false\" in this context."); } blocks = Arrays.asList((Block) new RawBlock(normalizedContent, XHTML_SYNTAX)); } else { blocks = Collections.emptyList(); } return blocks; }
public List<Block> execute(T parameters, String content, MacroTransformationContext context) throws MacroExecutionException { ActionContext actionContext = ActionContext.getContext(); ValueStack stack = actionContext.getValueStack(); V component = getBean(stack); Container container = Dispatcher.getInstance().getContainer(); container.inject(component); populateParams(component, parameters); if (content == null) content = ""; if (parameters.isWiki() && content.trim().length() > 0) content = renderWikiSyntax(content, context); StringWriter writer = new StringWriter(); boolean evaluateBody = component.start(writer); if (!evaluateBody) content = ""; component.end(writer, content); List<Block> wordBlockAsList = Arrays.<Block> asList(new RawBlock( writer.toString(), XHTML_SYNTAX)); // Handle both inline mode and standalone mode. if (context.isInline()) { return wordBlockAsList; } else { // Wrap the result in a Paragraph Block since a WordBlock is an inline // element and it needs to be // inside a standalone block. return Arrays.<Block> asList(new ParagraphBlock(wordBlockAsList)); } }
BlockRenderer gadgetContentRenderer = getGadgetContentRenderer(); gadgetContentRenderer.render(gadget.getContent(), printer); RawBlock rawBlock = new RawBlock(printer.toString(), getRawBlockSyntax(gadgetContentRenderer)); renderedContentBlock.addChild(rawBlock);