@Test public void resolveTextFromStartToBracketsEnd_includeTexts_for_an_image_complete_resolved_0_0(){ String include ="something::very-special-and-useful[title=\"AsciiDoctor Editor Logo\" opts=\"inline\"]"; String line = include+"... something else"; assertEquals(include, resolveTextFromStartToBracketsEnd(line, 0, 0).text); }
public static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine) { LinkTextData data = new LinkTextData(); String lineLeftChars = line.substring(0, offsetInLine); String lineRightChars = line.substring(offsetInLine); StringBuilder sb = new StringBuilder(); int offsetLeft = offset; boolean foundEndingBracket = false; for (char c : lineRightChars.toCharArray()) { foundEndingBracket= (c==']'); sb.append(c); if (foundEndingBracket) { break; } } if (!foundEndingBracket){ return data; } char[] left = lineLeftChars.toCharArray(); for (int i = left.length - 1; i >= 0; i--) { char c = left[i]; if (Character.isWhitespace(c)) { break; } offsetLeft--; sb.insert(0, c); } data.text = sb.toString(); data.offsetLeft = offsetLeft; return data; }
AsciiDocStringUtils { public static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine) { LinkTextData data = new LinkTextData(); String lineLeftChars = line.substring(0, offsetInLine); String lineRightChars = line.substring(offsetInLine); StringBuilder sb = new StringBuilder(); int offsetLeft = offset; boolean foundEndingBracket = false; for (char c : lineRightChars.toCharArray()) { foundEndingBracket= (c==']'); sb.append(c); if (foundEndingBracket) { break; } } if (!foundEndingBracket){ return data; } char[] left = lineLeftChars.toCharArray(); for (int i = left.length - 1; i >= 0; i--) { char c = left[i]; if (Character.isWhitespace(c)) { break; } offsetLeft--; sb.insert(0, c); } data.text = sb.toString(); data.offsetLeft = offsetLeft; return data; } }
AsciiDocStringUtils { public static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine) { LinkTextData data = new LinkTextData(); String lineLeftChars = line.substring(0, offsetInLine); String lineRightChars = line.substring(offsetInLine); StringBuilder sb = new StringBuilder(); int offsetLeft = offset; boolean foundEndingBracket = false; for (char c : lineRightChars.toCharArray()) { foundEndingBracket= (c==']'); sb.append(c); if (foundEndingBracket) { break; } } if (!foundEndingBracket){ return data; } char[] left = lineLeftChars.toCharArray(); for (int i = left.length - 1; i >= 0; i--) { char c = left[i]; if (Character.isWhitespace(c)) { break; } offsetLeft--; sb.insert(0, c); } data.text = sb.toString(); data.offsetLeft = offsetLeft; return data; }  }
AsciiDocStringUtils { public static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine) { LinkTextData data = new LinkTextData(); String lineLeftChars = line.substring(0, offsetInLine); String lineRightChars = line.substring(offsetInLine); StringBuilder sb = new StringBuilder(); int offsetLeft = offset; boolean foundEndingBracket = false; for (char c : lineRightChars.toCharArray()) { foundEndingBracket= (c==']'); sb.append(c); if (foundEndingBracket) { break; } } if (!foundEndingBracket){ return data; } char[] left = lineLeftChars.toCharArray(); for (int i = left.length - 1; i >= 0; i--) { char c = left[i]; if (Character.isWhitespace(c)) { break; } offsetLeft--; sb.insert(0, c); } data.text = sb.toString(); data.offsetLeft = offsetLeft; return data; }  static String resolveFilenameOfDiagramMacroOrNull(String potentialInclude); static String resolveFilenameOfMacroOrNull(String potentialInclude, String macroName); static String resolveFilenameOfImageOrNull(String potentialImage); static String resolveFilenameOfIncludeOrNull(String potentialInclude); static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine); static String readUTF8FileToString(File fileToRead); static File writeTextToUTF8File(String transformed, File newTempFile); }
AsciiDocStringUtils { public static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine) { LinkTextData data = new LinkTextData(); String lineLeftChars = line.substring(0, offsetInLine); String lineRightChars = line.substring(offsetInLine); StringBuilder sb = new StringBuilder(); int offsetLeft = offset; boolean foundEndingBracket = false; for (char c : lineRightChars.toCharArray()) { foundEndingBracket= (c==']'); sb.append(c); if (foundEndingBracket) { break; } } if (!foundEndingBracket){ return data; } char[] left = lineLeftChars.toCharArray(); for (int i = left.length - 1; i >= 0; i--) { char c = left[i]; if (Character.isWhitespace(c)) { break; } offsetLeft--; sb.insert(0, c); } data.text = sb.toString(); data.offsetLeft = offsetLeft; return data; }  static String resolveFilenameOfDiagramMacroOrNull(String potentialInclude); static String resolveFilenameOfMacroOrNull(String potentialInclude, String macroName); static String resolveFilenameOfImageOrNull(String potentialImage); static String resolveFilenameOfIncludeOrNull(String potentialInclude); static LinkTextData resolveTextFromStartToBracketsEnd(String line, int offset, int offsetInLine); static String readUTF8FileToString(File fileToRead); static File writeTextToUTF8File(String transformed, File newTempFile);  }