Refine search
public void setTitleChars(BasedSequence titleChars) { if (titleChars != null && titleChars != BasedSequence.NULL) { int titleCharsLength = titleChars.length(); titleOpeningMarker = titleChars.subSequence(0, 1); title = titleChars.subSequence(1, titleCharsLength - 1); titleClosingMarker = titleChars.subSequence(titleCharsLength - 1, titleCharsLength); } else { titleOpeningMarker = BasedSequence.NULL; title = BasedSequence.NULL; titleClosingMarker = BasedSequence.NULL; } }
public void setTitleChars(BasedSequence titleChars) { if (titleChars != null && titleChars != BasedSequence.NULL) { int titleCharsLength = titleChars.length(); titleOpeningMarker = titleChars.subSequence(0, 1); title = titleChars.subSequence(1, titleCharsLength - 1); titleClosingMarker = titleChars.subSequence(titleCharsLength - 1, titleCharsLength); } else { titleOpeningMarker = BasedSequence.NULL; title = BasedSequence.NULL; titleClosingMarker = BasedSequence.NULL; } } }
public void setTextChars(BasedSequence textChars) { int textCharsLength = textChars.length(); this.textOpeningMarker = textChars.subSequence(0, 1); this.text = textChars.subSequence(1, textCharsLength - 1).trim(); this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength); }
@Override public void setTextChars(BasedSequence textChars) { int textCharsLength = textChars.length(); this.textOpeningMarker = textChars.subSequence(0, 1); this.text = textChars.subSequence(1, textCharsLength - 1).trim(); this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength); } }
@Override public void setTextChars(final BasedSequence textChars) { int textCharsLength = textChars.length(); this.textOpeningMarker = textChars.subSequence(0, 1); this.text = textChars.subSequence(1, textCharsLength - 1).trim(); this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength); } }
@Override public void setTextChars(BasedSequence textChars) { int textCharsLength = textChars.length(); this.textOpeningMarker = textChars.subSequence(0, 2); this.text = textChars.subSequence(2, textCharsLength - 1).trim(); this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength); } }
@Override public void setTextChars(BasedSequence textChars) { int textCharsLength = textChars.length(); this.textOpeningMarker = textChars.subSequence(0, 2); this.text = textChars.subSequence(2, textCharsLength - 1).trim(); this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength); }
public void setReferenceChars(BasedSequence referenceChars) { int referenceCharsLength = referenceChars.length(); int openingOffset = referenceChars.charAt(0) == '!' ? 2 : 1; this.referenceOpeningMarker = referenceChars.subSequence(0, openingOffset); this.reference = referenceChars.subSequence(openingOffset, referenceCharsLength - 1).trim(); this.referenceClosingMarker = referenceChars.subSequence(referenceCharsLength - 1, referenceCharsLength); }
public Reference(BasedSequence label, BasedSequence url, BasedSequence title) { super(BasedSequence.NULL); this.openingMarker = label.subSequence(0, 1); this.reference = label.subSequence(1, label.length() - 2).trim(); this.closingMarker = label.subSequence(label.length() - 2, label.length()); setUrlChars(url); if (title != null) { this.titleOpeningMarker = title.subSequence(0, 1); this.title = title.subSequence(1, title.length() - 1); this.titleClosingMarker = title.subSequence(title.length() - 1, title.length()); } setCharsFromContent(); }
@Override public void setTextChars(final BasedSequence textChars) { verifyBasedSequence(textChars, 0); int textCharsLength = textChars.length(); textOpeningMarker = textChars.subSequence(0, PREFIX.length() + 1); // grab n characters, n - 1 for the PREFIX and 1 for the opener text = textChars.subSequence(PREFIX.length() + 2, textCharsLength - 1).trim(); textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength); }
public TocBlockBase(BasedSequence chars, BasedSequence styleChars, boolean closingSimToc) { super(chars); openingMarker = chars.subSequence(0, 1); tocKeyword = chars.subSequence(1, 4); if (styleChars != null) { style = styleChars; } int closingPos = chars.indexOf(']', 4); if (closingSimToc && !(closingPos != -1 && closingPos + 1 < chars.length() && chars.charAt(closingPos + 1) == ':')) { throw new IllegalStateException("Invalid TOC block sequence"); } closingMarker = chars.subSequence(closingPos, closingPos + (closingSimToc ? 2 : 1)); }
public TocBlock(BasedSequence chars, BasedSequence styleChars, boolean closingSimToc) { super(chars); openingMarker = chars.subSequence(0, 1); tocKeyword = chars.subSequence(1, 4); if (styleChars != null) { style = styleChars; } int closingPos = chars.indexOf(']', 4); if (closingSimToc && !(closingPos != -1 && closingPos + 1 < chars.length() && chars.charAt(closingPos + 1) == ':')) { throw new IllegalStateException("Invalid TOC block sequence"); } closingMarker = chars.subSequence(closingPos, closingPos + (closingSimToc ? 2 : 1)); }
public SegmentedSequenceBuilder append(String str) { BasedSequence useBase; if (segments.isEmpty()) { useBase = base.subSequence(0, 0); } else { useBase = segments.get(segments.size() - 1); useBase = useBase.subSequence(useBase.length(), useBase.length()); } return append(PrefixedSubSequence.of(str, useBase)); }
private boolean isEscaped(final BasedSequence chars, String prefix) { int backslashCount = chars.subSequence(0, chars.length() - prefix.length()).countTrailing('\\'); return (backslashCount & 1) != 0; }
@Override public BasedSequence ifNullEmptyAfter(BasedSequence other) { return isNull() ? other.subSequence(other.length(), other.length()) : this; }
@Override public BasedSequence[] getSegmentsForChars() { return new BasedSequence[] { openingMarker, reference, closingMarker, PrefixedSubSequence.of(" ", closingMarker.subSequence(closingMarker.length())), urlOpeningMarker, pageRef, anchorMarker, anchorRef, urlClosingMarker, titleOpeningMarker, title, titleClosingMarker }; }
/** * Attempt to parse an autolink (URL or email in pointy brackets). * * @return true if processed characters false otherwise */ @Override public boolean parseAutolink() { BasedSequence m; if ((m = match(myParsing.EMAIL_AUTOLINK)) != null) { MailLink node = new MailLink(m.subSequence(0, 1), m.subSequence(1, m.length() - 1), m.subSequence(m.length() - 1, m.length())); appendNode(node); return true; } else if ((m = match(myParsing.AUTOLINK)) != null) { AutoLink node = new AutoLink(m.subSequence(0, 1), m.subSequence(1, m.length() - 1), m.subSequence(m.length() - 1, m.length())); appendNode(node); return true; } else { return false; } }
private void visit(HardLineBreak node) { final BasedSequence chars = node.getChars(); out.append(chars.subSequence(chars.length() - 1, chars.length())); }
private void visit(HardLineBreak node) { final BasedSequence chars = node.getChars(); out.append(chars.subSequence(chars.length()-1, chars.length())); }
public static BasedSequence stripIndent(BasedSequence input, CharSequence sourceIndent) { BasedSequence result = input; if (sourceIndent.length() != 0) { // strip out indent to test how segmented input parses ArrayList<BasedSequence> segments = new ArrayList<>(); int lastPos = 0; int length = input.length(); while (lastPos < length) { int pos = input.indexOf(sourceIndent, lastPos); int end = pos == -1 ? length : pos; if (lastPos < end && (pos <= 0 || input.charAt(pos - 1) == '\n')) { segments.add(input.subSequence(lastPos, end)); } lastPos = end + sourceIndent.length(); } result = SegmentedSequence.of(segments); } return result; }