Add diff syntax definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/components.js b/components.js
index 46c2fae..5703718 100644
--- a/components.js
+++ b/components.js
@@ -136,6 +136,10 @@ var components = {
"require": "clike",
"owner": "Golmote"
},
+ "diff": {
+ "title": "Diff",
+ "owner": "uranusjr"
+ },
"docker": {
"title": "Docker",
"owner": "JustinBeckwith"
diff --git a/components/prism-diff.js b/components/prism-diff.js
new file mode 100644
index 0000000..f01858d
--- /dev/null
+++ b/components/prism-diff.js
@@ -0,0 +1,20 @@
+Prism.languages.diff = {
+ 'coord': [
+ // Match all kinds of coord lines (prefixed by "+++", "---" or "***").
+ /^(\*{3}|-{3}|\+{3}).*$/m,
+ // Match "@@ ... @@" coord lines in unified diff.
+ /^@@.*@@$/m,
+ // Match coord lines in normal diff (starts with a number).
+ /^\d+.*$/m,
+ ],
+
+ // Match inserted and deleted lines. Support both +/- and >/< styles.
+ 'deleted': /^[-<].+$/m,
+ 'inserted': /^[+>].+$/m,
+
+ // Match "different" lines (prefixed with "!") in context diff.
+ 'diff': {
+ 'pattern': /^\!(?!\!).+$/m,
+ 'alias': 'important'
+ }
+}
diff --git a/components/prism-diff.min.js b/components/prism-diff.min.js
new file mode 100644
index 0000000..57cc657
--- /dev/null
+++ b/components/prism-diff.min.js
@@ -0,0 +1 @@
+Prism.languages.diff={coord:[/^(\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d+.*$/m],deleted:/^[-<].+$/m,inserted:/^[+>].+$/m,diff:{pattern:/^\!(?!\!).+$/m,alias:"important"}};
\ No newline at end of file
diff --git a/examples/prism-diff.html b/examples/prism-diff.html
new file mode 100644
index 0000000..0bc7723
--- /dev/null
+++ b/examples/prism-diff.html
@@ -0,0 +1,36 @@
+<h1>Diff</h1>
+<p>To use this language, use the class "language-diff".</p>
+
+<h2>Normal Diff</h2>
+<pre><code>7c7
+< qt: core
+---
+> qt: core quick</code></pre>
+
+<h2>Context Diff</h2>
+<pre><code>*** qcli.yml 2014-12-16 11:43:41.000000000 +0800
+--- /Users/uranusjr/Desktop/qcli.yml 2014-12-31 11:28:08.000000000 +0800
+***************
+*** 4,8 ****
+ project:
+ sources: "src/*.cpp"
+ headers: "src/*.h"
+! qt: core
+ public_headers: "src/*.h"
+--- 4,8 ----
+ project:
+ sources: "src/*.cpp"
+ headers: "src/*.h"
+! qt: core gui
+ public_headers: "src/*.h"</code></pre>
+
+<h2>Unified Diff</h2>
+<pre><code>--- qcli.yml 2014-12-16 11:43:41.000000000 +0800
++++ /Users/uranusjr/Desktop/qcli.yml 2014-12-31 11:28:08.000000000 +0800
+@@ -4,5 +4,5 @@
+ project:
+ sources: "src/*.cpp"
+ headers: "src/*.h"
+- qt: core
++ qt: core gui
+ public_headers: "src/*.h"</code></pre>
\ No newline at end of file