LinkReferenceDefinitionParser { private boolean destination(Scanner scanner) { scanner.whitespace(); Position start = scanner.position(); if (!LinkScanner.scanLinkDestination(scanner)) { return false; } String rawDestination = scanner.textBetween(start, scanner.position()).toString(); destination = rawDestination.startsWith("<") ? rawDestination.substring(1, rawDestination.length() - 1) : rawDestination; int whitespace = scanner.whitespace(); if (!scanner.hasNext()) { referenceValid = true; paragraphLines.clear(); } else if (whitespace == 0) { return false; } state = State.START_TITLE; return true; }  void parse(CharSequence line); void addSourceSpan(SourceSpan sourceSpan);  }
@Test public void testDestination() { LinkReferenceDefinitionParser parser = new LinkReferenceDefinitionParser(); parser.parse("[foo]: /url"); assertEquals(State.START_TITLE, parser.getState()); assertParagraphLines("", parser); assertEquals(1, parser.getDefinitions().size()); assertDef(parser.getDefinitions().get(0), "foo", "/url", null); parser.parse("[bar]: </url2>"); assertDef(parser.getDefinitions().get(1), "bar", "/url2", null); }