本文整理汇总了Java中org.asciidoctor.AttributesBuilder类的典型用法代码示例。如果您正苦于以下问题:Java AttributesBuilder类的具体用法?Java AttributesBuilder怎么用?Java AttributesBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributesBuilder类属于org.asciidoctor包,在下文中一共展示了AttributesBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsciiDocOptionsAndAttributes
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
private Options getAsciiDocOptionsAndAttributes(ParserContext context) {
Configuration config = context.getConfig();
final AttributesBuilder attributes = attributes(config.getStringArray(Keys.ASCIIDOCTOR_ATTRIBUTES));
if (config.getBoolean(Keys.ASCIIDOCTOR_ATTRIBUTES_EXPORT, false)) {
final String prefix = config.getString( Keys.ASCIIDOCTOR_ATTRIBUTES_EXPORT_PREFIX, "");
for (final Iterator<String> it = config.getKeys(); it.hasNext();) {
final String key = it.next();
if (!key.startsWith("asciidoctor")) {
attributes.attribute(prefix + key.replace(".", "_"), config.getProperty(key));
}
}
}
final Configuration optionsSubset = config.subset(Keys.ASCIIDOCTOR_OPTION);
final Options options = options().attributes(attributes.get()).get();
for (final Iterator<String> iterator = optionsSubset.getKeys(); iterator.hasNext();) {
final String name = iterator.next();
if (name.equals(Options.TEMPLATE_DIRS)) {
options.setTemplateDirs(optionsSubset.getString(name));
} else {
options.setOption(name, guessTypeByContent(optionsSubset.getString(name)));
}
}
options.setBaseDir(context.getFile().getParentFile().getAbsolutePath());
options.setSafe(UNSAFE);
return options;
}
示例2: createOptions
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
private Options createOptions(File base, File outputFile) {
OptionsBuilder optionsBuilder = OptionsBuilder.options();
optionsBuilder
.backend(backend)
.docType(DOCTYPE)
.eruby(ERUBY)
.safe(SafeMode.UNSAFE)
.baseDir(base)
.toFile(outputFile);
AttributesBuilder attributesBuilder = AttributesBuilder.attributes();
attributesBuilder.attributes(getAttributes());
if (revnumber != null) {
attributesBuilder.attribute(REVNUMBER_NAME, revnumber);
}
optionsBuilder.attributes(attributesBuilder.get());
return optionsBuilder.get();
}
示例3: test
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
@Test
public void test() throws IOException {
folder.create();
Asciidoctor asciidoctor = Asciidoctor.Factory.create();
asciidoctor.javaExtensionRegistry().block(
SdEditBlockProcessor.SDEDIT_BLOCK_NAME,
SdEditBlockProcessor.class);
asciidoctor.javaExtensionRegistry().blockMacro(
SdEditBlockMacroProcessor.SDEDIT_BLOCK_MACRO_NAME,
SdEditBlockMacroProcessor.class);
File baseDir = new File("src/test/resources");
File adoc = new File(baseDir, "sdinclude.adoc");
File destDir = folder.newFolder();
AttributesBuilder attributes = AttributesBuilder.attributes()
.attribute("outdir", destDir.getAbsolutePath());
OptionsBuilder options = OptionsBuilder.options().safe(SafeMode.UNSAFE)
.mkDirs(true).toDir(destDir).destinationDir(destDir)
.baseDir(baseDir).attributes(attributes);
asciidoctor.convertFile(adoc, options.asMap());
assertTrue(new File(destDir, "sdinclude.html").exists());
assertTrue(new File(destDir, "testdiagram.png").exists());
assertTrue(new File(destDir, "fromblock.svg").exists());
}
示例4: should_convert_adoc_to_html
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
public void should_convert_adoc_to_html() throws URISyntaxException,
DeploymentException, IOException, InterruptedException {
Map<String, Object> parameters;
parameters = options()
.backend("html5")
.safe(SafeMode.UNSAFE).headerFooter(true)
.eruby("erubis")
.attributes(
AttributesBuilder.attributes()
.attribute("icons!", "")
.attribute("allow-uri-read")
.attribute("copycss!", "").asMap())
.asMap();
AsciidoctorProcessor asciidoctor = new AsciidoctorProcessor();
asciidoctor.init();
final String result = asciidoctor.getDelegate().render(dataConvertToPDF, parameters);
assertNotNull(result);
assertEquals(result.contains("<h1>Document Title"), true);
long start = System.currentTimeMillis();
final String result2 = asciidoctor.getDelegate().convert(getResourceAsString("adoc/websocket.adoc"), parameters);
assertNotNull(result2);
System.out.println("time : " + (System.currentTimeMillis() - start));
}
示例5: generate
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
public String generate(final Entry entry, final boolean oneLine) {
final AttributesBuilder attributes = AttributesBuilder.attributes().linkAttrs(true);
final OptionsBuilder options = OptionsBuilder.options().attributes(attributes);
final String content = oneLine ? generateOneLine(entry) : generateContent(entry);
return asciidoctor.convert(content, options);
}
示例6: testGenerate
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
@Test
public void testGenerate() {
final String expectedSource = "++++\n<div class=\"sect1\">\n++++\n" +
"++++\n<span class=\"note\">Published on 2014-12-12</span>\n++++\n" +
"++++\n<h2><a href=\"/entries/test_entry\">Test entry</a></h2>\n++++\n" +
"Lorem ipsum dolor sit amet + \n" +
"link:/entries/test_entry[\"more\", role=\"more\"]\n++++\n</div>\n++++\n";
final OptionsBuilder options = OptionsBuilder.options().attributes(AttributesBuilder.attributes().linkAttrs(true));
final String expectedOutput = asciidoctor.convert(expectedSource, options);
final String actualOutput = classUnderTest.generate(new Entry("Lorem ipsum dolor sit amet", "Test entry", "2014-12-12", "/entries/test_entry"), false);
assertEquals(expectedOutput, actualOutput);
}
示例7: testGenerateOneLine
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
@Test
public void testGenerateOneLine() {
final String expectedSource ="link:/entries/test_entry[\"Test entry\"]\n";
final OptionsBuilder options = OptionsBuilder.options().attributes(AttributesBuilder.attributes().linkAttrs(true));
final String expectedOutput = asciidoctor.convert(expectedSource, options);
final String actualOutput = classUnderTest.generate(new Entry("Lorem ipsum dolor sit amet", "Test entry", "2014-12-12", "/entries/test_entry"), true);
assertEquals(expectedOutput, actualOutput);
}
示例8: i_render_the_asciidoctor_content_to_html
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
@When("^I render the asciidoctor content to html$")
public void i_render_the_asciidoctor_content_to_html() throws Throwable {
Attributes attrs = AttributesBuilder.attributes()
.attribute("outdir", outputFolder.getAbsolutePath()).get();
Options options = OptionsBuilder.options().safe(SafeMode.UNSAFE)
.attributes(attrs).mkDirs(true).toDir(outputFolder)
.destinationDir(outputFolder).baseDir(inputFolder)
.backend("html5").get();
asciidocOutputFile = new File(outputFolder,
FilenameUtils.getBaseName(asciidocInputFile.getAbsolutePath())
+ ".html");
asciidoctor.convertFile(asciidocInputFile, options);
}
示例9: when_using_a_tree_processor_a_toc_should_still_be_created_when_rendering_to_html
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
/**
* See https://github.com/asciidoctor/asciidoctorj/issues/497.
*/
@Test
public void when_using_a_tree_processor_a_toc_should_still_be_created_when_rendering_to_html() {
JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry();
javaExtensionRegistry.treeprocessor(TouchEverythingTreeprocessor.class);
String content = asciidoctor.renderFile(
classpath.getResource("sample-with-sections.ad"),
options().toFile(false)
.backend("html")
.attributes(AttributesBuilder.attributes().tableOfContents(true))
.get());
}
示例10: when_using_a_tree_processor_a_toc_should_still_be_created_when_rendering_to_docbook
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
@Test
public void when_using_a_tree_processor_a_toc_should_still_be_created_when_rendering_to_docbook() {
JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry();
javaExtensionRegistry.treeprocessor(TouchEverythingTreeprocessor.class);
String content = asciidoctor.renderFile(
classpath.getResource("sample-with-sections.ad"),
options().toFile(false)
.backend("docbook")
.attributes(AttributesBuilder.attributes().tableOfContents(true))
.get());
}
示例11: api_parameters_should_be_transformed_to_cli_command
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
@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!"));
}
示例12: getDefaultOptions
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
private Map<String, Object> getDefaultOptions() {
Attributes attrs = AttributesBuilder.attributes().showTitle(true)
.sourceHighlighter("coderay").attribute("coderay-css", "style")
.attribute("env", "idea").attribute("env-idea").get();
if (imagesPath != null) {
final AsciiDocApplicationSettings settings = AsciiDocApplicationSettings.getInstance();
if (settings.getAsciiDocPreviewSettings().getHtmlPanelProviderInfo().getClassName().equals(JavaFxHtmlPanelProvider.class.getName())) {
attrs.setAttribute("outdir", imagesPath.toAbsolutePath().normalize().toString());
}
}
OptionsBuilder opts = OptionsBuilder.options().safe(SafeMode.UNSAFE).backend("html5").headerFooter(false).attributes(attrs).option("sourcemap", "true")
.baseDir(baseDir);
return opts.asMap();
}
示例13: attributes
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
private AttributesBuilder attributes() {
return AttributesBuilder.attributes()
.backend("html");
}
示例14: options
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
private OptionsBuilder options(AttributesBuilder attributesBuilder) {
return OptionsBuilder.options()
.attributes(attributesBuilder);
}
示例15: parse
import org.asciidoctor.AttributesBuilder; //导入依赖的package包/类
public Options parse() {
OptionsBuilder optionsBuilder = OptionsBuilder.options();
AttributesBuilder attributesBuilder = AttributesBuilder.attributes();
optionsBuilder.backend(this.backend).safe(this.safeMode).eruby(this.eruby);
if (isDoctypeOption()) {
optionsBuilder.docType(this.doctype);
}
if (isOutFileOption() && !isOutputStdout()) {
optionsBuilder.toFile(new File(this.outFile));
}
if (isOutFileOption() && isOutputStdout()) {
optionsBuilder.toFile(false);
}
if (this.safe) {
optionsBuilder.safe(SafeMode.SAFE);
}
if (this.noHeaderFooter) {
optionsBuilder.headerFooter(false);
}
if (this.sectionNumbers) {
attributesBuilder.sectionNumbers(this.sectionNumbers);
}
if (this.compact) {
optionsBuilder.compact(this.compact);
}
if (isBaseDirOption()) {
optionsBuilder.baseDir(new File(this.baseDir));
}
if (isTemplateEngineOption()) {
optionsBuilder.templateEngine(this.templateEngine);
}
if (isTemplateDirOption()) {
for (String templateDir : this.templateDir) {
optionsBuilder.templateDir(new File(templateDir));
}
}
if (isDestinationDirOption() && !isOutputStdout()) {
optionsBuilder.toDir(new File(this.destinationDir));
}
if (isInPlaceRequired()) {
optionsBuilder.inPlace(true);
}
if (this.verbose) {
optionsBuilder.option(MONITOR_OPTION_NAME, new HashMap<Object, Object>());
}
attributesBuilder.attributes(getAttributes());
optionsBuilder.attributes(attributesBuilder.get());
return optionsBuilder.get();
}