Skip to content

Commit

Permalink
Do not colorize commit logs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MathisMARION committed Nov 30, 2024
1 parent 4df15bd commit 9f57652
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/coloring.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,21 @@ const coloring = {
const preNodes = document.querySelectorAll("body > div > pre");

for (const pre of preNodes) {
for (let i = 0; i < pre.childNodes.length; i++) {
let i, j = -1;

for (i = 0; i < pre.childNodes.length && j < 0; i++) {
if (pre.childNodes[i].nodeName !== "#text") {
/*
* 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);
}
}
if (j >= 0) {
pre.childNodes[i - 1].splitText(j + '---'.length);
}
for (i = 0; i < pre.childNodes.length; i++) {
if (pre.childNodes[i].nodeName === "#text") {
const span = document.createElement("SPAN");

Expand Down

0 comments on commit 9f57652

Please sign in to comment.