@Test public void headline1_new_line_headline2__headline1_has_pos_0_headline2_pos_12() throws Exception { String text = "= headline1\n= headline2"; List<AsciiDoctorHeadline> result = parserToTest.parse(text); assertHeadlines(result). hasHeadline("headline1"). withPosition(0). withEnd(10). and(). hasHeadline("headline2"). withPosition(12). withEnd(22); }
public List<AsciiDoctorHeadline> parse(String asciidoctorScript) { List<AsciiDoctorHeadline> list = new ArrayList<AsciiDoctorHeadline>(); if (asciidoctorScript == null) { 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; addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start =currentPos+1; continue; } if (current != null) { current.append(c); if (current.charAt(0) != '=') { current = null; } } } addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, currentPos); return list; }
SimpleHeadlineParser { public List<AsciiDoctorHeadline> parse(String asciidoctorScript) { List<AsciiDoctorHeadline> list = new ArrayList<AsciiDoctorHeadline>(); if (asciidoctorScript == null) { 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; addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start =currentPos+1; continue; } if (current != null) { current.append(c); if (current.charAt(0) != '=') { current = null; } } } addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, currentPos); return list; } }
SimpleHeadlineParser { public List<AsciiDoctorHeadline> parse(String asciidoctorScript) { List<AsciiDoctorHeadline> list = new ArrayList<AsciiDoctorHeadline>(); if (asciidoctorScript == null) { 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; addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start =currentPos+1; continue; } if (current != null) { current.append(c); if (current.charAt(0) != '=') { current = null; } } } addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, currentPos); return list; }  }
SimpleHeadlineParser { public List<AsciiDoctorHeadline> parse(String asciidoctorScript) { List<AsciiDoctorHeadline> list = new ArrayList<AsciiDoctorHeadline>(); if (asciidoctorScript == null) { 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; addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start =currentPos+1; continue; } if (current != null) { current.append(c); if (current.charAt(0) != '=') { current = null; } } } addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, currentPos); return list; }  List<AsciiDoctorHeadline> parse(String asciidoctorScript); }
SimpleHeadlineParser { public List<AsciiDoctorHeadline> parse(String asciidoctorScript) { List<AsciiDoctorHeadline> list = new ArrayList<AsciiDoctorHeadline>(); if (asciidoctorScript == null) { 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; addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, end); current = new StringBuilder(); start =currentPos+1; continue; } if (current != null) { current.append(c); if (current.charAt(0) != '=') { current = null; } } } addHeadlineWhenCurrentNotEmptyAndHasASpaceAfterLastEqual(asciidoctorScript, list, current, start, currentPos); return list; }  List<AsciiDoctorHeadline> parse(String asciidoctorScript);  }