use of com.vladsch.flexmark.util.sequence.BasedSequence in project flexmark-java by vsch.
the class SpecExampleNodeRenderer method render.
private void render(SpecExampleHtml node, NodeRendererContext context, HtmlWriter html) {
BasedSequence text = node.getChars();
switch(options.renderAs) {
case DEFINITION_LIST:
html.tag("dt").text("Html").tag("/dt").line();
html.tag("dd");
render(text, "html", context, html);
html.tag("/dd").line();
if (options.renderHtml) {
html.tag("dt").text("Rendered Html").tag("/dt").line();
html.tag("dd");
html.raw(options.renderedHtmlPrefix).rawIndentedPre(text.normalizeEOL()).raw(options.renderedHtmlSuffix).line();
html.tag("/dd").line();
}
break;
case SECTIONS:
if (!text.isEmpty()) {
html.tagVoidLine("hr");
render(text, "html", context, html);
if (options.renderHtml) {
html.tagVoidLine("hr");
html.raw(options.renderedHtmlPrefix).rawIndentedPre(text.normalizeEOL()).raw(options.renderedHtmlSuffix).line();
}
}
break;
case FENCED_CODE:
default:
break;
}
}
use of com.vladsch.flexmark.util.sequence.BasedSequence in project flexmark-java by vsch.
the class WikiNode method setLinkChars.
public void setLinkChars(BasedSequence linkChars, boolean allowAnchors, boolean canEscapePipe, boolean canEscapeAnchor) {
int length = linkChars.length();
final int start = this instanceof WikiImage ? 3 : 2;
openingMarker = linkChars.subSequence(0, start);
closingMarker = linkChars.subSequence(length - 2, length);
int pos;
if (linkIsFirst) {
pos = linkChars.length() - 2;
do {
pos = linkChars.lastIndexOf('|', pos - 1);
} while (pos != -1 && canEscapePipe && (pos > 0 && linkChars.charAt(pos - 1) == '\\' && (linkChars.subSequence(0, pos).countTrailing('\\') & 1) == 1));
} else {
pos = -1;
do {
pos = linkChars.indexOf('|', pos + 1);
} while (pos != -1 && canEscapePipe && (pos > 0 && linkChars.charAt(pos - 1) == '\\' && (linkChars.subSequence(0, pos).countTrailing('\\') & 1) == 1));
}
BasedSequence link;
if (pos < 0) {
link = linkChars.subSequence(start, length - 2);
} else {
textSeparatorMarker = linkChars.subSequence(pos, pos + 1);
if (linkIsFirst) {
link = linkChars.subSequence(start, pos);
text = linkChars.subSequence(pos + 1, length - 2);
} else {
text = linkChars.subSequence(start, pos);
link = linkChars.subSequence(pos + 1, length - 2);
}
}
setLink(link, allowAnchors, canEscapeAnchor);
if (text.isNull() && allowAnchors && !anchorMarker.isNull()) {
// have anchor ref, remove it from text
text = pageRef;
}
}
use of com.vladsch.flexmark.util.sequence.BasedSequence in project flexmark-java by vsch.
the class WikiLinkLinkRefProcessor method updateNodeElements.
@Override
public void updateNodeElements(final Document document, final Node node) {
assert (node instanceof WikiNode);
final WikiNode wikiNode = (WikiNode) node;
if (node instanceof WikiLink && WikiLinkExtension.ALLOW_INLINES.getFrom(document)) {
// need to update link and pageRef with plain text versions
if (wikiNode.getText().isNull()) {
BasedSequence link = new TextCollectingVisitor().collectAndGetSequence(node);
wikiNode.setLink(link, WikiLinkExtension.ALLOW_ANCHORS.getFrom(document), WikiLinkExtension.ALLOW_ANCHOR_ESCAPE.getFrom(document));
}
}
}
use of com.vladsch.flexmark.util.sequence.BasedSequence in project flexmark-java by vsch.
the class SmartsInlineParser method parse.
@Override
public boolean parse(final InlineParser inlineParser) {
BasedSequence match = inlineParser.match(parsing.SMARTS);
if (match != null) {
BasedSequence input = inlineParser.getInput();
inlineParser.flushTextNode();
String typographicSmarts;
if (match.matches(parsing.ELIPSIS))
typographicSmarts = "…";
else if (match.matches(parsing.ELIPSIS_SPACED))
typographicSmarts = "…";
else if (match.matches(parsing.EN_DASH))
typographicSmarts = "–";
else if (match.matches(parsing.EM_DASH))
typographicSmarts = "—";
else
return false;
TypographicSmarts smarts = new TypographicSmarts(match, typographicSmarts);
inlineParser.getBlock().appendChild(smarts);
return true;
}
return false;
}
use of com.vladsch.flexmark.util.sequence.BasedSequence in project flexmark-java by vsch.
the class TableBlockParser method parseAlignment.
private static List<TableCell.Alignment> parseAlignment(BasedSequence separatorLine) {
List<BasedSequence> parts = split(separatorLine);
List<TableCell.Alignment> alignments = new ArrayList<TableCell.Alignment>();
for (BasedSequence part : parts) {
BasedSequence trimmed = part.trim();
boolean left = trimmed.startsWith(":");
boolean right = trimmed.endsWith(":");
TableCell.Alignment alignment = getAlignment(left, right);
alignments.add(alignment);
}
return alignments;
}
Aggregations