Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT(client,markdown): Support multiple code-blocks per message #6639

Closed
wants to merge 0 commits into from

Conversation

GeneralUser01
Copy link
Contributor

The way code-blocks are handled was here changed to support multiple code-blocks per message.

This allows content that is not formatted as code between code-blocks, whereas previously everything between the first start of a code-block and the last end of a code-block would become part of one code-block. The only other change is to only end a code-block on the end-signature when it is right after a new line, so triple backticks may also be included as long as they are not at the start of a line.

For explanation on how the regex functions, see perl - Regex to match any character including new lines

Checks

@Krzmbrzl
Copy link
Member

Krzmbrzl commented Nov 27, 2024

only end a code-block on the end-signature when it is right after a new line, so triple backticks may also be included as long as they are not at the start of a line.

I assume this is in accordance with the Markdown spec (or at least what most dialects use)?


Bla```

EDIT: seems that at least GitHub agrees that triple backticks may be part of code blocks

@GeneralUser01
Copy link
Contributor Author

GeneralUser01 commented Nov 28, 2024

Including triple backticks that are not at the start of a line deviates slightly from GitHub flavored Markdown, which requires triple backticks to on the same line be preceded by either four spaces or a non-whitespace character. I suppose it is designed this way to make it more visible if the triple backticks really are at the start of a line or close to it and thereby work as the mark to end the code-block. Still, this change to include triple backticks at all is more flexible in terms of what content it supports when formatted as usual with at least one new line both when starting and ending the content section, though I will consider changing this again to more closely match the GitHub flavored Markdown when it comes to code-blocks. I'm not sure what exact code-block formatting most Markdown flavors use, if anyone here could elaborate on that and/or has some sources on it then they may share it. However, this is a smaller change that the main change of supporting multiple code-blocks per message is independent from.

Regarding the info string right after a code-block's initial triple backticks, it is currently accepted but ignored. This would usually be used for specifying a language to provide syntax highlighting for and it could be accessed from the regex via another capture group. If it were implemented, would syntax highlighting be a welcome addition? If so, are there any particular conditions that feature should fulfill?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants