You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support inline code blocks in commit messages, like github #18104
Unlike on github, github desktop does not support markdown inline code blocks in commit messages
Here's what this looks like on the website:
Proposed solution
I suggest that within the commit message input field, anything surrounded with ` is rendered in a monospace font and elsewhere it's rendered as a code block like this.
The feature request
I often enclose code parts in backticks when writing commit messages. For example, this is a commit message I just made:
Rename addChildren method to addItems
Writing backticks takes time, so it would be great if Desktop could support the same CMD/CTRL+E shortcut as GitHub uses.
Proposed solution
Pressing CMD/CTRL+E adds backticks around the selected text
Additional context
No response
Reacted by motchy and Mr Beedell, Roke Julian Lockhart
changed the title [-]Support inline `code block` in commit messages, like github[/-][+]Support inline `code block`s in commit messages, like github[/+]on Jan 30, 2024
Some context as there are a couple way to go about this. For our current commit summaries and descriptions we use our RichText component and it in turn uses a custom Tokenizer to search for patterns and replace them with generated html. These patterns currently include emoji's, issue references, username references, and hyperlinks. Theoretically, we could simply add another token search to it for the backticks. Unfortunately, that would look something like "grab random input from user between backticks" and inject into html. Opening up possibilities for script injection.. so a no go.
We do have somewhere in the app that we do parse markdown such as the code blocks. It is our SandboxedMarkdown component. We currently use this for showing PR comments in conjunction with our notifications about PRs. How it works is that it takes markdown and runs it through a sanitizer and then through a markdown parser and then renders the produced html in a sandboxed iframe. Thus, it even if a script injection makes it past the sanitizer and markdown parser, it would be isolated to the iframe.
Tho, SandboxedMarkdown I believe (needs verified) does parse the same things as the Tokenizer used by the RichText component, simply substituting the RichText for the SandboxedMarkdown should be done with caution and investigation. Some drawbacks off the top of my head:
This would necessarily mean that we would parse any markdown tokens which may mean a different experience than dotcom and not necessarily expected behavior. One line summaries maybe alright tho since that should exclude things like headings and quotation blocks... but should be checked for other differences with dotcom. Maybe we would need to make the SandboxedMarkdown smarter and have the ability to turn off unwanted filters.
The SandboxedMarkdown Parser maybe slower than the Tokenizer since it is parsing for multiple things. (Back to turning off unwanted filters..might be more efficient)
The SandboxedMarkdown parser is an iframe and will take some more css effort to make it look seemless. Need to make sure it plays nicely with the expandable commit summary. Also, that it reads and links are navigable as expected by screen readers for accessibility.
Another potential more targeted solution would be to use the tokenizer in combination with the SandboxedMarkdown parser, that is, search for backticks and if found dump the backticks and anything inside them into the SandboxedMarkdown parser. I know a lot of the filters in the markdown parser are setup to basically skip if the backticks are present so this may lend for an efficient solution. The drawbacks are still similar to above tho and should be considered.
I am having trouble figuring out how to implement this feature. If this is still something that we would like to implement, would someone be willing to help me out a little bit?
Mostly I just need to understand exactly how I should apply the new rendering code into the current codebase. Which files should I look at specifically?
Activity
[-]Support inline `code block` in commit messages, like github[/-][+]Support inline `code block`s in commit messages, like github[/+]DylanDevelops commentedon Feb 2, 2024
I'm down to take on this issue. Can someone point me in the right direction on how a feature like this would be implemented?
tidy-dev commentedon Feb 12, 2024
@DylanDevelops Thanks for wanting to take this on!
Some context as there are a couple way to go about this. For our current commit summaries and descriptions we use our
RichTextcomponent and it in turn uses a customTokenizerto search for patterns and replace them with generated html. These patterns currently include emoji's, issue references, username references, and hyperlinks. Theoretically, we could simply add another token search to it for the backticks. Unfortunately, that would look something like "grab random input from user between backticks" and inject into html. Opening up possibilities for script injection.. so a no go.We do have somewhere in the app that we do parse markdown such as the code blocks. It is our
SandboxedMarkdowncomponent. We currently use this for showing PR comments in conjunction with our notifications about PRs. How it works is that it takes markdown and runs it through a sanitizer and then through a markdown parser and then renders the produced html in a sandboxed iframe. Thus, it even if a script injection makes it past the sanitizer and markdown parser, it would be isolated to the iframe.Tho,
SandboxedMarkdownI believe (needs verified) does parse the same things as theTokenizerused by theRichTextcomponent, simply substituting theRichTextfor theSandboxedMarkdownshould be done with caution and investigation. Some drawbacks off the top of my head:SandboxedMarkdownsmarter and have the ability to turn off unwanted filters.Another potential more targeted solution would be to use the tokenizer in combination with the
SandboxedMarkdownparser, that is, search for backticks and if found dump the backticks and anything inside them into theSandboxedMarkdownparser. I know a lot of the filters in the markdown parser are setup to basically skip if the backticks are present so this may lend for an efficient solution. The drawbacks are still similar to above tho and should be considered.DylanDevelops commentedon Mar 29, 2024
So sorry, I've been really busy. I may be able to get to this, this weekend.
DylanDevelops commentedon Apr 24, 2024
I am having trouble figuring out how to implement this feature. If this is still something that we would like to implement, would someone be willing to help me out a little bit?
Mostly I just need to understand exactly how I should apply the new rendering code into the current codebase. Which files should I look at specifically?
Render code spans and links in commit messages
Render code spans and links in commit messages
Render code spans and links in commit messages