googlechat icon indicating copy to clipboard operation
googlechat copied to clipboard

Google chat multi line code-blocks do not render properly on element desktop

Open Roukoswarf opened this issue 1 year ago • 2 comments

When sent a codeblock such as:

testing
a
codeblock

From a google chat user, the message will be rendered as a single line lacking \n in element desktop. This is technically element-desktop/element-web's fault, as it does appear properly in element mobile, but is not a problem on matrix to matrix as the message json is different.

Examples:

From bridge:

{
  "type": "m.room.message",
  "content": {
    "msgtype": "m.text",
    "body": "```This message is line 1.\nThis message is line 2.\nThis message is line 3.\nThis message is line 4.```",
    "format": "org.matrix.custom.html",
    "formatted_body": "<pre><code>This message is line 1.<br/>This message is line 2.<br/>This message is line 3.<br/>This message is line 4.</code></pre>",
    "com.beeper.linkpreviews": []
  }
}

From element:

{
  "type": "m.room.message",
  "content": {
    "org.matrix.msc1767.message": [
      {
        "body": "```\nthings\nstuff\nwords\n```",
        "mimetype": "text/plain"
      },
      {
        "body": "<pre><code>things\nstuff\nwords\n</code></pre>\n",
        "mimetype": "text/html"
      }
    ],
    "body": "```\nthings\nstuff\nwords\n```",
    "msgtype": "m.text",
    "format": "org.matrix.custom.html",
    "formatted_body": "<pre><code>things\nstuff\nwords\n</code></pre>\n"
  }
}

I am not sure if this is something I should instead be reporting to element, or if the bridge should add text/html to make element-desktop/web happy.

Roukoswarf avatar Sep 14 '22 18:09 Roukoswarf

Where do you see it as a single line? Only the line numbering is broken for me, the breaks are there 🤔

It's not related to org.matrix.msc1767.message, but it's definitely a client bug (specifically, it doesn't handle <br/> properly). I might still work around it in the bridge since I don't think element web is the only client that has bugs in that area.

tulir avatar Sep 14 '22 18:09 tulir

I played with some settings, it seems to be dependent on syntax highlighting being enabled clientside for codeblocks.

I can reproduce the broken line numbering by disabling syntax highlighting, resulting in the entire 3 line block rendering as line "1". Once highlighting is switched on, messages from the bridge appear in one line.

Roukoswarf avatar Sep 14 '22 19:09 Roukoswarf