@Test public void shouldAllowLoadingByClassName() { final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry(); registry.postprocessor(BoldifyPostProcessor.class.getCanonicalName()); }
@Test public void shouldAllowLoadingByClass() { final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry(); registry.postprocessor(BoldifyPostProcessor.class); }
@Override public void register(Asciidoctor asciidoctor) { JavaExtensionRegistry javaExtensionRegistry = asciidoctor.javaExtensionRegistry(); javaExtensionRegistry.postprocessor(ArrowsAndBoxesIncludesPostProcessor.class); javaExtensionRegistry.block("arrowsAndBoxes", ArrowsAndBoxesBlock.class); }
@Test public void shouldAllowLoadingUsingInstance() { final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry(); registry.postprocessor(new unusual.extension.BoldifyPostProcessor()); }
@Test public void a_postprocessor_instance_should_be_executed_after_document_is_rendered() throws IOException { JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry(); javaExtensionRegistry.postprocessor(new CustomFooterPostProcessor(new HashMap<>())); Options options = options().inPlace(false).toFile(new File(testFolder.getRoot(), "rendersample.html")) .safe(SafeMode.UNSAFE).get(); asciidoctor.convertFile(classpath.getResource("rendersample.asciidoc"), options); File renderedFile = new File(testFolder.getRoot(), "rendersample.html"); org.jsoup.nodes.Document doc = Jsoup.parse(renderedFile, "UTF-8"); Element footer = doc.getElementById("footer-text"); assertThat(footer.text(), containsString("Copyright Acme, Inc.")); }
@Test public void a_postprocessor_as_string_should_be_executed_after_document_is_rendered() throws IOException { JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry(); javaExtensionRegistry.postprocessor("org.asciidoctor.extension.CustomFooterPostProcessor"); Options options = options().inPlace(false).toFile(new File(testFolder.getRoot(), "rendersample.html")) .safe(SafeMode.UNSAFE).get(); asciidoctor.convertFile(classpath.getResource("rendersample.asciidoc"), options); File renderedFile = new File(testFolder.getRoot(), "rendersample.html"); org.jsoup.nodes.Document doc = Jsoup.parse(renderedFile, "UTF-8"); Element footer = doc.getElementById("footer-text"); assertThat(footer.text(), containsString("Copyright Acme, Inc.")); }
@Test public void a_postprocessor_should_be_executed_after_document_is_rendered() throws IOException { JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry(); javaExtensionRegistry.postprocessor(CustomFooterPostProcessor.class); Options options = options().inPlace(false).toFile(new File(testFolder.getRoot(), "rendersample.html")) .safe(SafeMode.UNSAFE).get(); asciidoctor.convertFile(classpath.getResource("rendersample.asciidoc"), options); File renderedFile = new File(testFolder.getRoot(), "rendersample.html"); org.jsoup.nodes.Document doc = Jsoup.parse(renderedFile, "UTF-8"); Element footer = doc.getElementById("footer-text"); assertThat(footer.text(), containsString("Copyright Acme, Inc.")); }
@Test public void should_unregister_all_current_registered_extensions() throws IOException { JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry(); javaExtensionRegistry.postprocessor(CustomFooterPostProcessor.class); Options options = options().inPlace(false).toFile(new File(testFolder.getRoot(), "rendersample.html")) .safe(SafeMode.UNSAFE).get(); asciidoctor.unregisterAllExtensions(); asciidoctor.convertFile(classpath.getResource("rendersample.asciidoc"), options); File renderedFile = new File(testFolder.getRoot(), "rendersample.html"); org.jsoup.nodes.Document doc = Jsoup.parse(renderedFile, "UTF-8"); Element footer = doc.getElementById("footer-text"); assertThat(footer.text(), not(containsString("Copyright Acme, Inc."))); }
@Test public void should_render_comments_as_notes() { //tag::include[] File doc = //... //end::include[] classpathResources.getResource("comment.adoc"); //tag::include[] asciidoctor.javaExtensionRegistry().postprocessor(CopyrightFooterPostprocessor.class); // <1> String result = asciidoctor.convertFile(doc, OptionsBuilder.options() .headerFooter(true) // <2> .toFile(false)); assertThat(result, containsString(CopyrightFooterPostprocessor.COPYRIGHT_NOTICE)); //end::include[] }