@Test public void testWikiWordTransformationIgnoresProtectedContent() throws Exception { String expected = "beginDocument\n" + "beginMacroMarkerStandalone [code] []\n" + "onWord [WikiWord]\n" + "endMacroMarkerStandalone [code] []\n" + "endDocument"; XDOM xdom = new XDOM(Arrays.asList((Block) new MacroMarkerBlock("code", Collections.<String, String>emptyMap(), Arrays.asList((Block) new WordBlock("WikiWord")), false))); this.wikiWordTransformation.transform(xdom, new TransformationContext()); WikiPrinter printer = new DefaultWikiPrinter(); BlockRenderer eventBlockRenderer = this.componentManager.getInstance(BlockRenderer.class, Syntax.EVENT_1_0.toIdString()); eventBlockRenderer.render(xdom, printer); Assert.assertEquals(expected, printer.toString()); }
@Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { 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); } } }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { 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); } } } }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { 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); } } }  }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { 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); } } }  @Override void transform(Block block, TransformationContext transformationContext); }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { 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); } } }  @Override void transform(Block block, TransformationContext transformationContext);  }