@Test public void testAttributeValue() { assertEquals("abc", target.attributeValue("<A href='abc'>t</a>").e3); assertEquals("abc", target.attributeValue("<A href=\"abc\">t</a>").e3); assertEquals("abc", target.attributeValue("<A href= 'abc' >t</a>").e3); assertEquals("abc", target.attributeValue("<a href=abc>t</a>").e3); assertEquals("abc", target.attributeValue("<a href=abc>t</a>").e3); assertEquals("abc", target.attributeValue("<a href=abc >t</a>").e3); assertEquals("abc", target.attributeValue("<a href='abc>t</a>").e3); }
@VisibleForTesting Tuple3<Integer, Integer, String> attributeValue(String tag) { String normalized= TextTools.removeControlChars(tag); List<Tuple3<Integer, Integer, String>> matches = RegexTools.findAll(attributePattern, normalized, true); if (matches.isEmpty()) return Tuple3.nil(); Tuple3<Integer, Integer, String> match = matches.get(0); String value = match.e3; char quote= value.charAt(0); if (isQuote(quote)) { value= extractBetweenQuotes(value, quote); } return Tuple3.tuple3(match.e1, match.e2, value); }
TagTranslator { @VisibleForTesting Tuple3<Integer, Integer, String> attributeValue(String tag) { String normalized= TextTools.removeControlChars(tag); List<Tuple3<Integer, Integer, String>> matches = RegexTools.findAll(attributePattern, normalized, true); if (matches.isEmpty()) return Tuple3.nil(); Tuple3<Integer, Integer, String> match = matches.get(0); String value = match.e3; char quote= value.charAt(0); if (isQuote(quote)) { value= extractBetweenQuotes(value, quote); } return Tuple3.tuple3(match.e1, match.e2, value); } }
TagTranslator { @VisibleForTesting Tuple3<Integer, Integer, String> attributeValue(String tag) { String normalized= TextTools.removeControlChars(tag); List<Tuple3<Integer, Integer, String>> matches = RegexTools.findAll(attributePattern, normalized, true); if (matches.isEmpty()) return Tuple3.nil(); Tuple3<Integer, Integer, String> match = matches.get(0); String value = match.e3; char quote= value.charAt(0); if (isQuote(quote)) { value= extractBetweenQuotes(value, quote); } return Tuple3.tuple3(match.e1, match.e2, value); } TagTranslator(Mapping mapping, Pattern tagPattern, Pattern attributePattern); }
TagTranslator { @VisibleForTesting Tuple3<Integer, Integer, String> attributeValue(String tag) { String normalized= TextTools.removeControlChars(tag); List<Tuple3<Integer, Integer, String>> matches = RegexTools.findAll(attributePattern, normalized, true); if (matches.isEmpty()) return Tuple3.nil(); Tuple3<Integer, Integer, String> match = matches.get(0); String value = match.e3; char quote= value.charAt(0); if (isQuote(quote)) { value= extractBetweenQuotes(value, quote); } return Tuple3.tuple3(match.e1, match.e2, value); } TagTranslator(Mapping mapping, Pattern tagPattern, Pattern attributePattern); String translate(String text); }
TagTranslator { @VisibleForTesting Tuple3<Integer, Integer, String> attributeValue(String tag) { String normalized= TextTools.removeControlChars(tag); List<Tuple3<Integer, Integer, String>> matches = RegexTools.findAll(attributePattern, normalized, true); if (matches.isEmpty()) return Tuple3.nil(); Tuple3<Integer, Integer, String> match = matches.get(0); String value = match.e3; char quote= value.charAt(0); if (isQuote(quote)) { value= extractBetweenQuotes(value, quote); } return Tuple3.tuple3(match.e1, match.e2, value); } TagTranslator(Mapping mapping, Pattern tagPattern, Pattern attributePattern); String translate(String text);  }