Fixed q/cite, added dfn, whitelisted del/s/tt

pull/174/head
M66B 6 years ago
parent 508487190d
commit b154bcff09

@ -322,7 +322,7 @@ public class HtmlHelper {
} }
Whitelist whitelist = Whitelist.relaxed() Whitelist whitelist = Whitelist.relaxed()
.addTags("hr", "abbr", "big", "font") .addTags("hr", "abbr", "big", "font", "dfn", "del", "s", "tt")
.removeTags("col", "colgroup", "thead", "tbody") .removeTags("col", "colgroup", "thead", "tbody")
.removeAttributes("table", "width") .removeAttributes("table", "width")
.removeAttributes("td", "colspan", "rowspan", "width") .removeAttributes("td", "colspan", "rowspan", "width")
@ -441,29 +441,47 @@ public class HtmlHelper {
p.tagName("div"); p.tagName("div");
} }
// Short quotes // Short inline quotes
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q
for (Element q : document.select("q")) { for (Element q : document.select("q")) {
q.prependText("\""); q.tagName("a");
q.appendText("\""); q.attr("href", q.attr("cite"));
q.tagName("em"); q.removeAttr("cite");
} }
// Citation
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite
for (Element cite : document.select("cite")) {
cite.prependText("\"");
cite.appendText("\"");
cite.tagName("em");
}
// Definition
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dfn
for (Element dfn : document.select("dfn"))
dfn.tagName("em");
// Pre formatted text // Pre formatted text
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
for (Element pre : document.select("pre")) { for (Element pre : document.select("pre")) {
pre.html(formatPre(pre.wholeText())); pre.html(formatPre(pre.wholeText()));
pre.tagName("div"); pre.tagName("div");
} }
// Code // Code
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code
document.select("code").tagName("strong"); document.select("code").tagName("strong");
// Lines // Lines
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr
for (Element hr : document.select("hr")) { for (Element hr : document.select("hr")) {
hr.tagName("div"); hr.tagName("div");
hr.text("----------------------------------------"); hr.text("----------------------------------------");
} }
// Descriptions // Descriptions
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl
document.select("dl").tagName("div"); document.select("dl").tagName("div");
for (Element dt : document.select("dt")) { for (Element dt : document.select("dt")) {
dt.tagName("strong"); dt.tagName("strong");
@ -475,9 +493,12 @@ public class HtmlHelper {
} }
// Abbreviations // Abbreviations
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/abbr
document.select("abbr").tagName("u"); document.select("abbr").tagName("u");
// Subscript/Superscript // Subscript/Superscript
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
for (Element subp : document.select("sub,sup")) { for (Element subp : document.select("sub,sup")) {
Element small = document.createElement("small"); Element small = document.createElement("small");
small.html(subp.html()); small.html(subp.html());
@ -485,6 +506,7 @@ public class HtmlHelper {
} }
// Lists // Lists
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li
for (Element li : document.select("li")) { for (Element li : document.select("li")) {
li.tagName("span"); li.tagName("span");
Element parent = li.parent(); Element parent = li.parent();
@ -498,6 +520,7 @@ public class HtmlHelper {
document.select("ul").tagName("div"); document.select("ul").tagName("div");
// Tables // Tables
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
for (Element col : document.select("th,td")) { for (Element col : document.select("th,td")) {
// separate columns // separate columns
if (hasVisibleContent(col.childNodes())) if (hasVisibleContent(col.childNodes()))
@ -532,6 +555,7 @@ public class HtmlHelper {
removeTrackingPixels(context, document); removeTrackingPixels(context, document);
// Images // Images
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
for (Element img : document.select("img")) { for (Element img : document.select("img")) {
String alt = img.attr("alt"); String alt = img.attr("alt");
String src = img.attr("src"); String src = img.attr("src");

Loading…
Cancel
Save