org.asciidoctor.OptionsBuilder Java Examples

The following examples show how to use org.asciidoctor.OptionsBuilder. 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: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_return_default_configuration_when_site_xml_is_null() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();

    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(null, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();
    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES);
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
    assertThat(configuration.getRequires()).isEmpty();
}
 
Example #2
Source File: CukedoctorMojo.java    From cukedoctor with Apache License 2.0 6 votes vote down vote up
private void generateDocumentation(DocumentAttributes documentAttributes, File adocFile, Asciidoctor asciidoctor) {
    
    OptionsBuilder ob = OptionsBuilder.options()
            .safe(SafeMode.UNSAFE)
            .backend(documentAttributes.getBackend())
            .attributes(documentAttributes.toMap());
    getLog().info("Document attributes:\n"+documentAttributes.toMap());
    ExtensionGroup cukedoctorExtensionGroup = asciidoctor.createGroup(CUKEDOCTOR_EXTENSION_GROUP_NAME);
    if ("pdf".equals(documentAttributes.getBackend())) {
        cukedoctorExtensionGroup.unregister();
        //remove auxiliary files
        FileUtil.removeFile(adocFile.getParent() + "/" + outputFileName + "-theme.yml");
    }
    asciidoctor.convertFile(adocFile, ob);

    getLog().info("Generated documentation at: " + adocFile.getParent());
}
 
Example #3
Source File: AsciidocConfluencePage.java    From confluence-publisher with Apache License 2.0 6 votes vote down vote up
private static Options options(Path templatesFolder, Path baseFolder, Path generatedAssetsTargetFolder, Map<String, Object> userAttributes) {
    if (!exists(templatesFolder)) {
        throw new RuntimeException("templateDir folder does not exist");
    }

    if (!isDirectory(templatesFolder)) {
        throw new RuntimeException("templateDir folder is not a folder");
    }

    Map<String, Object> attributes = new HashMap<>(userAttributes);
    attributes.put("imagesoutdir", generatedAssetsTargetFolder.toString());
    attributes.put("outdir", generatedAssetsTargetFolder.toString());
    attributes.put("source-highlighter", "none");

    return OptionsBuilder.options()
            .backend("xhtml5")
            .safe(UNSAFE)
            .baseDir(baseFolder.toFile())
            .templateDirs(templatesFolder.toFile())
            .attributes(attributes)
            .get();
}
 
Example #4
Source File: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_remove_empty_and_blank_requires() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();
    Xpp3Dom siteConfig = Xpp3DoomBuilder.asciidocNode()
            .addChild("requires")
            .addChild("require", "gem_1,,gem_2", "", ",,", "gem_3")
            .build();

    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(siteConfig, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();
    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES);
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
    assertThat(configuration.getRequires())
            .containsExactlyInAnyOrder("gem_1", "gem_2", "gem_3");
}
 
Example #5
Source File: AbstractAsciiDocMojo.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
private Map<String, Object> asciiDoctorOptions(
        Map<String, Object> attributes,
        Path inputRelativePath,
        File outputDirectory,
        Path baseDirPath,
        boolean runPreprocessing) {
    final OptionsBuilder optionsBuilder = OptionsBuilder.options()
            .attributes(
                    AttributesBuilder
                            .attributes()
                            .attributes(attributes))
            .safe(SafeMode.UNSAFE)
            .headerFooter(false)
            .baseDir(baseDirPath.toFile())
            .eruby("");
    if (outputDirectory != null) {
        optionsBuilder.option("preincludeOutputPath",
                    outputDirectory.toPath().resolve(inputRelativePath));
    }
    if (runPreprocessing) {
        optionsBuilder.option("preprocessOutputType", outputType());
    }

    return optionsBuilder.asMap();
}
 
Example #6
Source File: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_return_baseDir_dirs_when_defined_as_template_dirs_dir() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();
    Xpp3Dom siteConfig = Xpp3DoomBuilder.asciidocNode()
            .addChild("baseDir", "path")
            .build();

    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(siteConfig, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();

    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES, BASEDIR);
    assertThat(optionsMap.get(BASEDIR))
            .isEqualTo(new File("path").getAbsolutePath());
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
}
 
Example #7
Source File: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_return_default_configuration_when_asciidoc_xml_is_null() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();
    Xpp3Dom siteConfig = Xpp3DoomBuilder.siteNode()
            .build();
    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(siteConfig, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();
    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES);
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
    assertThat(configuration.getRequires()).isEmpty();
}
 
Example #8
Source File: OptionsTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void convert_to_dedicated_file() throws Exception {
//tag::optionToFile[]
        File targetFile = //...
//end::optionToFile[]
        temporaryFolder.newFile("toFileExample.html");

//tag::optionToFile[]
        asciidoctor.convert(
                "Hello World",
                OptionsBuilder.options()
                        .toFile(targetFile)    // <1>
                        .safe(SafeMode.UNSAFE) // <2>
                        .get());

        assertTrue(targetFile.exists());
        assertThat(
                IOUtils.toString(new FileReader(targetFile)),
                containsString("<p>Hello World"));
//end::optionToFile[]
    }
 
Example #9
Source File: OptionsTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void convert_in_unsafe_mode() throws Exception {
//tag::unsafeConversion[]
        File sourceFile =
//end::unsafeConversion[]
/*  We don't want to show the reader that we're getting the document via a classpath resources instance,
    nor do we want to expose the filesystem structure of our build.
    The reader should not care where the content comes from.
//tag::unsafeConversion[]
            new File("includingcontent.adoc");
//end::unsafeConversion[]
*/
                classpathResources.getResource("includingcontent.adoc");
//tag::unsafeConversion[]
        String result = asciidoctor.convertFile(
                sourceFile,
                OptionsBuilder.options()
                        .safe(SafeMode.UNSAFE) // <1>
                        .toFile(false)         // <2>
                        .get());

        assertThat(result, containsString("This is included content"));
//end::unsafeConversion[]
    }
 
Example #10
Source File: OptionsTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void options_for_pdf_document() throws Exception {
//tag::optionsPDFBackend[]
        File targetFile = // ...
//end::optionsPDFBackend[]
        temporaryFolder.newFile("test.pdf");
        assertTrue(targetFile.exists());
//tag::optionsPDFBackend[]
        asciidoctor.convert(
                "Hello World",
                OptionsBuilder.options()
                        .backend("pdf")
                        .toFile(targetFile)
                        .safe(SafeMode.UNSAFE)
                        .get());

        assertThat(targetFile.length(), greaterThan(0L));
//end::optionsPDFBackend[]
    }
 
Example #11
Source File: TextConverterTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void should_use_text_converter_for_conversion(@ArquillianResource Asciidoctor asciidoctor) {

//tag::include[]
        File test_adoc = //...
//end::include[]
            classpathResources.getResource("textconvertertest.adoc");

//tag::include[]

        asciidoctor.javaConverterRegistry().register(TextConverter.class); // <1>

        String result = asciidoctor.convertFile(
                test_adoc,
                OptionsBuilder.options()
                        .backend("text")                                   // <2>
                        .toFile(false));

//end::include[]

        verifyResult(result);
    }
 
Example #12
Source File: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_return_multiple_requires() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();
    Xpp3Dom siteConfig = Xpp3DoomBuilder.asciidocNode()
            .addChild("requires")
            .addChild("require", "gem_1", "gem_2", "gem_3")
            .build();

    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(siteConfig, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();
    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES);
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
    assertThat(configuration.getRequires())
            .containsExactlyInAnyOrder("gem_1", "gem_2", "gem_3");
}
 
Example #13
Source File: RobotsDocinfoProcessorTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void should_create_anchor_elements_for_inline_macros() {

//tag::include[]
        String src = "= Irrelevant content";

        asciidoctor.javaExtensionRegistry()
                .docinfoProcessor(RobotsDocinfoProcessor.class); // <1>

        String result = asciidoctor.convert(
                src,
                OptionsBuilder.options()
                        .headerFooter(true)                      // <2>
                        .safe(SafeMode.SERVER)                   // <3>
                        .toFile(false));

        org.jsoup.nodes.Document document = Jsoup.parse(result); // <4>
        Element metaElement = document.head().children().last();
        assertThat(metaElement.tagName(), is("meta"));
        assertThat(metaElement.attr("name"), is("robots"));
        assertThat(metaElement.attr("content"), is("index,follow"));
//end::include[]
    }
 
Example #14
Source File: HighlightJsHighlighterTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
public void should_invoke_syntax_highlighter_with_3_params() throws Exception {
    File sources_adoc =
        classpathResources.getResource("sources.adoc");


    asciidoctor.syntaxHighlighterRegistry()
        .register(org.asciidoctor.integrationguide.syntaxhighlighter.threeparams.HighlightJsHighlighter.class, "myhighlightjs");

    String result = asciidoctor.convertFile(sources_adoc,
        OptionsBuilder.options()
            .headerFooter(true)
            .toFile(false)
            .attributes(AttributesBuilder.attributes().sourceHighlighter("myhighlightjs")));

    assertThat(result,
        containsString("<script>hljs.initHighlighting()</script>"));
}
 
