### Question:
WikiTextUtils { public static String renderAllFormulae(String text) { return StringReplacer.replace(text, MATH_TAG_PATTERN, (Matcher m) -> { try { return TeX2MathML.TeX2MML(m.group(0).replaceAll("<math.*?>", "").replaceAll("</math>", "")); } catch (Exception e) { e.printStackTrace(); return m.group(0); } } ); }  static List<MathTag> findMathTags(String text); static String replaceAllFormulas(String text, List<MathTag> mathTags); static String renderAllFormulae(String text); static String subsup(String markup); static String extractPlainText(String wikiMarkup); static String deLinkify(Word word, ParsedWikiDocument doc); static final Pattern MATH_TAG_PATTERN; }### Answer:
@Test @Ignore public void testRenderAllFormulae() throws Exception { String testString = "The energy <math>E</math>,"; String out = WikiTextUtils.renderAllFormulae(testString); assertEquals("The energy <math xmlns=\"http: " <semantics id=\"p1.1.m1.1a\">\n" + " <mi id=\"p1.1.m1.1.1\" xref=\"p1.1.m1.1.1.cmml\">E</mi>\n" + " <annotation-xml encoding=\"MathML-Content\" id=\"p1.1.m1.1b\">\n" + " <ci id=\"p1.1.m1.1.1.cmml\" xref=\"p1.1.m1.1.1\">E</ci>\n" + " </annotation-xml>\n" + " <annotation encoding=\"application/x-tex\" id=\"p1.1.m1.1c\">E</annotation>\n" + " </semantics>\n" + "</math>,", out); }
@Ignore @Test public void renderResource() throws Exception { final String name = "n20"; String testString = PosTaggerTest.readText(name + "_wiki.txt"); String targetPath = PatternMatchingRelationFinder.class.getResource(name + "_wiki.txt").getPath().replace("_wiki.txt", "_exc.txt"); FileWriter writer = new FileWriter(targetPath); String out = WikiTextUtils.renderAllFormulae(testString); writer.write(out); writer.close(); System.out.println(out); }