本文整理汇总了Java中org.asciidoctor.Options类的典型用法代码示例。如果您正苦于以下问题:Java Options类的具体用法?Java Options怎么用?Java Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Options类属于org.asciidoctor包,在下文中一共展示了Options类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsciiDocOptionsAndAttributes
import org.asciidoctor.Options; //导入依赖的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: options
import org.asciidoctor.Options; //导入依赖的package包/类
protected Options options() {
this.asciidocTemplates.mkdirs();
String imagesOutputDirectory = generatedDocsDirectory.getAbsolutePath();
Map<String, Object> attributes = new HashMap<>();
attributes.put("imagesoutdir", imagesOutputDirectory);
attributes.put("outdir", imagesOutputDirectory);
return OptionsBuilder.options()
.backend("html5")
.safe(UNSAFE)
.baseDir(generatedDocsDirectory)
.templateDirs(asciidocTemplates)
.attributes(attributes)
.get();
}
示例3: newAsciidocConfluencePage
import org.asciidoctor.Options; //导入依赖的package包/类
public static AsciidocConfluencePage newAsciidocConfluencePage(AsciidocPage asciidocPage, Charset sourceEncoding, Path templatesDir, Path pageAssetsFolder, PageTitlePostProcessor pageTitlePostProcessor) {
try {
Path asciidocPagePath = asciidocPage.path();
String asciidocContent = readIntoString(newInputStream(asciidocPagePath), sourceEncoding);
Map<String, String> attachmentCollector = new HashMap<>();
Options options = options(templatesDir, asciidocPagePath.getParent(), pageAssetsFolder);
String pageContent = convertedContent(asciidocContent, options, asciidocPagePath, attachmentCollector, pageTitlePostProcessor, sourceEncoding);
String pageTitle = pageTitle(asciidocContent, pageTitlePostProcessor);
return new AsciidocConfluencePage(pageTitle, pageContent, attachmentCollector);
} catch (IOException e) {
throw new RuntimeException("Could not create asciidoc confluence page", e);
}
}
示例4: options
import org.asciidoctor.Options; //导入依赖的package包/类
private static Options options(Path templatesFolder, Path baseFolder, Path generatedAssetsTargetFolder) {
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<>();
attributes.put("imagesoutdir", generatedAssetsTargetFolder.toString());
attributes.put("outdir", generatedAssetsTargetFolder.toString());
return OptionsBuilder.options()
.backend("xhtml5")
.safe(UNSAFE)
.baseDir(baseFolder.toFile())
.templateDirs(templatesFolder.toFile())
.attributes(attributes)
.get();
}
示例5: createOptions
import org.asciidoctor.Options; //导入依赖的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();
}
示例6: renderFiles
import org.asciidoctor.Options; //导入依赖的package包/类
private void renderFiles(List<String> inputFiles, ZipOutputStream zip) throws IOException {
Asciidoctor asciidoctor = JRubyAsciidoctor.create();
for (String inputFile : inputFiles) {
String outName = mapInFileToOutFile(inputFile, inExt, outExt);
File out = bazel ? new File(outName) : new File(tmpdir, outName);
if (!bazel) {
out.getParentFile().mkdirs();
}
File input = new File(inputFile);
Options options = createOptions(basedir != null ? basedir : input.getParentFile(), out);
asciidoctor.renderFile(input, options);
if (zip != null) {
zipFile(out, outName, zip);
}
}
}
示例7: createInline
import org.asciidoctor.Options; //导入依赖的package包/类
public Inline createInline(AbstractBlock parent, String context, String text, Map<String, Object> attributes, Map<String, Object> options) {
options.put(Options.ATTRIBUTES, attributes);
IRubyObject rubyClass = rubyRuntime.evalScriptlet("Asciidoctor::Inline");
RubyHash convertedOptions = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
// FIXME hack to ensure we have the underlying Ruby instance
try {
parent = parent.delegate();
} catch (Exception e) {}
Object[] parameters = {
parent,
RubyUtils.toSymbol(rubyRuntime, context),
text,
convertedOptions };
return (Inline) JavaEmbedUtils.invokeMethod(rubyRuntime, rubyClass,
"new", parameters, Inline.class);
}
示例8: extensions_should_be_correctly_added_using_extension_registry
import org.asciidoctor.Options; //导入依赖的package包/类
@Test
@Ignore
public void extensions_should_be_correctly_added_using_extension_registry() throws IOException {
// To avoid registering the same extension over and over for all tests,
// service is instantiated manually.
new ArrowsAndBoxesExtension().register(asciidoctor);
Options options = options().inPlace(false).toFile(new File(testFolder.getRoot(), "rendersample.html"))
.safe(SafeMode.UNSAFE).get();
asciidoctor.renderFile(classpath.getResource("arrows-and-boxes-example.ad"), options);
File renderedFile = new File(testFolder.getRoot(), "rendersample.html");
Document doc = Jsoup.parse(renderedFile, "UTF-8");
Element arrowsJs = doc.select("script[src=http://www.headjump.de/javascripts/arrowsandboxes.js").first();
assertThat(arrowsJs, is(notNullValue()));
Element arrowsCss = doc.select("link[href=http://www.headjump.de/stylesheets/arrowsandboxes.css").first();
assertThat(arrowsCss, is(notNullValue()));
Element arrowsAndBoxes = doc.select("pre[class=arrows-and-boxes").first();
assertThat(arrowsAndBoxes, is(notNullValue()));
}
示例9: getEngine
import org.asciidoctor.Options; //导入依赖的package包/类
private Asciidoctor getEngine(Options options) {
try {
lock.readLock().lock();
if (engine==null) {
lock.readLock().unlock();
try {
lock.writeLock().lock();
if (engine==null) {
LOGGER.info("Initializing Asciidoctor engine...");
if (options.map().containsKey(OPT_GEM_PATH)) {
engine = Asciidoctor.Factory.create(String.valueOf(options.map().get(OPT_GEM_PATH)));
} else {
engine = Asciidoctor.Factory.create();
}
if (options.map().containsKey(OPT_REQUIRES)) {
String[] requires = String.valueOf(options.map().get(OPT_REQUIRES)).split(",");
if (requires.length != 0) {
for (String require : requires) {
engine.requireLibrary(require);
}
}
}
LOGGER.info("Asciidoctor engine initialized.");
}
} finally {
lock.readLock().lock();
lock.writeLock().unlock();
}
}
} finally {
lock.readLock().unlock();
}
return engine;
}
示例10: processHeader
import org.asciidoctor.Options; //导入依赖的package包/类
@Override
public void processHeader(final ParserContext context) {
Options options = getAsciiDocOptionsAndAttributes(context);
final Asciidoctor asciidoctor = getEngine(options);
DocumentHeader header = asciidoctor.readDocumentHeader(context.getFile());
Map<String, Object> contents = context.getContents();
if (header.getDocumentTitle() != null) {
contents.put("title", header.getDocumentTitle().getCombined());
}
Map<String, Object> attributes = header.getAttributes();
for (String key : attributes.keySet()) {
if (key.startsWith("jbake-")) {
Object val = attributes.get(key);
if (val!=null) {
String pKey = key.substring(6);
contents.put(pKey, val);
}
}
if (key.equals("revdate")) {
if (attributes.get(key) != null && attributes.get(key) instanceof String) {
DateFormat df = new SimpleDateFormat(context.getConfig().getString(Keys.DATE_FORMAT));
Date date = null;
try {
date = df.parse((String)attributes.get(key));
contents.put("date", date);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
if (key.equals("jbake-tags")) {
if (attributes.get(key) != null && attributes.get(key) instanceof String) {
contents.put("tags", ((String) attributes.get(key)).split(","));
}
} else {
contents.put(key, attributes.get(key));
}
}
}
示例11: processView
import org.asciidoctor.Options; //导入依赖的package包/类
@Override
public void processView(ViewEngineContext context) throws ViewEngineException {
try (PrintWriter writer = context.getResponse().getWriter();
InputStream is = servletContext.getResourceAsStream(resolveView(context));
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
BufferedReader reader = new BufferedReader(isr)) {
Options options = new Options();
options.setAttributes(new HashMap(context.getModels()));
asciidoctor.convert(reader, writer, options);
} catch (IOException e) {
throw new ViewEngineException(e);
}
}
示例12: convertedContent
import org.asciidoctor.Options; //导入依赖的package包/类
private static String convertedContent(String adocContent, Options options, Path pagePath, Map<String, String> attachmentCollector, PageTitlePostProcessor pageTitlePostProcessor, Charset sourceEncoding) {
String content = ASCIIDOCTOR.convert(adocContent, options);
String postProcessedContent = postProcessContent(content,
replaceCrossReferenceTargets(pagePath, pageTitlePostProcessor, sourceEncoding),
collectAndReplaceAttachmentFileNames(attachmentCollector),
unescapeCdataHtmlContent()
);
return postProcessedContent;
}
示例13: i_render_the_asciidoctor_content_to_html
import org.asciidoctor.Options; //导入依赖的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);
}
示例14: createBlock
import org.asciidoctor.Options; //导入依赖的package包/类
public Block createBlock(AbstractBlock parent, String context, String content, Map<String, Object> attributes,
Map<Object, Object> options) {
options.put(Options.SOURCE, content);
options.put(Options.ATTRIBUTES, attributes);
return createBlock(parent, context, options);
}
示例15: isCopyCssActionRequired
import org.asciidoctor.Options; //导入依赖的package包/类
public boolean isCopyCssActionRequired(Map<String, Object> options) {
Map<String, Object> attributes = (Map<String, Object>) options.get(Options.ATTRIBUTES);
if (attributes != null && isCopyCssPresent(attributes)) {
// if linkcss is not present by default is considered as true.
if (isLinkCssWithValidValue(attributes)) {
if (isStylesheetWithValidValue(attributes)) {
return true;
}
}
}
return false;
}