use of org.jsoup.nodes.Document.OutputSettings in project jsoup by jhy.
the class EntitiesTest method escape.
@Test
public void escape() {
String text = "Hello &<> Å å π 新 there ¾ © »";
String escapedAscii = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(base));
String escapedAsciiFull = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(extended));
String escapedAsciiXhtml = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(xhtml));
String escapedUtfFull = Entities.escape(text, new OutputSettings().charset("UTF-8").escapeMode(extended));
String escapedUtfMin = Entities.escape(text, new OutputSettings().charset("UTF-8").escapeMode(xhtml));
assertEquals("Hello &<> Å å π 新 there ¾ © »", escapedAscii);
assertEquals("Hello &<> Å å π 新 there ¾ © »", escapedAsciiFull);
assertEquals("Hello &<> Å å π 新 there ¾ © »", escapedAsciiXhtml);
assertEquals("Hello &<> Å å π 新 there ¾ © »", escapedUtfFull);
assertEquals("Hello &<> Å å π 新 there ¾ © »", escapedUtfMin);
// odd that it's defined as aring in base but angst in full
// round trip
assertEquals(text, Entities.unescape(escapedAscii));
assertEquals(text, Entities.unescape(escapedAsciiFull));
assertEquals(text, Entities.unescape(escapedAsciiXhtml));
assertEquals(text, Entities.unescape(escapedUtfFull));
assertEquals(text, Entities.unescape(escapedUtfMin));
}
use of org.jsoup.nodes.Document.OutputSettings in project jsoup by jhy.
the class EntitiesTest method unescapeMultiChars.
@Test
public void unescapeMultiChars() {
// gg is not combo, but 8811 could conflict with NestedGreaterGreater or others
String text = "≫ ⋙̸ ≫⃒ ≫̸ ≫ ≫";
String un = "≫ ⋙̸ ≫⃒ ≫̸ ≫ ≫";
assertEquals(un, Entities.unescape(text));
String escaped = Entities.escape(un, new OutputSettings().charset("ascii").escapeMode(extended));
assertEquals("≫ ⋙̸ ≫⃒ ≫̸ ≫ ≫", escaped);
assertEquals(un, Entities.unescape(escaped));
}
use of org.jsoup.nodes.Document.OutputSettings in project jsoup by jhy.
the class EntitiesTest method escapeSupplementaryCharacter.
@Test
public void escapeSupplementaryCharacter() {
String text = new String(Character.toChars(135361));
String escapedAscii = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(base));
assertEquals("𡃁", escapedAscii);
String escapedUtf = Entities.escape(text, new OutputSettings().charset("UTF-8").escapeMode(base));
assertEquals(text, escapedUtf);
}
use of org.jsoup.nodes.Document.OutputSettings in project jsoup by jhy.
the class EntitiesTest method escapedSupplemtary.
@Test
public void escapedSupplemtary() {
String text = "𝕙";
String escapedAscii = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(base));
assertEquals("𝕙", escapedAscii);
String escapedAsciiFull = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(extended));
assertEquals("𝕙", escapedAsciiFull);
String escapedUtf = Entities.escape(text, new OutputSettings().charset("UTF-8").escapeMode(extended));
assertEquals(text, escapedUtf);
}
use of org.jsoup.nodes.Document.OutputSettings in project jsoup by jhy.
the class DocumentTest method testHtmlAppendable.
@Test
public void testHtmlAppendable() {
String htmlContent = "<html><head><title>Hello</title></head><body><p>One</p><p>Two</p></body></html>";
Document document = Jsoup.parse(htmlContent);
OutputSettings outputSettings = new OutputSettings();
outputSettings.prettyPrint(false);
document.outputSettings(outputSettings);
assertEquals(htmlContent, document.html(new StringWriter()).toString());
}
Aggregations