本文整理汇总了Java中org.pegdown.Extensions.FENCED_CODE_BLOCKS属性的典型用法代码示例。如果您正苦于以下问题:Java Extensions.FENCED_CODE_BLOCKS属性的具体用法?Java Extensions.FENCED_CODE_BLOCKS怎么用?Java Extensions.FENCED_CODE_BLOCKS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.pegdown.Extensions
的用法示例。
在下文中一共展示了Extensions.FENCED_CODE_BLOCKS属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MarkdownService
public MarkdownService () {
markdownFileExtensions.add("md");
markdownFileExtensions.add("txt");
markdownFileExtensions.add("markdown");
processor = new PegDownProcessor(
Extensions.AUTOLINKS | Extensions.TABLES
| Extensions.FENCED_CODE_BLOCKS | Extensions.STRIKETHROUGH
| Extensions.ATXHEADERSPACE | Extensions.TASKLISTITEMS);
// read style sheet
InputStream inputStream = MarkdownService.class.getResourceAsStream(STYLE_SHEET_FILE);
StringWriter writer = new StringWriter();
try {
IOUtils.copy(inputStream, writer, "UTF-8");
styleSheet = writer.toString();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: parseDoc
private static void parseDoc(@NotNull String page, @NotNull File outDir) throws IOException {
outDir.mkdirs();
String source = CharStreams.toString(
new InputStreamReader(ParseDocs.class.getResourceAsStream("/pages/" + page + ".md")));
String toParse;
if (source.startsWith("#!")) {
toParse = "\n" + source.substring(source.indexOf("\n"));
} else {
toParse = source;
}
new DollarParserImpl(new ParserOptions()).parseMarkdown(toParse);
PegDownProcessor pegDownProcessor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
String result = pegDownProcessor.markdownToHtml(toParse);
Files.write(new File(outDir, page + ".html").toPath(), result.getBytes());
Files.write(new File(outDir, page + ".md").toPath(), toParse.getBytes());
System.exit(0);
}
示例3: process
public String process(String itemContent) {
itemContent = new MarkdownFootnotesProcessor(itemContent).process();
ParsedContent parsed = parseOutRawHtml(itemContent);
PegDownProcessor pegdownProcessor = new PegDownProcessor(
Extensions.FENCED_CODE_BLOCKS |
Extensions.AUTOLINKS |
Extensions.STRIKETHROUGH |
Extensions.TABLES |
Extensions.QUOTES |
Extensions.SMARTS
);
itemContent = pegdownProcessor.markdownToHtml(parsed.content);
itemContent = swapInRawHtml(itemContent, parsed);
return itemContent;
}
示例4: shouldHighlightMarkdown
@Test
public void shouldHighlightMarkdown() throws IOException {
PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
byte[] bytes = Files.readAllBytes(Paths.get("src/test/resources/markdown", "java1.md"));
String markdown = new String(bytes, StandardCharsets.UTF_8);
String html = processor.markdownToHtml(markdown);
System.out.println(html);
}
示例5: extensions
public static int extensions() {
int EXT = Extensions.NONE;
EXT |= Extensions.FENCED_CODE_BLOCKS;
EXT |= Extensions.TABLES;
EXT |= Extensions.STRIKETHROUGH;
// EXT |= Extensions.SMARTS; // Breaks link including a dash -
return EXT;
}
示例6: test
@Test
public void test() throws IOException {
try {
PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
RootNode rootNode = processor.parseMarkdown(FileUtils.readFileToString(new File("README.tmpl.md")).toCharArray());
rootNode.accept(new DocTestingVisitor());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
示例7: compile
public static String compile(String src) {
PegDownProcessor processor = new PegDownProcessor(Extensions.AUTOLINKS | Extensions.FENCED_CODE_BLOCKS);
String replaced = expandSpaceForLi(src);
String html = processor.markdownToHtml(replaced);
String cleanedHtml = Jsoup.clean(html, Whitelist.relaxed());
return cleanedHtml;
}
示例8: makeHelpText
private void makeHelpText(ScriptFieldAnswer answer, Pane parent) {
TextFlow flow = new TextFlow();
DataType fieldDataType = answer.getField().getDataType();
if (fieldDataType instanceof DataType.Enumeration) {
StringBuilder b = new StringBuilder();
String last = "";
for (String v : ((DataType.Enumeration)fieldDataType).getValues()) {
if (b.length() > 0) {
b.append(", ");
}
b.append(last);
last = v;
}
if (b.length() > 0) {
b.append(" or ");
}
b.append(last);
getJavaFxParent(flow).addChild(new Text("Possible values: " + b + "\n"));
}
MarkdownToJavafx mdToFx = new MarkdownToJavafx(this.getJavaFxParent(flow));
PegDownProcessor mdProcessor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
if (answer.getField().getDescription() != null) {
RootNode node = mdProcessor.parseMarkdown(answer.getField().getDescription().toCharArray());
node.accept(mdToFx);
}
parent.getChildren().add(flow);
flow.setMaxWidth(350);
//helpText = helpText.trim();
//helpText.replace('\n', ' ');
//helpText.replace('\t', ' ');
//Text help = new Text(answer.getField().getDescription());
//RootNode node = mdProcessor.parseMarkdown(answer.getField().getDescription().toCharArray());
////help.getStyleClass().add("help");
//return help;
}
示例9: parseMarkdown
@Override
@NotNull
public Value parseMarkdown(@NotNull String source) {
PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
RootNode rootNode = processor.parseMarkdown(source.toCharArray());
rootNode.accept(new CodeExtractionVisitor());
return $();
}
示例10: extensionFor
private int extensionFor(String name) {
int extension = Extensions.NONE;
if (name.equals("HARDWRAPS")) {
extension = Extensions.HARDWRAPS;
} else if (name.equals("AUTOLINKS")) {
extension = Extensions.AUTOLINKS;
} else if (name.equals("FENCED_CODE_BLOCKS")) {
extension = Extensions.FENCED_CODE_BLOCKS;
} else if (name.equals("DEFINITIONS")) {
extension = Extensions.DEFINITIONS;
} else if (name.equals("ABBREVIATIONS")) {
extension = Extensions.ABBREVIATIONS;
} else if (name.equals("QUOTES")) {
extension = Extensions.QUOTES;
} else if (name.equals("SMARTS")) {
extension = Extensions.SMARTS;
} else if (name.equals("SMARTYPANTS")) {
extension = Extensions.SMARTYPANTS;
} else if (name.equals("SUPPRESS_ALL_HTML")) {
extension = Extensions.SUPPRESS_ALL_HTML;
} else if (name.equals("SUPPRESS_HTML_BLOCKS")) {
extension = Extensions.SUPPRESS_HTML_BLOCKS;
} else if (name.equals("SUPPRESS_INLINE_HTML")) {
extension = Extensions.SUPPRESS_INLINE_HTML;
} else if (name.equals("TABLES")) {
extension = Extensions.TABLES;
} else if (name.equals("WIKILINKS")) {
extension = Extensions.WIKILINKS;
} else if (name.equals("ANCHORLINKS")) {
extension = Extensions.ANCHORLINKS;
} else if (name.equals("STRIKETHROUGH")) {
extension = Extensions.STRIKETHROUGH;
}else if (name.equals("ATXHEADERSPACE")) {
extension = Extensions.ATXHEADERSPACE;
}else if (name.equals("FORCELISTITEMPARA")) {
extension = Extensions.FORCELISTITEMPARA;
}else if (name.equals("RELAXEDHRULES")) {
extension = Extensions.RELAXEDHRULES;
}else if (name.equals("TASKLISTITEMS")) {
extension = Extensions.TASKLISTITEMS;
}else if (name.equals("EXTANCHORLINKS")) {
extension = Extensions.EXTANCHORLINKS;
} else if (name.equals("ALL")) {
extension = Extensions.ALL;
} else if (name.equals("ALL_OPTIONALS")) {
extension = Extensions.ALL_OPTIONALS;
} else if (name.equals("ALL_WITH_OPTIONALS")) {
extension = Extensions.ALL_WITH_OPTIONALS;
}
return extension;
}
示例11: PluginParser
public PluginParser() {
super(Extensions.FENCED_CODE_BLOCKS | Extensions.WIKILINKS, 1000L, Parser.DefaultParseRunnerProvider);
}
示例12: parseDescriptionFromMarkdown
private static VBox parseDescriptionFromMarkdown(final String markdown) {
final VBox result = new VBox();
final PegDownProcessor processor = new PegDownProcessor(Extensions.STRIKETHROUGH | Extensions.FENCED_CODE_BLOCKS);
final RootNode rootNode = processor.parseMarkdown(markdown.toCharArray());
// PanelUtil.visit(rootNode, "");
final MarkdownVisitor visitor = new MarkdownVisitor();
visitor.pushNode(result);
rootNode.accept(visitor);
result.getStylesheets().add("/styles/markdown.css");
result.setMaxWidth(200);
result.layout();
return result;
}
示例13: exec
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
if (arguments.size() != 1)
{
throw new TemplateModelException("Error, method expects one argument (String)");
}
SimpleScalar freemarkerArg = (SimpleScalar) arguments.get(0);
String markdownSource = freemarkerArg.getAsString();
SoftReference<String> cachedResult = cache.get(markdownSource);
String cachedResultString;
if (cachedResult != null && (cachedResultString = cachedResult.get()) != null)
{
return cachedResultString;
}
try
{
// build the plugins object with our extensions
PegDownPlugins plugins = PegDownPlugins.builder().build();
PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS, MAX_PARSING_TIME_MILLIS, plugins);
// build the node and then serialize it so that we can make sure the serializer uses our plugins
RootNode outputNode = processor.parseMarkdown(markdownSource.toCharArray());
// Our plugin is also a serializer, so build a plugins list for serialization as well
List<ToHtmlSerializerPlugin> serializerPlugins = new ArrayList<>(1);
ToHtmlSerializer serializer = new ToHtmlSerializerExtended(new LinkRenderer(), Collections.<String, VerbatimSerializer> emptyMap(),
serializerPlugins);
String result = serializer.toHtml(outputNode);
cache.put(markdownSource, new SoftReference<>(result));
return result;
}
catch (Throwable t)
{
LOG.log(Level.WARNING, "Failed to parse markdown due to: " + t.getMessage() + " markdown source: " + markdownSource, t);
// Return the unformatted markdown, as this is better than failing the report completely.
return markdownSource;
}
}