Skip to content

Commit

Permalink
fix(HtmlParser): remove trailing line breaks
Browse files Browse the repository at this point in the history
Some fediverse servers (e.g. lemmy) add a trailing line break to the
content. Since we add them as well, this can cause up to three line
breaks at the end of a post, resulting in a blank space.
This removes the trailing line breaks before parsing the content.
  • Loading branch information
FineFindus committed Jun 27, 2024
1 parent e8ce2a7 commit 618946a
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public SpanInfo(Object span, int start, Element element, boolean more){
int colorInsert=UiUtils.getThemeColor(context, R.attr.colorM3Success);
int colorDelete=UiUtils.getThemeColor(context, R.attr.colorM3Error);

if(source.endsWith("\n"))
source=source.stripTrailing();

Jsoup.parseBodyFragment(source).body().traverse(new NodeVisitor(){
private final ArrayList<SpanInfo> openSpans=new ArrayList<>();

Expand Down

0 comments on commit 618946a

Please sign in to comment.