-
Notifications
You must be signed in to change notification settings - Fork 6
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
Do not colorize commit logs #120
Conversation
Patch e-mails typically include a commit log as a header, which may contain arbitrary text including patterns that highlight.js can interpret as a diff. I have typically encountered this when a commit log line starts with a commandline option or a bullet point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've noticed the same issue, but it never annoyed me enough that I'd take the time to fix it. Thanks for working on it!
* man git-format-patch: The log message and the patch are | ||
* separated by a line with a three-dash line. | ||
*/ | ||
j = pre.childNodes[i].textContent.search(/^---$/m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly concerned that this might be a bit large and catch other things than the git format-patch
separator. I'm thinking that Markdown files can use ^---$
as separators, for example. On the other hand, if we end up colouring a raw Markdown file with diff syntax, it will be messed up anyway. So yeah, maybe we can do that and see if anyone complains that it break their patches.
Trying the add-on with this PR I noticed that we fail to colourise the patch for blocks where we don't have the |
Another comment: we're still highlighting list items when they're below the This is v2 of my patch
I have a description here.
- Lots of details!
- Oh by the way GitHub colours these as well
---
Changes since v1:
- rework foobar
- These list items
- Will get colours with the add-on
---
foobar | 1 +-
1 file changed, 1 insertions(+), 1 deletions(-)
diff --git a/foobar b/foobar
index c55878bdd9dd..db53c8d7d112 100755
--- a/foobar
+++ b/foobar
@@ -37,10 +37,11 @@ this is my patch
some random text
more random text
and even more
- remove this
+ add that
lorem ipsum
dolor sic amet
blah |
That was one of my concerns with this patch: There is still an edge case with testing |
We would have to copy the parser behavior from |
I've stumbled on that with a patch that (I guess) the person copy-pasted to their email, without inserting the delimiter. But not highlighting without the As for the part of the patch between the two delimiters, I reported it to keep track of this, it doesn't mean we should fix it. I don't want another parser in the add-on: it would likely be fragile, wouldn't support other formats, and honestly I have no appetite for maintaining this. By the way - I reported here because it was related to the PR, but it doesn't mean I'm expecting you to fix this 🙂. I'll look more into the first issue, eventually, unless you beat me to it. |
Patch e-mails typically include a commit log as a header, which may contain arbitrary text including patterns that highlight.js can interpret as a diff. I have typically encountered this when a commit log line starts with a commandline option or a bullet point.
I am not sure if people actually send raw diffs without a commit log, so maybe this should be handled with a bit more care to handle these.