Element-android: Multi-line code blocks apply monospace font to entire message

Created on 16 Jan 2020  路  5Comments  路  Source: vector-im/element-android

When using multi-line code blocks in a message, the entire message appears to be rendered as preformatted text. RiotX v0.12.0. See below for example.

2020-01-16-192429_322x179_scrot

Message source containing multi-line code block.
2020-01-16-192636_461x431_scrot

The <pre> tag is correctly placed in formatted_body, but the message renders incorrectly.

event-rendering

Most helpful comment

Yes, those are limitations we are aware of, thanks for having created the issue.

To be honest, we are thinking on removing the scrollability on code blocks and rather replace it with a real code previewer, which will be opened when you click on a code block, and which will display line numbers on the left, will be scrollable in each direction and eventually have syntax coloration. Some libraries may doing this quite well.

This could also be used for (decrypted) event source preview, rather than the simple dialog we have so far.

All 5 comments

It also makes the whole message horizontally scrollabel and not auto breaking if there is a code block..

Yes, those are limitations we are aware of, thanks for having created the issue.

To be honest, we are thinking on removing the scrollability on code blocks and rather replace it with a real code previewer, which will be opened when you click on a code block, and which will display line numbers on the left, will be scrollable in each direction and eventually have syntax coloration. Some libraries may doing this quite well.

This could also be used for (decrypted) event source preview, rather than the simple dialog we have so far.

If there are no good syntax highlighting libraries in kotlin or java it might be a cool project for someone to wrap https://github.com/trishume/syntect in a usable library for Android. It uses the SublimeText syntaxes for highlighting and it's probably a lot faster than doing the highlighting in .js. The easiest way would still be generating html like this https://github.com/trishume/syntect/blob/master/examples/synhtml.rs and displaying it in a webview, but a syntect -> spannable conversion would be really cool

To use rust libraries from gradle this might be helpful: https://github.com/mozilla/rust-android-gradle

@bmarty This is totally a subjective thing, but I personally would prefer code block scrollability over a dedicated code view, since a lot of people I know (myself included) mix code blocks with prose when collaborating with others. A dedicated code view would take you away from the prose as you look at the code, at least from my current understanding of how that'd be implemented.

related/more infos: #1375

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bubu picture Bubu  路  3Comments

532910 picture 532910  路  3Comments

532910 picture 532910  路  3Comments

Bubu picture Bubu  路  3Comments

jtagcat picture jtagcat  路  3Comments