-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests for JavaScript highlighting
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<span class="hljs-keyword">var</span> X = React.createClass({ | ||
render: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{ | ||
<span class="hljs-keyword">var</span> c = <span class="hljs-keyword">this</span>.map(c => <span class="xml"><span class="hljs-tag"><<span class="hljs-title">Comment</span> <span class="hljs-attribute">comment</span>=<span class="hljs-value">{c}</span> <span class="hljs-attribute">key</span>=<span class="hljs-value">{c.id}</span> /></span>)</span>; | ||
<span class="hljs-keyword">return</span> ( | ||
<span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span> <span class="hljs-attribute">className</span>=<span class="hljs-value">'comments'</span>></span> | ||
{c} | ||
<span class="hljs-tag"></<span class="hljs-title">div</span>></span> | ||
)</span>; | ||
}, | ||
foo: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{} | ||
}); | ||
|
||
<span class="hljs-keyword">var</span> Comment = React.createClass({ | ||
render: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{ | ||
<span class="hljs-keyword">var</span> comment = <span class="hljs-keyword">this</span>.props.comment; | ||
<span class="hljs-keyword">return</span> ( | ||
<span class="xml"><span class="hljs-tag"><<span class="hljs-title">li</span>></span>{comment}<span class="hljs-tag"></<span class="hljs-title">li</span>></span> | ||
)</span>; | ||
} | ||
foo: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var X = React.createClass({ | ||
render: function() { | ||
var c = this.map(c => <Comment comment={c} key={c.id} />); | ||
return ( | ||
<div className='comments'> | ||
{c} | ||
</div> | ||
); | ||
}, | ||
foo: function() {} | ||
}); | ||
|
||
var Comment = React.createClass({ | ||
render: function() { | ||
var comment = this.props.comment; | ||
return ( | ||
<li>{comment}</li> | ||
); | ||
} | ||
foo: function() {} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">$initHighlight</span><span class="hljs-params">(block, cls)</span> </span>{ | ||
<span class="hljs-keyword">try</span> { | ||
<span class="hljs-keyword">if</span> (cls.search(<span class="hljs-regexp">/\bno\-highlight\b/</span>) != -<span class="hljs-number">1</span>) | ||
<span class="hljs-keyword">return</span> process(block, <span class="hljs-literal">true</span>, <span class="hljs-number">0x0F</span>) + | ||
<span class="hljs-string">' class=""'</span>; | ||
} <span class="hljs-keyword">catch</span> (e) { | ||
<span class="hljs-comment">/* handle exception */</span> | ||
} | ||
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span> / <span class="hljs-number">2</span>; i < classes.length; i++) { | ||
<span class="hljs-keyword">if</span> (checkCondition(classes[i]) === <span class="hljs-literal">undefined</span>) | ||
<span class="hljs-keyword">return</span> <span class="hljs-regexp">/\d+[\s/]/g</span>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function $initHighlight(block, cls) { | ||
try { | ||
if (cls.search(/\bno\-highlight\b/) != -1) | ||
return process(block, true, 0x0F) + | ||
' class=""'; | ||
} catch (e) { | ||
/* handle exception */ | ||
} | ||
for (var i = 0 / 2; i < classes.length; i++) { | ||
if (checkCondition(classes[i]) === undefined) | ||
return /\d+[\s/]/g; | ||
} | ||
} |