/** * {@inheritDoc} * * @see org.xwiki.rendering.listener.Listener#onWord(java.lang.String) */ public void onWord(String word) { this.stack.push(new WordBlock(word)); }
@Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { // Find all Word blocks and for each of them check if they're a wiki word or not for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } } }
/** * {@inheritDoc} * * @see java.lang.Object#toString() * @since 1.8RC2 */ @Override public String toString() { return getWord(); } }
/** * {@inheritDoc} * * @see AbstractBlock#traverse(Listener) */ public void traverse(Listener listener) { listener.onWord(getWord()); }
/** * {@inheritDoc} * * @see org.wikimodel.wem.IWemListener#onWord(String) */ public void onWord(String str) { this.stack.push(new WordBlock(str)); }
/** * {@inheritDoc} * @see AbstractTransformation#transform(Block, TransformationContext) */ public void transform(Block block, TransformationContext transformationContext) throws TransformationException { // Find all Word blocks and for each of them check if they're a wiki word or not for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } } }
private void generateError(MacroBlock macroToReplace, String message, String description) { List<Block> errorBlocks = new ArrayList<Block>(); Map<String, String> errorBlockParams = Collections.singletonMap("class", "xwikirenderingerror"); Map<String, String> errorDescriptionBlockParams = Collections.singletonMap("class", "xwikirenderingerrordescription hidden"); Block descriptionBlock = new VerbatimBlock(description, macroToReplace.isInline()); if (macroToReplace.isInline()) { errorBlocks.add(new FormatBlock(Arrays.<Block> asList(new WordBlock(message)), Format.NONE, errorBlockParams)); errorBlocks.add(new FormatBlock(Arrays.asList(descriptionBlock), Format.NONE, errorDescriptionBlockParams)); } else { errorBlocks.add(new GroupBlock(Arrays.<Block> asList(new WordBlock(message)), errorBlockParams)); errorBlocks.add(new GroupBlock(Arrays.asList(descriptionBlock), errorDescriptionBlockParams)); } macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace); }
/** * Generate the footnote reference (link) that should be inserted at the location of the macro, and should point to * the actual footnote at the end of the document. * * @param counter the current footnote counter * @return the generated reference element, displayed as {@code (superscript(link(footnote index)))} */ private Block createFootnoteReferenceBlock(int counter) { Block result = new WordBlock(String.valueOf(counter)); DocumentResourceReference reference = new DocumentResourceReference(null); reference.setAnchor(FOOTNOTE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result = new FormatBlock(Collections.singletonList(result), Format.SUPERSCRIPT); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_REFERENCE_ID_PREFIX + counter); result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteRef"); return result; }
list.add(new Substitution(block, new WordBlock(value))); return list;
parsedContent = this.contentParser.parse(content, context, false, true).getChildren(); } catch (MacroExecutionException e) { parsedContent = Collections.<Block>singletonList(new WordBlock(content)); Block result = new WordBlock("^"); DocumentResourceReference reference = new DocumentResourceReference(null); reference.setAnchor(FOOTNOTE_REFERENCE_ID_PREFIX + counter);
result = new WordBlock(content);
sourcePageBlock.addChild(new WordBlock(sourceDoc.getName())); sourcePageBlock.setParameter(classParameterName, DashboardMacro.SOURCE_PAGE); metadataContainer.addChild(sourcePageBlock); GroupBlock sourceSpaceBlock = new GroupBlock(); sourceSpaceBlock.addChild(new WordBlock( this.localReferenceSerializer.serialize(sourceDoc.getLastSpaceReference()))); sourceSpaceBlock.setParameter(classParameterName, DashboardMacro.SOURCE_SPACE); metadataContainer.addChild(sourceSpaceBlock); GroupBlock sourceWikiBlock = new GroupBlock(); sourceWikiBlock.addChild(new WordBlock(sourceDoc.getWikiReference().getName())); sourceWikiBlock.setParameter(classParameterName, DashboardMacro.SOURCE_WIKI); metadataContainer.addChild(sourceWikiBlock);