Search in sources :

Example 1 with DelimitedBuilder

use of com.vladsch.flexmark.util.options.DelimitedBuilder in project flexmark-java by vsch.

the class TocUtils method getTocPrefix.

public static String getTocPrefix(TocOptions options, TocOptions defaultOptions) {
    DelimitedBuilder out = new DelimitedBuilder(" ");
    out.append("[TOC").mark();
    TocOptionsParser optionsParser = new TocOptionsParser();
    out.append(optionsParser.getOptionText(options, defaultOptions));
    out.unmark().append("]");
    out.append("\n").unmark();
    return out.toString();
}
Also used : DelimitedBuilder(com.vladsch.flexmark.util.options.DelimitedBuilder)

Example 2 with DelimitedBuilder

use of com.vladsch.flexmark.util.options.DelimitedBuilder in project flexmark-java by vsch.

the class TocUtils method getSimTocPrefix.

public static String getSimTocPrefix(TocOptions options, TocOptions defaultOptions) {
    DelimitedBuilder out = new DelimitedBuilder(" ");
    out.append("[TOC").mark();
    SimTocOptionsParser optionsParser = new SimTocOptionsParser();
    out.append(optionsParser.getOptionText(options, defaultOptions));
    out.unmark().append("]:").mark().append('#').mark();
    String optionTitleHeading = options.getTitleHeading();
    String optionTitle = options.title;
    if (defaultOptions == null || !optionTitleHeading.equals(defaultOptions.getTitleHeading())) {
        if (!optionTitle.isEmpty()) {
            out.append('"');
            if (defaultOptions == null || options.titleLevel != defaultOptions.titleLevel) {
                out.append(optionTitleHeading);
            } else {
                out.append(optionTitle);
            }
            out.append('"').mark();
        } else {
            out.append("\"\"").mark();
        }
    }
    out.unmark().append("\n").unmark();
    return out.toString();
}
Also used : DelimitedBuilder(com.vladsch.flexmark.util.options.DelimitedBuilder)

Example 3 with DelimitedBuilder

use of com.vladsch.flexmark.util.options.DelimitedBuilder in project flexmark-java by vsch.

the class SpecExampleNodeRenderer method render.

private void render(SpecExampleBlock node, NodeRendererContext context, HtmlWriter html) {
    // here we should probably prettify and display section, number and options
    switch(options.renderAs) {
        case DEFINITION_LIST:
            html.tagVoidLine("hr");
            html.tag("dl").indent();
            html.tag("dt").text(SpecReader.EXAMPLE_KEYWORD);
            if (node.getSection().isNotNull() || node.getNumberSeparator().isNotNull() || node.getNumber().isNotNull()) {
                html.text(" ").text(node.getSection().toString()).text(": ").text(node.getNumber().toString());
            }
            if (node.getOptionsKeyword().isNotNull() || node.getOptionsOpeningMarker().isNotNull() || node.getOptions().isNotNull() || node.getOptionsClosingMarker().isNotNull()) {
                String optionsText = "";
                BasedSequence trimmed = node.getOptions().trim(BasedSequence.WHITESPACE_NBSP_CHARS);
                if (!trimmed.isEmpty()) {
                    BasedSequence[] optionsList = trimmed.split(',', 0, BasedSequence.SPLIT_TRIM_SKIP_EMPTY);
                    DelimitedBuilder out = new DelimitedBuilder(", ");
                    optionsText = out.appendAll(optionsList).getAndClear();
                }
                html.text(" options(").text(optionsText).text(")");
            }
            html.tag("/dt").line();
            context.renderChildren(node);
            html.unIndent().tag("/dl").line();
            break;
        case SECTIONS:
            html.tagVoidLine("hr");
            if (node.getSection().isNotNull() || node.getNumberSeparator().isNotNull() || node.getNumber().isNotNull()) {
                html.tag("h5").text(node.getSection().toString()).text(": ").text(node.getNumber().toString()).tag("/h5").line();
            }
            context.renderChildren(node);
            break;
        case FENCED_CODE:
        default:
            render(node.getContentChars(), "text", context, html);
            break;
    }
}
Also used : BasedSequence(com.vladsch.flexmark.util.sequence.BasedSequence) DelimitedBuilder(com.vladsch.flexmark.util.options.DelimitedBuilder)

Aggregations

DelimitedBuilder (com.vladsch.flexmark.util.options.DelimitedBuilder)3 BasedSequence (com.vladsch.flexmark.util.sequence.BasedSequence)1