Reverse the order of html inline setSpan

This commit is contained in:
zhangyu.0602 2023-06-27 12:39:12 +08:00
parent 2ea148c30a
commit fb94ad2fd4
2 changed files with 7 additions and 3 deletions

View File

@ -40,7 +40,8 @@ public class HtmlCssStyleParserSample extends MarkwonTextViewSample {
final String md = "# CSS\n\n" +
"<span style=\"background-color: #ff0000;\">this has red background</span> and then\n\n" +
"this <span style=\"color: #00ff00;\">is green</span>";
"this <span style=\"color: #00ff00;\">is green</span>\n\n" +
"<span style=\"color: red;\">A <span style=\"color: blue;\">blue</span> inside the red</span>";
final Markwon markwon = Markwon.builder(context)
.usePlugin(HtmlPlugin.create(plugin -> plugin.addHandler(new SpanTagHandler())))
@ -68,7 +69,7 @@ public class HtmlCssStyleParserSample extends MarkwonTextViewSample {
case "color":
color = Color.parseColor(property.value());
break;
case "background":
case "background-color":
backgroundColor = Color.parseColor(property.value());
break;

View File

@ -193,7 +193,10 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
}
}
action.apply(Collections.unmodifiableList((List<? extends HtmlTag.Inline>) inlineTags));
List<HtmlTag.Inline> reverseOrder =
new ArrayList<>((List<? extends HtmlTag.Inline>) inlineTags);
Collections.reverse(reverseOrder);
action.apply(reverseOrder);
inlineTags.clear();
} else {
action.apply(Collections.<HtmlTag.Inline>emptyList());