thunder-app/thunder

Additional line breaks before subscript text

Opened this issue · 2 comments

Bug Description

When subscript text is inputted with ~text~ after long enough text without breaks, a post renders with a line break before that text

Thunder rendering post with subscript text

Expected Behaviour

There should be no extra line break

lemmy-ui renders post with a subscript, as seen on programming.dev

Steps to Reproduce

Post a text like . .~s~, you may need to adjust amount of spaces

Additional Context

It seems to depend on screen size and interface size settings:

  1. if the text fits into one line, the subscript part is placed correctly
  2. as preceding line grows and rendered text length grows, the subscript is moved to the next line*
  3. if the preceding line length grows further, additional line breaks will be added to fit line into post window, but an extra line breaks before subscript will remain
  4. Extra line break depends on visible text size, not on a character count, so I suppose that's a rendering bug rather than some markdown engine bug. But I know nothing of Thunder internals, so this might as well be nonsensical statement 😅

* I would argue that it should take the preceding text to the next line if there is no space before subscipt, i.e. not put line break between text~index~ but allow to break text ~index. That's a bit tangential to the issue, though.

App Version

0.3.0-1

Device

Pixel 8 Pro

OS

Android 14 kernel 5.15.110-android14-11-gcc48824eebe8-ab10865596

Thanks for the detailed report! Markdown itself doesn't officially support subscript or superscript tags (see flutter/flutter#81717) so this had to be implemented manually 😅

Just a quick update - I tried a couple of changes on my end to see if I could fix this issue easily, and it seems like its going to take some effort to get this to work properly.

This is what I believe is happening at the moment:

  • When I perform the markdown parsing, it splits up the preceding text and the superscript/subscript text. The preceding text gets processed normally, while the super/subscript text is rendered manually
  • When I render the super/subscript text, it assumes that it's not an inline content so it breaks into a new line in certain situations

I tried to parse both the preceding text and super/subscript text together to get past that issue with it breaking into the next line, but this completely breaks markdown formatting for the preceding text (e.g., bolded text gets shown as raw markdown). This also causes another similar issue with line breaking if there are multiple super/subscripts in a single paragraph.