Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion scripts/coloring.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@ 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;
let 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);
Copy link
Owner

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.

}
}
if (j >= 0) {
pre.childNodes[i - 1].splitText(j + "---".length);
}
for (; i < pre.childNodes.length; i++) {
if (pre.childNodes[i].nodeName === "#text") {
const span = document.createElement("SPAN");

Expand Down
Loading