Java Code Examples for org.asciidoctor.Asciidoctor#convert()
The following examples show how to use
org.asciidoctor.Asciidoctor#convert() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WhenRubyExtensionGroupIsRegistered.java From asciidoctorj with Apache License 2.0 | 6 votes |
@Test public void ruby_postprocessor_should_be_registered() { final String rubyExtPath = classpath.getResource("ruby-extensions").getAbsolutePath(); final Asciidoctor asciidoctor = JRubyAsciidoctor.create(singletonList(rubyExtPath)); asciidoctor.createGroup() .requireRubyLibrary("xml-entity-postprocessor.rb") .rubyPostprocessor("XmlEntityPostprocessor") .register(); String content = asciidoctor.convert( "Read §2 and it'll all be clear.", options().toFile(false).get()); System.out.println(content); assertThat(content, containsString("Read §2 and it'll all be clear.")); }
Example 2
Source File: AsciidoctorInvoker.java From asciidoctorj with Apache License 2.0 | 5 votes |
private String renderInput(Asciidoctor asciidoctor, Options options, List<File> inputFiles) { if(inputFiles.size() == 1 && "-".equals(inputFiles.get(0).getName())) { return asciidoctor.convert(readInputFromStdIn(), options); } StringBuilder output = new StringBuilder(); for (File inputFile : inputFiles) { if (inputFile.canRead()) { String renderedFile = asciidoctor .convertFile(inputFile, options); if (renderedFile != null) { output.append(renderedFile).append( System.getProperty("line.separator")); } } else { System.err.println("asciidoctor: FAILED: input file(s) '" + inputFile.getAbsolutePath() + "' missing or cannot be read"); throw new IllegalArgumentException( "asciidoctor: FAILED: input file(s) '" + inputFile.getAbsolutePath() + "' missing or cannot be read"); } } return output.toString(); }
Example 3
Source File: WhenRubyExtensionGroupIsRegistered.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void ruby_docinfoprocessor_should_be_registered() { final String rubyExtPath = classpath.getResource("ruby-extensions").getAbsolutePath(); final Asciidoctor asciidoctor = JRubyAsciidoctor.create(singletonList(rubyExtPath)); asciidoctor.createGroup() .requireRubyLibrary("view-result-docinfoprocessor.rb") .rubyDocinfoProcessor("ViewResultDocinfoProcessor") .register(); String content = asciidoctor.convert( "= View Result Sample \n" + " \n" + ".This will have a link next to it\n" + "---- \n" + "* always displayed \n" + "* always displayed 2 \n" + "---- \n" + " \n" + "[.result] \n" + "==== \n" + "* hidden till clicked \n" + "* hidden till clicked 2 \n" + "==== ", options().toFile(false).safe(SafeMode.SAFE).headerFooter(true).get()); final Document document = Jsoup.parse(content); final Iterator<Element> elems = document.getElementsByTag("style").iterator(); boolean found = false; while (elems.hasNext()) { final Element styleElem = elems.next(); if (styleElem.toString().contains(".listingblock a.view-result")) { found = true; } } assertTrue("Could not find style element that should have been added by docinfo processor:\n" + document, found); }
Example 4
Source File: WhenTheInlineMacroProcessorRunsTwice.java From asciidoctorj with Apache License 2.0 | 4 votes |
private String convert(Asciidoctor asciidoctor) { return asciidoctor.convert("example:alpha.bravo[format=test]", Collections.emptyMap()); }