void (boolean inlineTagsSupported) { { TextContent text = extractText("a.html", "<b>abc</b>", 4); assertEquals(inlineTagsSupported ? "abc" : "|abc|", unknownOffsets(text)); Assertions.assertArrayEquals(inlineTagsSupported ? new int[]{0, 3} : new int[0], text.markupOffsets()); } assertEquals("|abc|", unknownOffsets(extractText("a.xml", "<b>abc</b>", 4))); assertEquals("|characters with markup\nand without it|", unknownOffsets(extractText("a.xml", "<b><![CDATA[\n characters with markup\n]]>and without it</b>", 22))); assertEquals("abcd efg", unknownOffsets(extractText("a.xml", "<tag attr=\"abcd efg\"/>", 14))); assertEquals("comment", extractText("a.xml", "<!-- comment -->", 10).toString()); assertEquals("top-level text", unknownOffsets(extractText("a.html", "top-level text", 2))); //nothing in HTML <code> tag assertNull(extractText("a.html", "<code>abc</code>def", 7)); assertEquals("|def", unknownOffsets(extractText("a.html", "<code>abc</code>def", 18))); assertEquals("|abc|", unknownOffsets(extractText("a.xml", "<code>abc</code>", 6))); if (inlineTagsSupported) { String longHtml = "<body><a>Hello</a> <b>world</b><code>without code</code>!<div/>Another text.</body>"; TextContent text = extractText("a.html", longHtml, 9); assertEquals("Hello world|", unknownOffsets(text)); Assertions.assertArrayEquals(new int[]{0, 5, 6}, text.markupOffsets()); assertEquals("|Another text.", unknownOffsets(extractText("a.html", longHtml, 70))); text = extractText("a.html", "<div>Hello <span>world</span>!</div>", 20); assertEquals("|Hello world!|", unknownOffsets(text)); Assertions.assertArrayEquals(new int[]{6, 11}, text.markupOffsets()); assertEquals("|Hello\nworld!|", unknownOffsets(extractText("a.html", "<div>\n Hello\n world!\n</div>", 20))); assertEquals("|def", unknownOffsets(extractText("a.html", "<div>abc</div>def", 16))); assertOrderedEquals(extractText("a.html", "<div>Hello world!</div>", 10).getRangesInFile(), new TextRange(5, 17)); } }