Skip to content

Commit

Permalink
Diff: Add nest token
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxsan committed Apr 4, 2020
1 parent 8167005 commit a809e5d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
15 changes: 12 additions & 3 deletions components/prism-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@
alias.push("bold");
}

var pattern = RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm');
var inside = {
'line': {
pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/,
lookbehind: true
},
'prefix': /[\s\S]/
};
Prism.languages.diff[name] = {
// pattern: /^(?:[_].*(?:\r\n?|\n|(?![\s\S])))+/m
pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
alias: alias
pattern: pattern,
alias: alias,
inside: inside
};

});

// make prefixes available to Diff plugin
Expand Down
2 changes: 1 addition & 1 deletion components/prism-diff.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tests/languages/diff/diff_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
----------------------------------------------------

[
["diff", "! qt: core\r\n"],
["unchanged", " unchanged\r\n"],
["deleted-sign", "- qt: core\r\n"],
["inserted-sign", "+ qt: core gui\r\n"],
["deleted-arrow", "< qt: core\r\n"],
["inserted-arrow", "> qt: core quick"]
["diff", [["prefix", "!"], ["line", " qt: core\r\n"]]],
["unchanged", [["prefix", " "], ["line", " unchanged\r\n"]]],
["deleted-sign", [["prefix", "-"], ["line", " qt: core\r\n"]]],
["inserted-sign", [["prefix", "+"], ["line", " qt: core gui\r\n"]]],
["deleted-arrow", [["prefix", "<"], ["line", " qt: core\r\n"]]],
["inserted-arrow", [["prefix", ">"], ["line", " qt: core quick"]]]
]

----------------------------------------------------
Expand Down

0 comments on commit a809e5d

Please sign in to comment.