/** * {@inheritDoc} * * @see org.xwiki.rendering.listener.Listener#endParagraph(java.util.Map) */ public void endParagraph(Map<String, String> parameters) { this.stack.push(new ParagraphBlock(generateListFromStack(), parameters)); }
public void endParagraph(WikiParameters params) { this.stack.push(new ParagraphBlock(generateListFromStack(), convertParameters(params))); }
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)); } }
@Override public List<Block> execute(ChartMacroParameters macroParams, String content, MacroTransformationContext context) throws MacroExecutionException { // Generate the chart image in a temporary location. generateChart(macroParams, content, context); String imageLocation = this.imageWriter.getURL(new ImageId(macroParams)); String title = macroParams.getTitle(); ResourceReference reference = new ResourceReference(imageLocation, ResourceType.URL); ImageBlock imageBlock = new ImageBlock(new ResourceReference(imageLocation, ResourceType.URL), true); imageBlock.setParameter("alt", title); LinkBlock linkBlock = new LinkBlock(Collections.singletonList((Block) imageBlock), reference, true); linkBlock.setParameter("title", title); // If the macro is used standalone then we need to wrap it in a paragraph block. Block resultBlock; if (context.isInline()) { resultBlock = linkBlock; } else { resultBlock = new ParagraphBlock(Collections.singletonList((Block) linkBlock)); } return Collections.singletonList(resultBlock); }
result = new ParagraphBlock(Collections.<Block> singletonList(result));