private boolean pipeNeedsSpaceBefore(TableCell cell) { //if (cell.trackedTextOffset != NO_TRACKED_OFFSET) { // return cell.text.equals(" ") || cell.trackedTextOffset > cell.text.length() || !cell.text.subSequence(cell.trackedTextOffset).endsWith(" "); //} return cell.text.equals(" ") || !cell.text.endsWith(" "); }
private List<TableCell.Alignment> parseAlignment(BasedSequence separatorLine) { List<BasedSequence> parts = split(separatorLine, false, false); 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; }
private static List<Alignment> parseAlignment(BasedSequence separatorLine) { List<BasedSequence> parts = split(separatorLine); List<Alignment> alignments = new ArrayList<Alignment>(); for (BasedSequence part : parts) { BasedSequence trimmed = part.trim(); boolean left = trimmed.startsWith(":"); boolean right = trimmed.endsWith(":"); Alignment alignment = getAlignment(left, right); alignments.add(alignment); } return alignments; }
@Override public String toString() { int total = 0; StringBuilder sb = new StringBuilder(); BasedSequence last = null; for (BasedSequence s : segments) { if (s.isEmpty()) continue; if (last != null && last.getEndOffset() < s.getStartOffset() && (BasedSequence.WHITESPACE_CHARS.indexOf(last.charAt(last.length() - 1)) == -1) && BasedSequence.WHITESPACE_CHARS.indexOf(s.charAt(0)) == -1 && s.baseSubSequence(last.getEndOffset(), s.getStartOffset()).endsWith(" ") ) { sb.append(' '); } s.appendTo(sb); last = s; } return sb.toString(); } }
/** * Attempt to parse inline HTML. * * @return true if processed characters false otherwise */ @Override public boolean parseHtmlInline() { BasedSequence m = match(myParsing.HTML_TAG); if (m != null) { // separate HTML comment from herd HtmlInlineBase node; if (m.startsWith("<!--") && m.endsWith("-->")) { node = new HtmlInlineComment(m); } else { node = new HtmlInline(m); } appendNode(node); return true; } else { return false; } }
MacroClose macroClose = null; if (macroOpen.endsWith("/}}")) {
if (chars.isContinuedBy(node.getChars())) { AbstractMediaLink mediaLink; if (chars.endsWith(AudioLink.PREFIX) && !isEscaped(chars, AudioLink.PREFIX)) { // AudioLink mediaLink = new AudioLink((Link) node); } else if (chars.endsWith(EmbedLink.PREFIX) && !isEscaped(chars, EmbedLink.PREFIX)) { // EmbedLink mediaLink = new EmbedLink((Link) node); } else if (chars.endsWith(PictureLink.PREFIX) && !isEscaped(chars, PictureLink.PREFIX)) { // PictureLink mediaLink = new PictureLink((Link) node); } else if (chars.endsWith(VideoLink.PREFIX) && !isEscaped(chars, VideoLink.PREFIX)) { // VideoLink mediaLink = new VideoLink((Link) node); } else { // None of the Above, abort postprocess
public void setUrlChars(BasedSequence url) { if (url != null && url != BasedSequence.NULL) { // strip off <> wrapping if (url.startsWith("<") && url.endsWith(">")) { urlOpeningMarker = url.subSequence(0, 1); this.url = url.subSequence(1, url.length() - 1); urlClosingMarker = url.subSequence(url.length() - 1); } else { this.url = url; } // parse out the anchor marker and ref int pos = this.url.indexOf('#'); if (pos < 0) { this.pageRef = this.url; } else { this.pageRef = this.url.subSequence(0, pos); this.anchorMarker = this.url.subSequence(pos, pos + 1); this.anchorRef = this.url.subSequence(pos + 1); } } else { this.urlOpeningMarker = BasedSequence.NULL; this.url = BasedSequence.NULL; this.urlClosingMarker = BasedSequence.NULL; } }
private boolean pipeNeedsSpaceBefore(TableCell cell) { //if (cell.trackedTextOffset != NO_TRACKED_OFFSET) { // return cell.text.equals(" ") || cell.trackedTextOffset > cell.text.length() || !cell.text.subSequence(cell.trackedTextOffset).endsWith(" "); //} return cell.text.equals(" ") || !cell.text.endsWith(" "); }
case AS_IS: addOpenCaptionSpace = cell.text.startsWith(" "); addCloseCaptionSpace = cell.text.endsWith(" "); break;
@Override public void process(NodeTracker state, Node node) { if (node instanceof Link) { Node previous = node.getPrevious(); if (previous instanceof Text) { final BasedSequence chars = previous.getChars(); if (chars.endsWith("@") && chars.isContinuedBy(node.getChars())) { int prevBackslash = chars.subSequence(0, chars.length() - 1).countTrailing('\\'); if ((prevBackslash & 1) == 0) { // trim previous chars to remove '@' previous.setChars(chars.subSequence(0, chars.length() - 1)); YouTubeLink youTubeLink = new YouTubeLink((Link) node); youTubeLink.takeChildren(node); node.unlink(); previous.insertAfter(youTubeLink); state.nodeRemoved(node); state.nodeAddedWithChildren(youTubeLink); } } } } }
if (!typoGraphic.getChars().isContinuationOf(combined) || typoGraphic.getChars().startsWith(" ") || combined.endsWith(" ")) break; combined = typoGraphic.getChars(); combinedSequences.add(combined);
if (trimmed.startsWith("[") && trimmed.endsWith("]")) { captionLine = trimmed;
private List<TableCell.Alignment> parseAlignment(BasedSequence separatorLine) { List<BasedSequence> parts = split(separatorLine, false, false); 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; }
private static List<Alignment> parseAlignment(BasedSequence separatorLine) { List<BasedSequence> parts = split(separatorLine); List<Alignment> alignments = new ArrayList<Alignment>(); for (BasedSequence part : parts) { BasedSequence trimmed = part.trim(); boolean left = trimmed.startsWith(":"); boolean right = trimmed.endsWith(":"); Alignment alignment = getAlignment(left, right); alignments.add(alignment); } return alignments; }
@Override public String toString() { int total = 0; StringBuilder sb = new StringBuilder(); BasedSequence last = null; for (BasedSequence s : segments) { if (s.isEmpty()) continue; if (last != null && last.getEndOffset() < s.getStartOffset() && (BasedSequence.WHITESPACE_CHARS.indexOf(last.charAt(last.length() - 1)) == -1) && BasedSequence.WHITESPACE_CHARS.indexOf(s.charAt(0)) == -1 && s.baseSubSequence(last.getEndOffset(), s.getStartOffset()).endsWith(" ") ) { sb.append(' '); } s.appendTo(sb); last = s; } return sb.toString(); } }
/** * Attempt to parse inline HTML. * * @return true if processed characters false otherwise */ @Override public boolean parseHtmlInline() { BasedSequence m = match(myParsing.HTML_TAG); if (m != null) { // separate HTML comment from herd HtmlInlineBase node; if (m.startsWith("<!--") && m.endsWith("-->")) { node = new HtmlInlineComment(m); } else { node = new HtmlInline(m); } appendNode(node); return true; } else { return false; } }
spnl(); if ((dest = parseLinkDestination()) != null) { if (options.parseMultiLineImageUrls && opener.isImage() && !dest.startsWith("<") && dest.endsWith("?") && spnlUrl()) {
@Override public void process(NodeTracker state, Node node) { if (node instanceof Link) { Node previous = node.getPrevious(); if (previous instanceof Text) { final BasedSequence chars = previous.getChars(); if (chars.endsWith("@") && chars.isContinuedBy(node.getChars())) { int prevBackslash = chars.subSequence(0, chars.length() - 1).countTrailing('\\'); if ((prevBackslash & 1) == 0) { // trim previous chars to remove '@' previous.setChars(chars.subSequence(0, chars.length() - 1)); YouTubeLink youTubeLink = new YouTubeLink((Link) node); youTubeLink.takeChildren(node); node.unlink(); previous.insertAfter(youTubeLink); state.nodeRemoved(node); state.nodeAddedWithChildren(youTubeLink); } } } } }