private Options buildOptions(DocletOptions docletOptions, DocErrorReporter errorReporter) { OptionsBuilder opts = defaultOptions(); if (docletOptions.baseDir().isPresent()) { opts.baseDir(docletOptions.baseDir().get()); } if (templates.isPresent()) { opts.templateDir(templates.get().templateDir()); } opts.attributes(buildAttributes(docletOptions, errorReporter)); if (docletOptions.requires().size() > 0) { for (String require : docletOptions.requires()) { asciidoctor.rubyExtensionRegistry().requireLibrary(require); } } return opts.get(); }
@Test public void ruby_postprocessor_should_be_registered() { final String rubyExtPath = classpath.getResource("ruby-extensions").getAbsolutePath(); final Asciidoctor asciidoctor = Asciidoctor.Factory.create(singletonList(rubyExtPath)); asciidoctor.rubyExtensionRegistry() .requireLibrary("xml-entity-postprocessor.rb") .postprocessor("XmlEntityPostprocessor"); String content = asciidoctor.convert( "Read §2 and it'll all be clear.", options().toFile(false).get()); assertThat(content, containsString("Read §2 and it'll all be clear.")); }
@Test public void ruby_treeprocessor_should_be_registered() { final String rubyExtPath = classpath.getResource("ruby-extensions").getAbsolutePath(); final Asciidoctor asciidoctor = Asciidoctor.Factory.create(singletonList(rubyExtPath)); asciidoctor.rubyExtensionRegistry() .requireLibrary("shell-session-tree-processor.rb") .treeprocessor("ShellSessionTreeProcessor"); String content = asciidoctor.convert( " $ echo \"Hello, World!\"\n" + " > Hello, World!\n" + "\n" + " $ gem install asciidoctor", options().toFile(false).get()); final Document document = Jsoup.parse(content); final TextNode commandElement = document.getElementsByClass("command").get(0).textNodes().get(0); assertThat(commandElement.getWholeText(), is("echo \"Hello, World!\"")); final TextNode commandElement2 = document.getElementsByClass("command").get(1).textNodes().get(0); assertThat(commandElement2.getWholeText(), is("gem install asciidoctor")); }
final Asciidoctor asciidoctor = Asciidoctor.Factory.create(singletonList(rubyExtPath)); asciidoctor.rubyExtensionRegistry() .requireLibrary("front-matter-preprocessor.rb") .preprocessor("FrontMatterPreprocessor");
final Asciidoctor asciidoctor = Asciidoctor.Factory.create(singletonList(rubyExtPath)); asciidoctor.rubyExtensionRegistry() .requireLibrary("view-result-docinfoprocessor.rb") .docinfoProcessor("ViewResultDocinfoProcessor");