Refine search
protected boolean canClose(final DelimiterRun closer, final int minLength) { if (closer.canClose()) { BasedSequence closerChars = closer.getNode().getChars(); if (closer.getNext() != null && closerChars.isContinuationOf(closer.getNext().getNode().getChars()) || closerChars.getEndOffset() >= closerChars.getBaseSequence().length() || isAllowed(closerChars.getBaseSequence(), closerChars.getEndOffset() + minLength - 1)) { return true; } } return false; }
public void appendChild(Node child) { BasedSequence childChars = child.getChars(); assert nodeChars.containsAllOf(childChars) : "child " + child.toAstString(false) + " is not within parent sequence " + Node.toSegmentSpan(nodeChars, null); assert remainingChars.containsAllOf(childChars) : "child " + child.toAstString(false) + " is not within remaining sequence " + Node.toSegmentSpan(remainingChars, null); child.unlink(); if (!(child instanceof Text)) { if (remainingChars.getStartOffset() < childChars.getStartOffset()) { // add preceding chars as Text list.add(new Text(remainingChars.subSequence(0, childChars.getStartOffset() - remainingChars.getStartOffset()))); } // punch out remaining node chars remainingChars = remainingChars.subSequence(childChars.getEndOffset() - remainingChars.getStartOffset()); list.add(child); } }
private void visit(Text node) { if (!node.isOrDescendantOfType(DoNotDecorate.class)) { // do some processing BasedSequence original = node.getChars(); boolean wrapInTextBase = !(node.getParent() instanceof TextBase); TextBase textBase = null; while (wrapInTextBase) { if (wrapInTextBase) { wrapInTextBase = false; textBase = new TextBase(original); node.insertBefore(textBase); textBase.appendChild(node); } } } }
@Override public void getAstExtra(StringBuilder out) { astExtraChars(out); if (getChars() instanceof PrefixedSubSequence) { astChars(out, getChars(), "text"); } }
private void visit(Text node) { if (!node.isOrDescendantOfType(DoNotCollectText.class)) { out.append(node.getChars()); } }
if (node.getNext().getChars().isContinuationOf(combined)) { Node typoGraphic = node.getNext(); ArrayList<BasedSequence> combinedSequences = new ArrayList<>(); if (!typoGraphic.getChars().isContinuationOf(combined) || typoGraphic.getChars().startsWith(" ") || combined.endsWith(" ")) break; combined = typoGraphic.getChars(); combinedSequences.add(combined); BasedSequence literal = Escaping.unescape(original, textMapper); literal = Escaping.removeAll(literal, "\u001f", textMapper); BasedSequence escapedChars = original.subSequence(lastEscaped, startOffset); Node node1 = new Text(escapedChars); if (textBase != null) { textBase.appendChild(node1); final BasedSequence linkChars = linkText.baseSubSequence(linkText.getStartOffset(), linkText.getEndOffset()); Text contentNode = new Text(linkChars); LinkNode linkNode; if (lastEscaped < original.length()) { BasedSequence escapedChars = original.subSequence(lastEscaped, original.length()); Node node1 = new Text(escapedChars); if (textBase != null) { textBase.appendChild(node1);
while ((matched = match(myParsing.TICKS)) != null) { if (matched.equals(ticks)) { int ticksLength = ticks.length(); BasedSequence content = input.subSequence(afterOpenTicks - ticksLength, index - ticksLength); final BasedSequence codeText = input.subSequence(afterOpenTicks, index - ticksLength); Code node = new Code(input.subSequence(afterOpenTicks - ticksLength, afterOpenTicks), codeText, input.subSequence(index - ticksLength, index)); int lineBreak = pos; final Text textNode = new Text(codeText.subSequence(lastPos, pos)); node.appendChild(textNode); final Text textNode = new Text(codeText); node.appendChild(textNode);
if (lines.size() > 0) { BasedSequence info = lines.get(0); if (!info.isBlank()) { block.setInfo(info.trim()); BasedSequence spanningChars = chars.baseSubSequence(chars.getStartOffset(), lines.get(0).getEndOffset()); block.appendChild(codeBlock); } else { Text codeBlock = new Text(SegmentedSequence.of(segments)); block.appendChild(codeBlock);
boolean crLf = index > 0 && input.charAt(index - 1) == '\r'; int crLfDelta = crLf ? 1 : 0; if (lastChild instanceof Text && (lastChild.getChars().endsWith(" ") || crLf && lastChild.getChars().endsWith(" \r"))) { Text text = (Text) lastChild; BasedSequence literal = text.getChars(); Matcher matcher = myParsing.FINAL_SPACE.matcher(literal); int spaces = matcher.find() ? matcher.end() - matcher.start() - crLfDelta : 0; if (crLf && lastChild instanceof Text) { Text text = (Text) lastChild; BasedSequence literal = text.getChars(); if (literal.length() > 1) { lastChild.setChars(literal.subSequence(0, literal.length() - crLfDelta).trimEnd());
if (opener == null) { int savedIndex = index; while (nesting-- > 0) { index++; lastBracket.getNode().unlink(); removeLastBracket(); String normalizedLabel = Escaping.normalizeReferenceChars(ref, true); boolean containsLinks = containsLinkRefs(refIsBare ? ref : sequence, opener.getNode().getNext(), true); isLinkOrImage = !containsLinks; refIsDefined = true; boolean containsLinks = containsLinkRefs(ref, opener.getNode().getNext(), null); if (!containsLinks) { refIsBare = true; boolean containsLinks = containsLinkRefs(ref, opener.getNode().getNext(), null); if (!containsLinks) { isLinkOrImage = true; opener.getNode().setChars(opener.getNode().getChars().subSequence(1)); Node node = opener.getNode().getNext(); while (node != null) { Node next = node.getNext();
} else { opener.getNode().setChars(opener.getNode().getChars().subSequence(0, opener.getNumDelims())); } else { BasedSequence chars = closer.getNode().getChars(); int length = chars.length(); closer.getNode().setChars(chars.subSequence(length - closer.getNumDelims(), length)); closer.setIndex(closer.getIndex() + useDelims);
@SuppressWarnings("MethodMayBeStatic") void render(Text node, NodeRendererContext context, HtmlWriter html) { html.text(Escaping.normalizeEOL(node.getChars().unescape())); }
protected boolean canOpen(final DelimiterRun opener, final int minLength) { if (opener.canOpen()) { BasedSequence openerChars = opener.getNode().getChars(); if (opener.getPrevious() != null && opener.getPrevious().getNode().getChars().isContinuationOf(openerChars) || openerChars.getStartOffset() == 0 || isAllowed(openerChars.getBaseSequence(), openerChars.getStartOffset() - minLength)) { return true; } } return false; }
public void trimWhiteSpace() { Node firstChild = getFirstChild(); Node child = firstChild; while (child instanceof WhiteSpace) { Node next = child.getNext(); child.unlink(); child = next; } child = getLastChild(); while (child instanceof WhiteSpace) { Node next = child.getPrevious(); child.unlink(); child = next; } if (getFirstChild() == null && firstChild != null) { // we keep a single space from the child Node text = new Text(firstChild.getChars().subSequence(0, 1)); appendChild(text); } }
Node lastNode = node.getNext() instanceof WhiteSpace ? node.getNext() : node; Text text = new Text(node.getChars().baseSubSequence(firstNode.getStartOffset(), lastNode.getEndOffset())); node.insertBefore(text); node.unlink(); mergeTextParents.add(text.getParent());
@Override public Node unmatchedDelimiterNode(InlineParser inlineParser, final DelimiterRun delimiter) { if (myUnmatched != null && myOptions.typographicSmarts) { BasedSequence chars = delimiter.getNode().getChars(); if (chars.length() == 1) { return new TypographicSmarts(chars, myUnmatched); } } return null; }
private void render(final Text node, final DocxRendererContext docx) { docx.text(node.getChars().unescape()); /* // add text to last R R r = docx.getR(); final org.docx4j.wml.Text text = docx.addWrappedText(r); text.setValue(node.getChars().unescape()); text.setSpace(RunFormatProvider.SPACE_PRESERVE); */ }
@Override protected String toStringAttributes() { return "text=" + getChars(); } }
private void processText(NodeTracker state, Text node) { BasedSequence original = node.getChars(); boolean wrapInTextBase = !(node.getParent() instanceof TextBase); TextBase textBase = null; while (wrapInTextBase) { if (wrapInTextBase) { wrapInTextBase = false; textBase = new TextBase(original); node.insertBefore(textBase); textBase.appendChild(node); state.nodeAdded(textBase); } } }