metalsmith-metallic
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -5,2 +5,3 @@ | ||
var hljs = require('highlight.js'); | ||
var entities = require("entities"); | ||
@@ -32,3 +33,3 @@ /** | ||
var end = /```/; | ||
var typed = /```(\w+)\r?\n/; | ||
var typed = /```([\w\-]+)\r?\n/; | ||
var remainder = str; | ||
@@ -66,8 +67,12 @@ var pos = 0; | ||
if (lang==null) { | ||
replacements.push("<code>"+hljs.highlightAuto(code).value+"</code>"); | ||
replacements.push("<pre><code>"+hljs.highlightAuto(code).value+"</code></pre>"); | ||
} else { | ||
try { | ||
replacements.push("<code>"+hljs.highlight(lang, code).value+"</code>"); | ||
if (lang==="no-highlight") { | ||
replacements.push("<pre><code class=\""+lang+"\">"+entities.encodeHTML(code)+"</code></pre>"); | ||
} else { | ||
replacements.push("<pre><code class=\""+lang+"\">"+hljs.highlight(lang, code).value+"</code></pre>"); | ||
} | ||
} catch(err) { | ||
replacements.push("<code>"+hljs.highlightAuto(code).value+"</code>"); | ||
replacements.push("<pre><code>"+hljs.highlightAuto(code).value+"</code></pre>"); | ||
} | ||
@@ -74,0 +79,0 @@ } |
@@ -5,8 +5,12 @@ { | ||
"repository": "git://github.com/weswigham/metalsmith-metallic.git", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"dependencies": { | ||
"debug": "~0.7.4", | ||
"highlight.js": "~8.0.0" | ||
"highlight.js": "~8.1", | ||
"entities": "~1.1" | ||
}, | ||
@@ -13,0 +17,0 @@ "devDependencies": { |
Non code | ||
<code><span class="hljs-built_in">local</span> <span class="hljs-built_in">var</span> <span class="hljs-subst">=</span> <span class="hljs-string">"untyped code"</span></code> | ||
<pre><code><span class="hljs-built_in">local</span> <span class="hljs-built_in">var</span> <span class="hljs-subst">=</span> <span class="hljs-string">"untyped code"</span></code></pre> | ||
<code><span class="hljs-keyword">var</span> t = <span class="hljs-string">'typed code'</span></code> | ||
<pre><code class="js"><span class="hljs-keyword">var</span> t = <span class="hljs-string">'typed code'</span></code></pre> | ||
More non code |
Non code | ||
<code><span class="hljs-built_in">local</span> <span class="hljs-built_in">var</span> <span class="hljs-subst">=</span> <span class="hljs-string">"untyped code"</span></code> | ||
<pre><code><span class="hljs-built_in">local</span> <span class="hljs-built_in">var</span> <span class="hljs-subst">=</span> <span class="hljs-string">"untyped code"</span></code></pre> | ||
<code><span class="hljs-keyword">var</span> t = <span class="hljs-string">'typed code'</span></code> | ||
<pre><code class="js"><span class="hljs-keyword">var</span> t = <span class="hljs-string">'typed code'</span></code></pre> | ||
More non code |
@@ -10,15 +10,30 @@ | ||
it('should highlight code blocks in markdown files', function(done){ | ||
fs.readFile('test/fixture/expected/index.md', 'utf8', function (err,data) { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
Metalsmith('test/fixture') | ||
.use(metallic()) | ||
.build(function(err, files){ | ||
if (err) return done(err); | ||
assert.equal(data.toString(), files['index.md'].contents); | ||
done(); | ||
}); | ||
fs.readFile('test/fixture/expected/index.md', 'utf8', function (err,data) { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
Metalsmith('test/fixture') | ||
.use(metallic()) | ||
.build(function(err, files){ | ||
if (err) return done(err); | ||
assert.equal(data.toString(), files['index.md'].contents); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should parse code blocks with the no-highlight language in markdown files', function(done){ | ||
fs.readFile('test/fixture/expected/nohighlight.md', 'utf8', function (err,data) { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
Metalsmith('test/fixture') | ||
.use(metallic()) | ||
.build(function(err, files){ | ||
if (err) return done(err); | ||
assert.equal(data.toString(), files['nohighlight.md'].contents); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6557
12
116
3
+ Addedentities@~1.1
+ Addedentities@1.1.2(transitive)
+ Addedhighlight.js@8.1.0(transitive)
- Removedhighlight.js@8.0.0(transitive)
Updatedhighlight.js@~8.1