Example #15
Source File: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_return_multiple_requires_when_defined_in_single_element() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();
    Xpp3Dom siteConfig = Xpp3DoomBuilder.asciidocNode()
            .addChild("requires")
            .addChild("require", "gem_1,gem_2, gem_3")
            .build();

    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(siteConfig, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();
    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES);
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
    assertThat(configuration.getRequires())
            .containsExactlyInAnyOrder("gem_1", "gem_2", "gem_3");
}
 
Example #16
Source File: CommentPreprocessorTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void should_render_comments_as_notes() {

//tag::include[]
        File comment_adoc = //...
//end::include[]
            classpathResources.getResource("comment.adoc");

//tag::include[]
        File comment_with_note_adoc = //...
//end::include[]
            classpathResources.getResource("comment-with-note.adoc");
//tag::include[]
        asciidoctor.javaExtensionRegistry().preprocessor(CommentPreprocessor.class);      // <1>

        String result1 = asciidoctor.convertFile(comment_adoc, OptionsBuilder.options().toFile(false));
        String result2 = asciidoctor.convertFile(comment_with_note_adoc, OptionsBuilder.options().toFile(false));

        assertThat(result1, is(result2)); // <2>
//end::include[]
    }
 
Example #17
Source File: HighlightJsHighlighterTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void should_invoke_formatting_syntax_highlighter() throws Exception {
        File sources_adoc =
            classpathResources.getResource("sources.adoc");


//tag::includeformatter[]

        asciidoctor.syntaxHighlighterRegistry()
            .register(HighlightJsWithLanguageHighlighter.class, "myhighlightjs");

        String result = asciidoctor.convertFile(sources_adoc,
            OptionsBuilder.options()
                .headerFooter(true)
                .toFile(false)
                .attributes(AttributesBuilder.attributes().sourceHighlighter("myhighlightjs")));

        assertThat(result,
            containsString("<script>hljs.initHighlighting()</script>"));
        assertThat(result,
            containsString("<code class='java'>public static class Test"));
//end::includeformatter[]
    }
 
Example #18
Source File: CopyrightFooterPostprocessorTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@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[]
    }
 
Example #19
Source File: AsciidocEngine.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
/**
 * Read a document's header.
 * @param source the document to read the header from
 * @return the header as {@code Map<String, Object>}, never {@code null}
 */
public Map<String, Object> readDocumentHeader(File source){
    checkValidFile(source, "source");
    final OptionsBuilder optionsBuilder = OptionsBuilder.options()
            .attributes(
                    AttributesBuilder
                            .attributes()
                            .attributes(attributes))
            .safe(SafeMode.UNSAFE)
            .headerFooter(false)
            .eruby("")
            .baseDir(source.getParentFile())
            .option("parse_header_only", true);
    if (backend != null) {
        optionsBuilder.backend(this.backend);
    }
    Document doc = asciidoctor.loadFile(source, optionsBuilder.asMap());
    Map<String, Object> headerMap = new HashMap<>();
    String h1 = parseSection0Title(source);
    if (h1 != null) {
        headerMap.put("h1", h1);
    }
    headerMap.putAll(doc.getAttributes());
    return headerMap;
}
 
Example #20
Source File: SiteConversionConfigurationParserTest.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void should_return_simple_single_requires() {
    // given
    final MavenProject project = fakeProject();
    OptionsBuilder emptyOptions = OptionsBuilder.options();
    AttributesBuilder emptyAttributes = AttributesBuilder.attributes();
    Xpp3Dom siteConfig = Xpp3DoomBuilder.asciidocNode()
            .addChild("requires")
            .addChild("require", "gem")
            .build();

    // when
    SiteConversionConfiguration configuration = new SiteConversionConfigurationParser(project)
            .processAsciiDocConfig(siteConfig, emptyOptions, emptyAttributes);

    // then
    final Map<String, Object> optionsMap = configuration.getOptions().map();
    assertThat(optionsMap).containsOnlyKeys(ATTRIBUTES);
    assertThat((Map) optionsMap.get(ATTRIBUTES)).isEmpty();
    assertThat(configuration.getRequires())
            .containsExactly("gem");
}
 
Example #21
Source File: YellBlockProcessorTest.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Test
    public void should_invoke_block_processor() throws Exception {
//tag::include[]
        File yellblock_adoc = //...
//end::include[]
            classpathResources.getResource("yell-block.adoc");

        //tag::include[]

        asciidoctor.javaExtensionRegistry().block(YellBlockProcessor.class); // <1>

        String result = asciidoctor.convertFile(yellblock_adoc, OptionsBuilder.options().toFile(false));

        assertThat(result, containsString("I REALLY MEAN IT"));              // <2>
//end::include[]
    }
 
