/** * {@inheritDoc} * * @see org.xwiki.rendering.listener.Listener#endMacroMarker(java.lang.String, java.util.Map, java.lang.String, * boolean) */ public void endMacroMarker(String name, Map<String, String> macroParameters, String content, boolean isInline) { this.stack.push(new MacroMarkerBlock(name, macroParameters, content, generateListFromStack(), isInline)); }
/** * @param block the block to test * @return true if the passed block is a protected block or false otherwise */ private boolean isProtectedBlock(Block block) { return (block instanceof MacroMarkerBlock) && ((MacroMarkerBlock) block).getId().equals("code"); } }
/** * Add a footnote to the list of document footnotes. If such a list doesn't exist yet, create it and append it to * the end of the document. * * @param footnoteMacro the {{footnote}} macro being processed * @param footnoteRef the generated block corresponding to the footnote to be inserted */ private void addFootnoteRef(MacroMarkerBlock footnoteMacro, Block footnoteRef) { footnoteMacro.getChildren().clear(); footnoteMacro.addChild(footnoteRef); }
/** * {@inheritDoc} * * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener) */ public void before(Listener listener) { listener.beginMacroMarker(getName(), getParameters(), getContent(), isInline()); }
new MacroMarkerBlock(htmlMacroBlock.getId(), htmlMacroBlock.getParameters(), htmlMacroBlock.getContent(), xdom.getChildren(), htmlMacroBlock.isInline()); } finally { htmlMacroMarker.getParent().replaceChild(htmlMacroBlock, htmlMacroMarker); for (Block block : htmlMacroMarker.getChildren()) { block.traverse(renderer);
new MacroMarkerBlock(htmlMacroBlock.getId(), htmlMacroBlock.getParameters(), htmlMacroBlock .getContent(), xdom.getChildren(), htmlMacroBlock.isInline()); htmlMacroMarker.setParent(htmlMacroBlock.getParent()); for (Block block : htmlMacroMarker.getChildren()) { block.traverse(renderer);
/** * Indicate if the provided macro is an include macro with the provided included document. * * @param parentMacro the macro block to check * @param completeReference the document reference to compare to * @return true if the documents are the same */ // TODO: Add support for any kind of macro including content linked to a reference private boolean isRecursive(MacroMarkerBlock parentMacro, EntityReference completeReference) { if (parentMacro.getId().equals("include")) { IncludeMacroParameters macroParameters = getParameters(parentMacro.getParameters()); return completeReference.equals(this.macroEntityReferenceResolver.resolve(macroParameters.getReference(), macroParameters.getType(), parentMacro)); } return false; }
for (ListIterator<MacroMarkerBlock> it = footnotes.listIterator(); it.hasNext();) { MacroMarkerBlock macro = it.next(); if (FootnoteMacro.MACRO_NAME.equals(macro.getId())) { continue; } else if (PutFootnotesMacro.MACRO_NAME.equals(macro.getId())) { macro.getParent().replaceChild(Collections.<Block>emptyList(), macro);
MacroMarkerBlock parent = context.getCurrentMacroBlock().getParentBlockByType(MacroMarkerBlock.class); while (parent != null) { String parentId = parent.getId(); try { Macro< ? > macro = this.macroManager.getMacro(new MacroId(parentId)); parent = parent.getParentBlockByType(MacroMarkerBlock.class);
new ClassBlockMatcher(MacroMarkerBlock.class), Block.Axes.ANCESTOR); while (parent != null) { String parentId = parent.getId(); try { Macro< ? > macro = this.macroManager.getMacro(new MacroId(parentId)); parent = parent.getFirstBlock(new ClassBlockMatcher(MacroMarkerBlock.class), Block.Axes.ANCESTOR);
/** * Processes a {{footnote}} macro, by generating a footnote element to insert in the footnote list and a reference * to it, which is placed instead of the macro call. * * @param footnoteMacro the {{footnote}} macro element * @param counter the current footnote counter * @param context the execution context of the macro * @return the footnote element which should be inserted in the footnote list * @throws MacroExecutionException if the footnote content cannot be further processed */ private ListItemBlock processFootnote(MacroMarkerBlock footnoteMacro, int counter, MacroTransformationContext context) throws MacroExecutionException { String content = footnoteMacro.getContent(); if (StringUtils.isBlank(content)) { content = " "; } // Construct the footnote and reference blocks Block referenceBlock = createFootnoteReferenceBlock(counter); ListItemBlock footnoteBlock = createFootnoteBlock(content, counter, context); // Insert the footnote and the reference in the document. if (referenceBlock != null && footnoteBlock != null) { addFootnoteRef(footnoteMacro, referenceBlock); return footnoteBlock; } return null; }
/** * {@inheritDoc} * * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener) */ public void after(Listener listener) { listener.endMacroMarker(getName(), getParameters(), getContent(), isInline()); } }
/** * Wrap the output of a macro block with a {@link MacroMarkerBlock}. * * @param macroBlockToWrap the block that should be replaced * @param newBlocks list of blocks to wrap * @return the wrapper */ private Block wrapInMacroMarker(MacroBlock macroBlockToWrap, List<Block> newBlocks) { return new MacroMarkerBlock(macroBlockToWrap.getId(), macroBlockToWrap.getParameters(), macroBlockToWrap.getContent(), newBlocks, macroBlockToWrap.isInline()); }
/** * @return the macro name. * @deprecated since 2.4M1 use {@link #getId()} instead */ @Deprecated public String getName() { return getId(); }
/** * Wrap the output of a macro block with a {@link MacroMarkerBlock}. * * @param macroBlockToWrap the block that should be replaced * @param newBlocks list of blocks to wrap * @return the wrapper */ private Block wrapInMacroMarker(MacroBlock macroBlockToWrap, List<Block> newBlocks) { return new MacroMarkerBlock(macroBlockToWrap.getId(), macroBlockToWrap.getParameters(), macroBlockToWrap .getContent(), newBlocks, macroBlockToWrap.isInline()); }
/** * Wrap the output of a macro block with a {@link org.xwiki.rendering.block.MacroMarkerBlock}. * * @param macroBlockToWrap the block that should be replaced * @param newBlocks list of blocks to wrap * @return the wrapper */ private Block wrapInMacroMarker(MacroBlock macroBlockToWrap, List<Block> newBlocks) { return new MacroMarkerBlock(macroBlockToWrap.getId(), macroBlockToWrap.getParameters(), macroBlockToWrap.getContent(), newBlocks, macroBlockToWrap.isInline()); } }
new MacroMarkerBlock(wikiMacroBlock.getId(), wikiMacroBlock.getParameters(), wikiMacroBlock.getContent(), macroXDOM.getChildren(), wikiMacroBlock.isInline());