本文整理汇总了Java中org.asciidoctor.SafeMode类的典型用法代码示例。如果您正苦于以下问题:Java SafeMode类的具体用法?Java SafeMode怎么用?Java SafeMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeMode类属于org.asciidoctor包,在下文中一共展示了SafeMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parameters
import org.asciidoctor.SafeMode; //导入依赖的package包/类
/**
* Create the Map in order to configure the converter.
* @param optsBuilder
* @param converter
* @param outputFilename
* @return
*/
private Map<String, Object> parameters(OptionsBuilder optsBuilder, Converter converter,
String outputFilename){
OptionsBuilder opts = optsBuilder
.backend(converter.toString())
.safe(SafeMode.UNSAFE).headerFooter(true);
//.inPlace(true);
if (outputFilename != null) {
opts.toFile(new File(outputDir + outputFilename + converter.getFilenameExtension()));
}
//For now the PDF converter can only write to a file
else if (outputFilename == null && converter == Converter.pdf) {
opts.toFile(new File(outputDir + "temp.pdf"));
} else {
opts.toFile(false);
}
return opts.asMap();
}
示例2: generateDocumentation
import org.asciidoctor.SafeMode; //导入依赖的package包/类
private void generateDocumentation(DocumentAttributes documentAttributes, File adocFile, Asciidoctor asciidoctor) {
OptionsBuilder ob;
ob = OptionsBuilder.options().backend(documentAttributes.getBackend());
ob.safe(SafeMode.UNSAFE);
if (allowUriRead) {
Attributes attr = new Attributes();
attr.setAllowUriRead(true);
ob.attributes(attr);
}
if ("pdf".equals(documentAttributes.getBackend())) {
asciidoctor.unregisterAllExtensions();
}
asciidoctor.convertFile(adocFile, ob);
//remove auxiliary files
if ("pdf".equals(documentAttributes.getBackend())) {
FileUtil.removeFile(adocFile.getParent() + "/" + outputFileName + "-theme.yml");
}
getLog().info("Generated documentation at: " + adocFile.getParent());
}
示例3: createOptions
import org.asciidoctor.SafeMode; //导入依赖的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();
}
示例4: test
import org.asciidoctor.SafeMode; //导入依赖的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());
}
示例5: a_docinfoprocessor_should_be_executed_and_add_meta_in_footer
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void a_docinfoprocessor_should_be_executed_and_add_meta_in_footer() {
JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry();
Map<String, Object> options = new HashMap<String, Object>();
options.put("location", ":footer");
MetaRobotsDocinfoProcessor metaRobotsDocinfoProcessor = new MetaRobotsDocinfoProcessor(options);
javaExtensionRegistry.docinfoProcessor(metaRobotsDocinfoProcessor);
String content = asciidoctor.renderFile(
classpath.getResource("simple.adoc"),
options().headerFooter(true).safe(SafeMode.SERVER).toFile(false).get());
Document doc = Jsoup.parse(content, "UTF-8");
Element footer = doc.getElementById("footer");
// Since Asciidoctor 1.5.3 the docinfo in the footer is a sibling to the footer element
assertTrue("robots".equals(footer.nextElementSibling().attr("name")));
}
示例6: extensions_should_be_correctly_added_using_extension_registry
import org.asciidoctor.SafeMode; //导入依赖的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()));
}
示例7: generateDocumentation
import org.asciidoctor.SafeMode; //导入依赖的package包/类
protected synchronized void generateDocumentation(List<Feature> features, DocumentAttributes attrs, String outputPath, Asciidoctor asciidoctor) {
asciidoctor.unregisterAllExtensions();
if (!attrs.getBackend().equalsIgnoreCase("pdf")) {
new CukedoctorExtensionRegistry().register(asciidoctor);
}
CukedoctorConverter converter = Cukedoctor.instance(features, attrs);
String doc = converter.renderDocumentation();
File adocFile = FileUtil.saveFile(outputPath + "/documentation.adoc", doc);
asciidoctor.convertFile(adocFile, OptionsBuilder.options().backend(attrs.getBackend()).safe(SafeMode.UNSAFE).asMap());
}
示例8: should_convert_adoc_to_html
import org.asciidoctor.SafeMode; //导入依赖的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));
}
示例9: shouldAddCustomCssToRenderedHtml
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldAddCustomCssToRenderedHtml(){
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
String customCssPath = Paths.get("").toAbsolutePath() + "/target/cukedoctor.css";
FileUtil.copyFileFromClassPath("/cukedoctor-test.css", customCssPath);
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertThat(sampleHtml).isNotEmpty().
containsOnlyOnce("<style> body #toctitle { color: green;}body.book { background: #444;}</style>");
}
示例10: shouldDisableStyleExtension
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldDisableStyleExtension(){
System.setProperty(STYLE_DISABLE_EXT_KEY,"anyValue");
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertThat(sampleHtml).isNotEmpty().
doesNotContain(".sidebarblock, .sectionbody, .content{overflow:auto!important;}");
}
示例11: shouldAddFooterToRenderedHtml
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldAddFooterToRenderedHtml(){
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
System.setProperty("cukedoctor.stopwatch",String.valueOf(System.currentTimeMillis()));
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertThat(sampleHtml.replaceAll("\n","").replace("\t","")).isNotEmpty().
containsOnlyOnce("Generated by <a href=\"https://github.com/rmpestano/cukedoctor\" target=\"_blank\"> Cukedoctor").
containsOnlyOnce("Execution time: ");
}
示例12: shouldNotAddFooterToRenderedHtmlWhenExtensionDisabled
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldNotAddFooterToRenderedHtmlWhenExtensionDisabled(){
System.setProperty(FOOTER_DISABLE_EXT_KEY,"anyValue");
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
System.setProperty("cukedoctor.stopwatch",String.valueOf(System.currentTimeMillis()));
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertThat(sampleHtml.replaceAll("\n","").replace("\t","")).isNotEmpty().
doesNotContain("Generated by <a href=\"https://github.com/rmpestano/cukedoctor\" target=\"_blank\"> Cukedoctor").
doesNotContain("Execution time: ");
}
示例13: shouldAddSearchInputToRenderedHtml
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldAddSearchInputToRenderedHtml(){
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertNotNull(sampleHtml);
assertThat(sampleHtml.replaceAll(" ","").replaceAll("\n", "").replaceAll("\t","")).
containsOnlyOnce(removeSpecialChars("<span class=\"fa fa-minus-square fa-fw\" style=\"cursor:pointer;float:right;margin-top:-30px\" title=\"Minimize\" onclick=\"hideFeatureScenarios('Sample-test');document.getElementById('hidden-Sample-test').style.display = 'inline';this.style.display = 'none'\"> </span>") +
removeSpecialChars("<span id=\"hidden-Sample-test\" class=\"fa fa-plus-square fa-fw\" style=\"cursor:pointer;float:right;display:none;margin-top:-30px\" title=\"Maximize feature\" onclick=\"showFeatureScenarios('Sample-test');this.style.display = 'none'\"> </span>"));
}
示例14: shouldNotAddMinMaxMacroToRenderedHtmlWhenExtensionDisabled
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldNotAddMinMaxMacroToRenderedHtmlWhenExtensionDisabled(){
System.setProperty(MINMAX_DISABLE_EXT_KEY,"anyValue");
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertNotNull(sampleHtml);
assertThat(sampleHtml).
doesNotContain(removeSpecialChars("title=\"Maximize feature\""));
}
示例15: shouldAddThemesToRenderedHtml
import org.asciidoctor.SafeMode; //导入依赖的package包/类
@Test
public void shouldAddThemesToRenderedHtml(){
System.clearProperty(THEME_DISABLE_EXT_KEY);
File sampleAdoc = loadTestFile("sample.adoc");
assertThat(sampleAdoc).exists();
asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());
String sampleHtml = readFileContent(loadTestFile("sample.html"));
assertThat(sampleHtml).isNotEmpty().
containsOnlyOnce("<div name=\"themes\" id=\"themes\"");
}