@Test public void a_block_processor_should_be_executed_when_registered_listing_block_is_found_in_document() throws IOException { this.asciidoctor.createGroup() .block("yell", YellStaticListingBlock.class) .register(); String content = asciidoctor.convertFile( classpath.getResource("sample-with-yell-listing-block.ad"), options().toFile(false).get()); org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8"); Elements elements = doc.getElementsByClass("paragraph"); assertThat(elements.size(), is(1)); assertThat(elements.get(0).text(), is("THE TIME IS NOW. GET A MOVE ON.")); }
@Test public void a_block_processor_as_string_should_be_executed_when_registered_block_is_found_in_document() throws IOException { this.asciidoctor.createGroup() .block("yell", "org.asciidoctor.extension.YellStaticBlock") .register(); String content = asciidoctor.convertFile( classpath.getResource("sample-with-yell-block.ad"), options().toFile(false).get()); org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8"); Elements elements = doc.getElementsByClass("paragraph"); assertThat(elements.size(), is(1)); assertThat(elements.get(0).text(), is("THE TIME IS NOW. GET A MOVE ON.")); }
@Test public void a_block_processor_instance_should_be_executed_when_registered_block_is_found_in_document() throws IOException { Map<String, Object> config = new HashMap<String, Object>(); config.put(Contexts.KEY, Arrays.asList(Contexts.PARAGRAPH)); config.put(ContentModel.KEY, ContentModel.SIMPLE); YellBlock yellBlock = new YellBlock("yell", config); this.asciidoctor.createGroup() .block(yellBlock) .register(); String content = asciidoctor.convertFile( classpath.getResource("sample-with-yell-block.ad"), options().toFile(false).get()); org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8"); Elements elements = doc.getElementsByClass("paragraph"); assertThat(elements.size(), is(1)); assertThat(elements.get(0).text(), is("THE TIME IS NOW. GET A MOVE ON.")); }
@Test public void a_block_processor_instance_should_be_executed_when_registered_listing_block_is_found_in_document() throws IOException { Map<String, Object> config = new HashMap<String, Object>(); config.put(Contexts.KEY, Arrays.asList(Contexts.LISTING)); config.put(ContentModel.KEY, ContentModel.SIMPLE); YellBlock yellBlock = new YellBlock("yell", config); this.asciidoctor.createGroup() .block(yellBlock) .register(); String content = asciidoctor.convertFile( classpath.getResource("sample-with-yell-listing-block.ad"), options().toFile(false).get()); org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8"); Elements elements = doc.getElementsByClass("paragraph"); assertThat(elements.size(), is(1)); assertThat(elements.get(0).text(), is("THE TIME IS NOW. GET A MOVE ON.")); }
@Test public void a_block_processor_should_be_executed_when_registered_block_is_found_in_document() throws IOException { this.asciidoctor.createGroup() .block("yell", YellStaticBlock.class) .register(); String content = asciidoctor.convertFile( classpath.getResource("sample-with-yell-block.ad"), options().toFile(false).get()); org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8"); Elements elements = doc.getElementsByClass("paragraph"); assertThat(elements.size(), is(1)); assertThat(elements.get(0).text(), is("THE TIME IS NOW. GET A MOVE ON.")); }
@Test @Ignore public void extensions_should_be_correctly_added_using_extension_registry() throws IOException { // To avoid registering the same extension over and over for all tests, // service is instantiated manually. this.asciidoctor.createGroup() .postprocessor(ArrowsAndBoxesIncludesPostProcessor.class) .block("arrowsAndBoxes", ArrowsAndBoxesBlock.class) .register(); Options options = options().inPlace(false).toFile(new File(testFolder.getRoot(), "rendersample.html")) .safe(SafeMode.UNSAFE).get(); asciidoctor.convertFile(classpath.getResource("arrows-and-boxes-example.ad"), options); File renderedFile = new File(testFolder.getRoot(), "rendersample.html"); org.jsoup.nodes.Document doc = Jsoup.parse(renderedFile, "UTF-8"); Element arrowsJs = doc.select("script[src=http://www.headjump.de/javascripts/arrowsandboxes.js").first(); assertThat(arrowsJs, is(notNullValue())); Element arrowsCss = doc.select("link[href=http://www.headjump.de/stylesheets/arrowsandboxes.css").first(); assertThat(arrowsCss, is(notNullValue())); Element arrowsAndBoxes = doc.select("pre[class=arrows-and-boxes").first(); assertThat(arrowsAndBoxes, is(notNullValue())); }
YellBlock yellBlock = new YellBlock("yell", config); ExtensionGroup extensionGroup = this.asciidoctor.createGroup().block(yellBlock);
YellBlock yellBlock = new YellBlock("yell", config); ExtensionGroup extensionGroup = this.asciidoctor.createGroup().block(yellBlock);