Java Code Examples for org.asciidoctor.ast.Document#getBlocks()
The following examples show how to use
org.asciidoctor.ast.Document#getBlocks() .
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: WhenAsciiDocIsRenderedToDocument.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void should_get_attributes() { final String documentWithAttributes = "= Document Title\n" + ":docattr: docvalue\n" + "\n" + "preamble\n" + "\n" + "== Section A\n" + "\n" + "paragraph\n" + "\n"; Document document = asciidoctor.load(documentWithAttributes, new HashMap<String, Object>()); List<StructuralNode> blocks = document.getBlocks(); Section section = (Section) blocks.get(1); section.setAttribute("testattr", "testvalue", true); assertThat(document.hasAttribute("testattr"), is(false)); assertThat(section.hasAttribute("testattr"), is(true)); assertThat(section.hasAttribute("testattr", true), is(true)); assertThat(section.hasAttribute("testattr", false), is(true)); assertThat(section.isAttribute("testattr", "testvalue"), is(true)); assertThat(section.hasAttribute("docattr", true), is(true)); assertThat(section.hasAttribute("docattr", false), is(false)); }
Example 2
Source File: WhenAsciiDocIsRenderedToDocument.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void should_get_content_model() { final String documentWithPreambleAndSection = "" + "= Document Title\n" + "\n" + "A test document with a preamble and a section.\n" + "\n" + "The preamble contains multiple paragraphs to force the outer block to be compound.\n" + "\n" + "== First Section\n" + "\n" + "And herein lies the problem.\n" + "\n"; Document document = asciidoctor.load(documentWithPreambleAndSection, new HashMap<String, Object>()); List<StructuralNode> blocks = document.getBlocks(); StructuralNode preambleContainer = blocks.get(0); assertThat(preambleContainer.getContentModel(), is("compound")); assertThat(preambleContainer.getBlocks().get(0).getContentModel(), is("simple")); assertThat(preambleContainer.getBlocks().get(1).getContentModel(), is("simple")); Section section = (Section) blocks.get(1); assertThat(section.getContentModel(), is("compound")); assertThat(section.getBlocks().get(0).getContentModel(), is("simple")); }