Skip aligning table content

This commit is contained in:
M66B 2020-05-05 13:30:48 +02:00
parent 4117f533ea
commit eed8d3fb34
1 changed files with 32 additions and 22 deletions

View File

@ -519,12 +519,14 @@ public class HtmlHelper {
if ("center".equals(element.tagName())) { if ("center".equals(element.tagName())) {
style = mergeStyles(style, "text-align:center"); style = mergeStyles(style, "text-align:center");
element.tagName("div"); element.tagName("div");
} else if ("table".equals(element.tagName()))
style = mergeStyles(style, "text-align:left");
else {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
String align = element.attr("align");
if (!TextUtils.isEmpty(align))
style = mergeStyles(style, "text-align:" + align);
} }
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
String align = element.attr("align");
if (!TextUtils.isEmpty(align))
style = mergeStyles(style, "text-align:" + align);
} }
// Process style // Process style
@ -1910,25 +1912,33 @@ public class HtmlHelper {
ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break; break;
case "text-align": case "text-align":
for (AlignmentSpan span : ssb.getSpans(0, start, AlignmentSpan.class)) { boolean table = false;
int s = ssb.getSpanStart(span); Element e = element;
ssb.removeSpan(span); while (e != null) {
ssb.setSpan(span, s, start, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if ("table".equals(e.tagName())) {
table = true;
break;
}
e = e.parent();
} }
Layout.Alignment alignment = null;
switch (value) { if (!table) {
case "left": Layout.Alignment alignment = null;
alignment = (ltr ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_OPPOSITE); switch (value) {
break; case "left":
case "center": case "justify":
alignment = Layout.Alignment.ALIGN_CENTER; alignment = (ltr ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_OPPOSITE);
break; break;
case "right": case "center":
alignment = (ltr ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL); alignment = Layout.Alignment.ALIGN_CENTER;
break; break;
case "right":
alignment = (ltr ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL);
break;
}
if (alignment != null)
ssb.setSpan(new AlignmentSpan.Standard(alignment), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
if (alignment != null)
ssb.setSpan(new AlignmentSpan.Standard(alignment), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break; break;
} }
} }