@Test public void inline_anchor_section_13() throws Exception { String text = "[[section-13]]"; List<AsciiDoctorInlineAnchor> result = parserToTest.parse(text); assertInlineAnchors(result). hasInlineAnchors(1). hasInlineAnchor("[[section-13]]"). withId("section-13"). withPosition(0). withEnd(13); }
public List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript) { List<AsciiDoctorInlineAnchor> list = new ArrayList<AsciiDoctorInlineAnchor>(); if (asciidoctorScript == null || asciidoctorScript .length() < 5) { return list; } StringBuilder current = new StringBuilder(); int start = 0; int currentPos = -1; for (char c : asciidoctorScript.toCharArray()) { currentPos++; if (c == '\n') { int end = currentPos - 1; addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start = currentPos + 1; continue; } if (current != null) { current.append(c); if (current.length() == 1 && current.charAt(0) != '[') { current = null; } else if (current.length() == 2 && (current.charAt(1) != '[' && current.charAt(1) != '#')) { current = null; } } } addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, currentPos); return list; }
SimpleInlineAnchorParser { public List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript) { List<AsciiDoctorInlineAnchor> list = new ArrayList<AsciiDoctorInlineAnchor>(); if (asciidoctorScript == null || asciidoctorScript .length() < 5) { return list; } StringBuilder current = new StringBuilder(); int start = 0; int currentPos = -1; for (char c : asciidoctorScript.toCharArray()) { currentPos++; if (c == '\n') { int end = currentPos - 1; addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start = currentPos + 1; continue; } if (current != null) { current.append(c); if (current.length() == 1 && current.charAt(0) != '[') { current = null; } else if (current.length() == 2 && (current.charAt(1) != '[' && current.charAt(1) != '#')) { current = null; } } } addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, currentPos); return list; } }
SimpleInlineAnchorParser { public List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript) { List<AsciiDoctorInlineAnchor> list = new ArrayList<AsciiDoctorInlineAnchor>(); if (asciidoctorScript == null || asciidoctorScript .length() < 5) { return list; } StringBuilder current = new StringBuilder(); int start = 0; int currentPos = -1; for (char c : asciidoctorScript.toCharArray()) { currentPos++; if (c == '\n') { int end = currentPos - 1; addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start = currentPos + 1; continue; } if (current != null) { current.append(c); if (current.length() == 1 && current.charAt(0) != '[') { current = null; } else if (current.length() == 2 && (current.charAt(1) != '[' && current.charAt(1) != '#')) { current = null; } } } addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, currentPos); return list; }  }
SimpleInlineAnchorParser { public List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript) { List<AsciiDoctorInlineAnchor> list = new ArrayList<AsciiDoctorInlineAnchor>(); if (asciidoctorScript == null || asciidoctorScript .length() < 5) { return list; } StringBuilder current = new StringBuilder(); int start = 0; int currentPos = -1; for (char c : asciidoctorScript.toCharArray()) { currentPos++; if (c == '\n') { int end = currentPos - 1; addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start = currentPos + 1; continue; } if (current != null) { current.append(c); if (current.length() == 1 && current.charAt(0) != '[') { current = null; } else if (current.length() == 2 && (current.charAt(1) != '[' && current.charAt(1) != '#')) { current = null; } } } addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, currentPos); return list; }  List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript); }
SimpleInlineAnchorParser { public List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript) { List<AsciiDoctorInlineAnchor> list = new ArrayList<AsciiDoctorInlineAnchor>(); if (asciidoctorScript == null || asciidoctorScript .length() < 5) { return list; } StringBuilder current = new StringBuilder(); int start = 0; int currentPos = -1; for (char c : asciidoctorScript.toCharArray()) { currentPos++; if (c == '\n') { int end = currentPos - 1; addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start = currentPos + 1; continue; } if (current != null) { current.append(c); if (current.length() == 1 && current.charAt(0) != '[') { current = null; } else if (current.length() == 2 && (current.charAt(1) != '[' && current.charAt(1) != '#')) { current = null; } } } addWhenCurrentWhenValidAnchorText(asciidoctorScript, list, current, start, currentPos); return list; }  List<AsciiDoctorInlineAnchor> parse(String asciidoctorScript);  }