private boolean pipeNeedsSpaceAfter(TableCell cell) { return cell.text.equals(" ") || !cell.text.startsWith(" "); }
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 void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { BasedSequence s = original.subSequence(startIndex, endIndex); if (s.startsWith("%")) { if (s.length() == 3) { // Already percent-encoded, preserve textMapper.addOriginalText(startIndex, endIndex); } else { // %25 is the percent-encoding for % textMapper.addReplacedText(startIndex, startIndex + 1, PrefixedSubSequence.of("%25", BasedSequence.NULL)); textMapper.addOriginalText(startIndex + 1, endIndex); } } else { byte[] bytes = s.toString().getBytes(Charset.forName("UTF-8")); StringBuilder sbItem = new StringBuilder(); for (byte b : bytes) { sbItem.append('%'); sbItem.append(HEX_DIGITS[(b >> 4) & 0xF]); sbItem.append(HEX_DIGITS[b & 0xF]); } textMapper.addReplacedText(startIndex, endIndex, PrefixedSubSequence.of(sbItem.toString(), BasedSequence.NULL)); } } };
@Override public BlockContinue tryContinue(ParserState state) { BasedSequence line = state.getLine(); if (line.startsWith(myOptions.exampleBreak)) { block.setClosingMarker(line.subSequence(0, myOptions.exampleBreak.length())); return BlockContinue.finished(); } return BlockContinue.atIndex(0); }
List<BasedSequence> segments = new ArrayList<BasedSequence>(); if (line.startsWith("|")) {
@Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { BasedSequence line = state.getLine(); if (state.getIndex() == 0) { int breakLength = myOptions.exampleBreak.length(); if (line.length() >= breakLength + 1 + EXAMPLE_KEYWORD.length() && line.startsWith(myOptions.exampleBreak) && line.matchChars(EXAMPLE_KEYWORD, breakLength + 1) && " \t\u00A0".contains(String.valueOf(line.charAt(breakLength)))) { SpecExampleBlockParser blockParser = new SpecExampleBlockParser(state.getProperties()); blockParser.block.setOpeningMarker(line.subSequence(0, breakLength)); //blockParser.addLine(state, state.getLineWithEOL()); return BlockStart.of(blockParser).atIndex(-1); } } return BlockStart.none(); } }
List<BasedSequence> segments = new ArrayList<BasedSequence>(); if (line.startsWith("|")) { if (wantPipes) segments.add(line.subSequence(0, 1)); line = line.subSequence(1, lineLength);
/** * 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; } }
private void render(HtmlInline node, NodeFormatterContext context, MarkdownWriter markdown) { switch (context.getRenderPurpose()) { case TRANSLATION_SPANS: case TRANSLATED_SPANS: String prefix = node.getChars().startsWith("</") ? "</" : "<"; markdown.appendNonTranslating(prefix, node.getChars(), ">"); break; case TRANSLATED: markdown.appendNonTranslating(node.getChars()); break; case FORMAT: default: markdown.append(node.getChars()); } }
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 pipeNeedsSpaceAfter(TableCell cell) { return cell.text.equals(" ") || !cell.text.startsWith(" "); }
addOpenCaptionSpace = cell.text.startsWith(" "); addCloseCaptionSpace = cell.text.endsWith(" "); break;
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; }
if (!myTable.isSeparator() && options.spaceAroundPipes && (!node.getText().startsWith(" ") || parserTrimCellWhiteSpace)) markdown.append(' ');
@Override public BlockContinue tryContinue(ParserState state) { BasedSequence line = state.getLine(); if (line.startsWith(myOptions.exampleBreak)) { block.setClosingMarker(line.subSequence(0, myOptions.exampleBreak.length())); return BlockContinue.finished(); } return BlockContinue.atIndex(0); }
spnl(); if ((dest = parseLinkDestination()) != null) { if (options.parseMultiLineImageUrls && opener.isImage() && !dest.startsWith("<") && dest.endsWith("?") && spnlUrl()) {