m->d: Discord code block cannot contain its delimiters #38

Open
opened 2024-02-18 12:30:45 +00:00 by cadence · 1 comment
Owner

Inline code delimited by one backtick cannot contain one backtick.

Inline code delimited by two cannot contain two.

The above cases are handled by discord-markdown.

However, the situation is impossible to resolve when the inline code contains BOTH one and two backticks - neither delimiter would work. The inline code could be converted to a code block, maybe.

Inline code can contain 3 or more backticks in a row, but code blocks cannot.

To do

  • If somebody tries to use inline code with both delimiters in it, it should be converted to a code block.

  • If somebody tries to use a code block with 3 or more backticks, we should upload their code as a file instead.

Technical details

While walking the parsed HTML tree of the Matrix message, search for the backticks in code blocks in the parsed HTML and replace them there. Add the attachment. Then hit Turndown.

Inline code delimited by one backtick cannot contain one backtick. Inline code delimited by two cannot contain two. The above cases are handled by discord-markdown. However, the situation is impossible to resolve when the inline code contains BOTH one and two backticks - neither delimiter would work. The inline code could be converted to a code block, maybe. Inline code can contain 3 or more backticks in a row, but code blocks cannot. ### To do - If somebody tries to use inline code with both delimiters in it, it should be converted to a code block. - If somebody tries to use a code block with 3 or more backticks, we should upload their code as a file instead. ### Technical details While walking the parsed HTML tree of the Matrix message, search for the backticks in code blocks in the parsed HTML and replace them there. Add the attachment. Then hit Turndown.
Author
Owner

This was done for code blocks in 77b7772062 using the HTML tree walker.

This was done for code blocks in 77b7772062a53e272c98c9ae822a8a7fe81e40e8 using the HTML tree walker.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cadence/out-of-your-element#38
No description provided.