Skip to content

Commit

Permalink
Merge pull request #450 from uranusjr/diff
Browse files Browse the repository at this point in the history
Add diff syntax definition
  • Loading branch information
Golmote committed Sep 15, 2015
2 parents 3aadd5d + e642a22 commit ef41c74
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 26 deletions.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ var components = {
"require": "clike",
"owner": "Golmote"
},
"diff": {
"title": "Diff",
"owner": "uranusjr"
},
"docker": {
"title": "Docker",
"owner": "JustinBeckwith"
Expand Down
52 changes: 26 additions & 26 deletions components/prism-autohotkey.js

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

20 changes: 20 additions & 0 deletions components/prism-diff.js
Original file line number Diff line number Diff line change
@@ -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'
}
}
1 change: 1 addition & 0 deletions components/prism-diff.min.js

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

36 changes: 36 additions & 0 deletions examples/prism-diff.html
Original file line number Diff line number Diff line change
@@ -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
&lt; qt: core
---
&gt; 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>

0 comments on commit ef41c74

Please sign in to comment.