@Test public void replaceNonTranslatableNodeHTML() { String node1NoTranslate = "<span translate=\"no\">do not translate</span>"; String node2 = "<em>translate</em>"; String node4NoTranslate = "<span class=\"notranslate\">do not translate</span>"; String node5NoTranslate = "<span id=\"private-notes-testing\">do not translate</span>"; String node6 = "<span>translate this</span>"; String node7 = "<p>translate this</p>"; String htmlToProcess = node1NoTranslate + node2 + node4NoTranslate + node5NoTranslate + node6 + node7; TranslatableNodeList node = ArticleUtil.replaceNonTranslatableNodeHTML(1, htmlToProcess); assertThat(node.getPlaceholderIdMap().values()) .extracting(Node::toString) .containsExactly(node1NoTranslate, node4NoTranslate, node5NoTranslate); assertThat(node.getHtml()) .contains(node2, node6, node7) .doesNotContain(node1NoTranslate) .doesNotContain(node4NoTranslate) .doesNotContain(node5NoTranslate); }
public static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix, String html) { Element document = wrapHTML(html); Map<String, Node> placeholderIdMap = createPlaceholdersHTML(prefix, document); return new TranslatableNodeList(unwrapAsNodes(document), placeholderIdMap); }
ArticleUtil { public static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix, String html) { Element document = wrapHTML(html); Map<String, Node> placeholderIdMap = createPlaceholdersHTML(prefix, document); return new TranslatableNodeList(unwrapAsNodes(document), placeholderIdMap); } }
ArticleUtil { public static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix, String html) { Element document = wrapHTML(html); Map<String, Node> placeholderIdMap = createPlaceholdersHTML(prefix, document); return new TranslatableNodeList(unwrapAsNodes(document), placeholderIdMap); } @SuppressWarnings("unused") private  ArticleUtil(); }
ArticleUtil { public static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix, String html) { Element document = wrapHTML(html); Map<String, Node> placeholderIdMap = createPlaceholdersHTML(prefix, document); return new TranslatableNodeList(unwrapAsNodes(document), placeholderIdMap); } @SuppressWarnings("unused") private  ArticleUtil(); static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix,
            String html); static TranslatableNodeList replaceNonTranslatableNodeXML(int prefix,
            String xml); static String generatePlaceholderId(int prefix, int index); static Element generatePlaceholderNode(@NotNull String id); static Document wrapHTML(String html); static Document wrapXML(String html); static List<Node> unwrapAsNodes(@NotNull Element element); static List<Node> unwrapAsElements(@NotNull Element element); static @Nullable Node asElement(String html, Function<String, Element> toElement); static String replacePlaceholderWithNode(
            Map<String, Node> nodeIdMap, String xml, Function<String, Element> toElement); }
ArticleUtil { public static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix, String html) { Element document = wrapHTML(html); Map<String, Node> placeholderIdMap = createPlaceholdersHTML(prefix, document); return new TranslatableNodeList(unwrapAsNodes(document), placeholderIdMap); } @SuppressWarnings("unused") private  ArticleUtil(); static TranslatableNodeList replaceNonTranslatableNodeHTML(int prefix,
            String html); static TranslatableNodeList replaceNonTranslatableNodeXML(int prefix,
            String xml); static String generatePlaceholderId(int prefix, int index); static Element generatePlaceholderNode(@NotNull String id); static Document wrapHTML(String html); static Document wrapXML(String html); static List<Node> unwrapAsNodes(@NotNull Element element); static List<Node> unwrapAsElements(@NotNull Element element); static @Nullable Node asElement(String html, Function<String, Element> toElement); static String replacePlaceholderWithNode(
            Map<String, Node> nodeIdMap, String xml, Function<String, Element> toElement);  }