Example #22
Source File: AsciidoctorInterface.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
    public void autocloseAsciidoctorInstance() {
//tag::autoclose[]
        try (Asciidoctor asciidoctor = Asciidoctor.Factory.create()) {
            asciidoctor.convert("Hello World", OptionsBuilder.options());
        }
//end::autoclose[]
    }
 
Example #23
Source File: BlockProcessorRegistrationTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterNamedClassAsClassWithExplicitName() {
    final String explicitblockname = "explicitblockname";
    asciidoctor.javaExtensionRegistry().block(explicitblockname, AnnotatedTestProcessor.class);
    final String result = asciidoctor.convert(document(explicitblockname, "Hello Explicit"), OptionsBuilder.options());
    check("H e l l o E x p l i c i t", result);
}
 
Example #24
Source File: WhenDocumentIsRenderedWithPreloading.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void coderay_gem_should_be_preloaded() {

    Map<String, Object> options = OptionsBuilder.options()
            .attributes(AttributesBuilder.attributes().sourceHighlighter("coderay").get()).asMap();

    ((JRubyAsciidoctor) asciidoctor).rubyGemsPreloader.preloadRequiredLibraries(options);
    RubyBoolean evalScriptlet = (RubyBoolean) ((JRubyAsciidoctor) asciidoctor).rubyRuntime.evalScriptlet("require 'coderay'");
    assertThat(evalScriptlet.isFalse(), is(true));

}
 
Example #25
Source File: InlineMacroRegistrationTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterClassWithNameAsClassWithExplicitName() {
    final String explicitblockname = "explicitblockname";
    asciidoctor.javaExtensionRegistry().inlineMacro(explicitblockname, TestProcessorWithName.class);
    final String result = asciidoctor.convert(document(explicitblockname, "Explicit"), OptionsBuilder.options());
    check("Hello EXPLICIT", result);
}
 
Example #26
Source File: BlockMacroRegistrationTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterClassAsClassWithExplicitName() {
    final String explicitblockname = "anotherexplicitname";
    asciidoctor.javaExtensionRegistry().blockMacro(explicitblockname, AbstractTestProcessor.class);
    final String result = asciidoctor.convert(document(explicitblockname, "Hello Explicit Class"), OptionsBuilder.options());
    check("HELLO EXPLICIT CLASS", result);
}
 
Example #27
Source File: BlockProcessorRegistrationTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterClassAsClassWithExplicitName() {
    final String explicitblockname = "anotherexplicitname";
    asciidoctor.javaExtensionRegistry().block(explicitblockname, AbstractTestProcessor.class);
    final String result = asciidoctor.convert(document(explicitblockname, "Hello Explicit Class"), OptionsBuilder.options());
    check("H e l l o E x p l i c i t C l a s s", result);
}
 
Example #28
Source File: BlockMacroRegistrationTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterClassWithNameAsInstanceWithExplicitName() {
    final String blockName = "somename";
    asciidoctor.javaExtensionRegistry().blockMacro(blockName, new TestProcessorWithName());
    final String result = asciidoctor.convert(document(blockName, "Yet Another Test"), OptionsBuilder.options());
    check("YET ANOTHER TEST", result);
}
 
Example #29
Source File: InlineMacroRegistrationTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterNamedClassAsClassWithExplicitName() {
    final String explicitblockname = "explicitblockname";
    asciidoctor.javaExtensionRegistry().inlineMacro(explicitblockname, AnnotatedTestProcessor.class);
    final String result = asciidoctor.convert(document(explicitblockname, "Explicit"), OptionsBuilder.options());
    check("Hello EXPLICIT", result);
}
 
Example #30
Source File: PrismJsHighlighterTest.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Test
    public void should_invoke_syntax_highlighter() throws Exception {
//tag::include[]
        File sources_adoc = //...
//end::include[]
            classpathResources.getResource("sources.adoc");

//tag::include[]
        File toDir = // ...
//end::include[]
            tempDir.newFolder();
//tag::include[]

        //tag::include[]
        asciidoctor.syntaxHighlighterRegistry()
            .register(PrismJsHighlighter.class, "prismjs"); // <1>

        asciidoctor.convertFile(sources_adoc,
            OptionsBuilder.options()
                .headerFooter(true)
                .toDir(toDir)
                .safe(SafeMode.UNSAFE)
                .attributes(AttributesBuilder.attributes()
                    .sourceHighlighter("prismjs")           // <1>
                    .copyCss(true)
                    .linkCss(true)));

        File docFile = new File(toDir, "sources.html");

        Document document = Jsoup.parse(new File(toDir, "sources.html"), "UTF-8");
        Elements keywords = document.select("div.content pre.highlight code span.token.keyword"); // <2>
        assertThat(keywords, not(empty()));
        assertThat(keywords.first().text(), is("public"));
//end::include[]
    }