@Test public void sect_num_levels_attribute_should_only_number_levels_up_to_value_defined_by_sectnumlevels_attribute() throws IOException { Attributes attributes = attributes().sectionNumbers(true).sectNumLevels(2).get(); Options options = options().inPlace(false).safe(SafeMode.UNSAFE) .toDir(testFolder.getRoot()).attributes(attributes).get(); asciidoctor.convertFile(classpath.getResource("multiple_levels.asciidoc"), options); Document doc = Jsoup.parse(new File(testFolder.getRoot(), "multiple_levels.html"), "UTF-8"); assertThat(doc.getElementById("_level_1").text(), startsWith("1.")); assertThat(doc.getElementById("_level_2").text(), startsWith("1.1.")); assertThat(doc.getElementById("_level_3").text(), not(startsWith("1.1.1."))); assertThat(doc.getElementById("_level_4").text(), not(startsWith("1.1.1.1."))); }
attributesBuilder.sectionNumbers(this.sectionNumbers);
@Test public void api_parameters_should_be_transformed_to_cli_command() { AttributesBuilder attributesBuilder = AttributesBuilder.attributes() .attribute("myAtribute", "myValue").sectionNumbers(true) .copyCss(false); OptionsBuilder optionsBuilder = OptionsBuilder.options() .backend("docbook").templateDirs(new File("a"), new File("b")) .safe(SafeMode.UNSAFE).attributes(attributesBuilder.get()); String command = AsciidoctorUtils.toAsciidoctorCommand( optionsBuilder.asMap(), "file.adoc"); String currentDirectory = new File( "" ).getAbsolutePath() + File.separator; String parametersString = command.substring(command.indexOf(" "), command.length()); String[] parameters = parametersString.split(" "); AsciidoctorCliOptions asciidoctorCliOptions = new AsciidoctorCliOptions(); new JCommander(asciidoctorCliOptions, parameters); assertThat(asciidoctorCliOptions.getTemplateDir(), containsInAnyOrder(currentDirectory+"a", currentDirectory+"b")); assertThat(asciidoctorCliOptions.getSafeMode(), is(SafeMode.UNSAFE)); assertThat(asciidoctorCliOptions.getBackend(), is("docbook")); assertThat(asciidoctorCliOptions.getParameters(), containsInAnyOrder("file.adoc")); assertThat(asciidoctorCliOptions.getAttributes(), hasEntry("myAtribute", (Object)"myValue")); assertThat(asciidoctorCliOptions.getAttributes(), hasKey("numbered")); assertThat(asciidoctorCliOptions.getAttributes(), hasKey("copycss!")); }
attributesBuilder.sectionNumbers(this.sectionNumbers);
attributesBuilder.sectionNumbers(this.sectionNumbers);