public enum ListType { HIERARCHY, FLAT, FLAT_REVERSED, SORTED, SORTED_REVERSED }
public static BasedSequence of(CharSequence charSequence) { if (charSequence instanceof BasedSequence) return ((BasedSequence) charSequence); else if (charSequence instanceof String) return CharSubSequence.of(charSequence); else if (charSequence != null) return SubSequence.of(charSequence); return BasedSequence.NULL; }
@SuppressWarnings("WeakerAccess") public static int indexOfValue(final CharSequence value, final CharSequence valueName, final char valueListDelimiter, final char valueNameDelimiter) { if (valueName.length() == 0 || value.length() == 0) return -1; if (valueListDelimiter == NUL) { return value.equals(valueName) ? 0 : -1; } else { int lastPos = 0; final BasedSequence subSeq = SubSequence.of(value); while (lastPos < value.length()) { int pos = subSeq.indexOf(valueName, lastPos); if (pos == -1) break; // see if it is 0 or preceded by a space, or at the end or followed by a space int endPos = pos + valueName.length(); if (pos == 0 || value.charAt(pos - 1) == valueListDelimiter || valueNameDelimiter != NUL && value.charAt(pos - 1) == valueNameDelimiter) { if (endPos >= value.length() || value.charAt(endPos) == valueListDelimiter || valueNameDelimiter != NUL && value.charAt(endPos) == valueNameDelimiter) { return pos; } } lastPos = endPos + 1; } } return -1; }
public static BasedSequence of(CharSequence charSequence, int start) { if (charSequence instanceof BasedSequence) return ((BasedSequence) charSequence).subSequence(start); else if (charSequence instanceof String) return CharSubSequence.of(charSequence, start); else return SubSequence.of(charSequence, start); }
public static BasedSequence of(CharSequence charSequence, int start, int end) { if (charSequence instanceof BasedSequence) return ((BasedSequence) charSequence).subSequence(start, end); else if (charSequence instanceof String) return CharSubSequence.of(charSequence, start, end); else return SubSequence.of(charSequence, start, end); } }
@Override public BasedSequence replace(final CharSequence find, final CharSequence replace) { int[] indices = indexOfAll(find); if (indices.length == 0) return this; final int iMax = indices.length; StringBuilder sb = new StringBuilder(length() + (replace.length() - find.length()) * iMax); final BasedSequence basedReplace = SubSequence.of(replace); int i = 0; int lastPos = 0; while (i < iMax) { int pos = indices[i++]; if (lastPos < pos) appendTo(sb, lastPos, pos); lastPos = pos + find.length(); basedReplace.appendTo(sb); } if (lastPos < length()) { appendTo(sb, lastPos, length()); } return CharSubSequence.of(sb); }
private boolean processCode(FormattingAppendable out, Element element) { skip(); BasedSequence text = SubSequence.of(element.ownText()); int backTickCount = getMaxRepeatedChars(text, '`', 1); CharSequence backTicks = RepeatedCharSequence.of("`", backTickCount); boolean oldInlineCode = myInlineCode; myInlineCode = true; processTextNodes(out, element, false, myOptions.skipInlineCode || myOptions.extInlineCode.isTextOnly ? "" : backTicks); myInlineCode = oldInlineCode; return true; }
private void render(final DefinitionItem node, final NodeFormatterContext context, final MarkdownWriter markdown) { BasedSequence openMarkerChars = node.getChars().prefixOf(node.getFirstChild().getChars()); BasedSequence openMarker = openMarkerChars.subSequence(0,1); BasedSequence openMarkerSpaces = openMarkerChars.subSequence(1); if (options.markerSpaces >= 1 && openMarkerSpaces.length() != options.markerSpaces) { openMarkerSpaces = SubSequence.of(RepeatedCharSequence.of(' ', options.markerSpaces)); } switch (options.markerType) { case ANY: break; case COLON: openMarker = SubSequence.of(":"); break; case TILDE: openMarker = SubSequence.of("~"); break; } markdown.line().append(openMarker).append(openMarkerSpaces); markdown.pushPrefix().addPrefix(RepeatedCharSequence.of(' ', context.getFormatterOptions().itemContentIndent ? openMarker.length() + openMarkerSpaces.length() : listOptions.getItemIndent())); context.renderChildren(node); markdown.popPrefix(); if (!context.getOptions().get(BLANK_LINES_IN_AST)) { // add blank lines after last paragraph item Node child = node.getLastChild(); if (child instanceof Paragraph && ((Paragraph) child).isTrailingBlankLine()) { markdown.blankLine(); } } }
public static BasedSequence of(CharSequence charSequence) { if (charSequence instanceof BasedSequence) return ((BasedSequence) charSequence); else if (charSequence instanceof String) return CharSubSequence.of(charSequence); else if (charSequence != null) return SubSequence.of(charSequence); return BasedSequence.NULL; }
public enum ListType { HIERARCHY, FLAT, FLAT_REVERSED, SORTED, SORTED_REVERSED }
BasedSequence input = SubSequence.of(source); int lineStart = 0; int lineBreak;
@SuppressWarnings("WeakerAccess") public static int indexOfValue(final CharSequence value, final CharSequence valueName, final char valueListDelimiter, final char valueNameDelimiter) { if (valueName.length() == 0 || value.length() == 0) return -1; if (valueListDelimiter == NUL) { return value.equals(valueName) ? 0 : -1; } else { int lastPos = 0; final BasedSequence subSeq = SubSequence.of(value); while (lastPos < value.length()) { int pos = subSeq.indexOf(valueName, lastPos); if (pos == -1) break; // see if it is 0 or preceded by a space, or at the end or followed by a space int endPos = pos + valueName.length(); if (pos == 0 || value.charAt(pos - 1) == valueListDelimiter || valueNameDelimiter != NUL && value.charAt(pos - 1) == valueNameDelimiter) { if (endPos >= value.length() || value.charAt(endPos) == valueListDelimiter || valueNameDelimiter != NUL && value.charAt(endPos) == valueNameDelimiter) { return pos; } } lastPos = endPos + 1; } } return -1; }
public static BasedSequence of(CharSequence charSequence, int start) { if (charSequence instanceof BasedSequence) return ((BasedSequence) charSequence).subSequence(start); else if (charSequence instanceof String) return CharSubSequence.of(charSequence, start); else return SubSequence.of(charSequence, start); }
public static BasedSequence of(CharSequence charSequence, int start, int end) { if (charSequence instanceof BasedSequence) return ((BasedSequence) charSequence).subSequence(start, end); else if (charSequence instanceof String) return CharSubSequence.of(charSequence, start, end); else return SubSequence.of(charSequence, start, end); } }
@Override public BasedSequence replace(final CharSequence find, final CharSequence replace) { int[] indices = indexOfAll(find); if (indices.length == 0) return this; final int iMax = indices.length; StringBuilder sb = new StringBuilder(length() + (replace.length() - find.length()) * iMax); final BasedSequence basedReplace = SubSequence.of(replace); int i = 0; int lastPos = 0; while (i < iMax) { int pos = indices[i++]; if (lastPos < pos) appendTo(sb, lastPos, pos); lastPos = pos + find.length(); basedReplace.appendTo(sb); } if (lastPos < length()) { appendTo(sb, lastPos, length()); } return CharSubSequence.of(sb); }
private void render(final DefinitionItem node, final NodeFormatterContext context, final MarkdownWriter markdown) { BasedSequence openMarkerChars = node.getChars().prefixOf(node.getFirstChild().getChars()); BasedSequence openMarker = openMarkerChars.subSequence(0,1); BasedSequence openMarkerSpaces = openMarkerChars.subSequence(1); if (options.markerSpaces >= 1 && openMarkerSpaces.length() != options.markerSpaces) { openMarkerSpaces = SubSequence.of(RepeatedCharSequence.of(' ', options.markerSpaces)); } switch (options.markerType) { case ANY: break; case COLON: openMarker = SubSequence.of(":"); break; case TILDE: openMarker = SubSequence.of("~"); break; } markdown.line().append(openMarker).append(openMarkerSpaces); markdown.pushPrefix().addPrefix(RepeatedCharSequence.of(' ', context.getFormatterOptions().itemContentIndent ? openMarker.length() + openMarkerSpaces.length() : listOptions.getItemIndent())); context.renderChildren(node); markdown.popPrefix(); if (!context.getOptions().get(BLANK_LINES_IN_AST)) { // add blank lines after last paragraph item Node child = node.getLastChild(); if (child instanceof Paragraph && ((Paragraph) child).isTrailingBlankLine()) { markdown.blankLine(); } } }
BasedSequence input = SubSequence.of(source); int lineStart = 0; int lineBreak;