Java Code Examples for com.vladsch.flexmark.util.options.MutableDataSet#set()

The following examples show how to use com.vladsch.flexmark.util.options.MutableDataSet#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocumentationGenerator.java    From TestingApp with Apache License 2.0 6 votes vote down vote up
public String getInstructionsAsHTML() {
    MutableDataSet options = new MutableDataSet();

    // uncomment to set optional extensions
    //options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create()));

    // uncomment to convert soft-breaks to hard breaks
    options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");

    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();

    String markdown = getInstructionsAsMarkdown();

    // You can re-use parser and renderer instances
    Node document = parser.parse(markdown);
    return renderer.render(document);
}
 
Example 2
Source File: MarkDownModel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected String load() {
    String markDownValue = markDawnModel.getObject();
    if (Strings.isEmpty(markDownValue)) {
        return "";
    }
    try {
        MutableDataSet options = new MutableDataSet();
        options.set(Parser.EXTENSIONS, createExtensions());
        Parser parser = Parser.builder(options).build();
        HtmlRenderer renderer = HtmlRenderer.builder(options).build();

        Node node = parser.parse(markDawnModel.getObject());
        markDownValue = renderer.render(node);
    } catch (Exception e) {
        throw new WicketRuntimeException("Can't use flexmark-java for markups", e);
    }
    return markDownValue;
}
 
Example 3
Source File: Markdown2HtmlUtil.java    From plumemo with Apache License 2.0 5 votes vote down vote up
/**
 * Markdownz转为Html
 * @param content
 * @return
 */
public static String html(String content){

    MutableDataSet options = new MutableDataSet();
    options.setFrom(ParserEmulationProfile.MARKDOWN);
    options.set(Parser.EXTENSIONS, Arrays.asList(new Extension[]{TablesExtension.create()}));
    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();
    Node document = parser.parse(content);

    return renderer.render(document);
}
 
Example 4
Source File: PMarkdownOptions.java    From jphp with Apache License 2.0 5 votes vote down vote up
public MutableDataSet getNativeOptions() {
    MutableDataSet dataSet = new MutableDataSet();
    dataSet.set(Parser.EXTENSIONS, parserExtensions);

    for (Entry<DataKey, Object> entry : options.getAll().entrySet()) {
        dataSet.set(entry.getKey(), entry.getValue());
    }

    return dataSet;
}