improve list rendering implementation
This commit is contained in:
parent
4880c642fe
commit
a7a29db8d5
|
@ -91,12 +91,6 @@ public class HtmlParser{
|
||||||
ssb.append(textNode.text());
|
ssb.append(textNode.text());
|
||||||
}else if(node instanceof Element el){
|
}else if(node instanceof Element el){
|
||||||
switch(el.nodeName()){
|
switch(el.nodeName()){
|
||||||
case "p" -> {
|
|
||||||
Node sib=el.previousSibling();
|
|
||||||
// compensate for missing empty line after </ul> to match the empty
|
|
||||||
// line added by the <p> before <ul> elements
|
|
||||||
if(sib!=null && !sib.nodeName().equals("p")) ssb.append('\n');
|
|
||||||
}
|
|
||||||
case "a" -> {
|
case "a" -> {
|
||||||
String href=el.attr("href");
|
String href=el.attr("href");
|
||||||
LinkSpan.Type linkType;
|
LinkSpan.Type linkType;
|
||||||
|
@ -137,7 +131,7 @@ public class HtmlParser{
|
||||||
if(node instanceof Element el){
|
if(node instanceof Element el){
|
||||||
if("span".equals(el.nodeName()) && el.hasClass("ellipsis")){
|
if("span".equals(el.nodeName()) && el.hasClass("ellipsis")){
|
||||||
ssb.append("…", new DeleteWhenCopiedSpan(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
ssb.append("…", new DeleteWhenCopiedSpan(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}else if("p".equals(el.nodeName())){
|
}else if("p".equals(el.nodeName()) || "ul".equals(el.nodeName()) || "ol".equals(el.nodeName())){
|
||||||
if(node.nextSibling()!=null)
|
if(node.nextSibling()!=null)
|
||||||
ssb.append("\n\n");
|
ssb.append("\n\n");
|
||||||
}else if(!openSpans.isEmpty()){
|
}else if(!openSpans.isEmpty()){
|
||||||
|
@ -147,9 +141,7 @@ public class HtmlParser{
|
||||||
openSpans.remove(openSpans.size()-1);
|
openSpans.remove(openSpans.size()-1);
|
||||||
}
|
}
|
||||||
if("li".equals(el.nodeName())) {
|
if("li".equals(el.nodeName())) {
|
||||||
ssb.append('\n');
|
if(node.nextSibling()!=null) ssb.append('\n');
|
||||||
Node sib=node.nextSibling();
|
|
||||||
if(sib!=null && !sib.nodeName().equals("li")) ssb.append('\n');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue