Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added pygmentize for code syntax highlighting

  • Loading branch information...
commit cd00a69cbde1288e73e91f0735781404f1ef2b70 1 parent b1ed67b
Richard D. Worth rdworth authored
Showing with 21 additions and 5 deletions.
  1. +1 −1  entries2html.xsl
  2. +18 −3 grunt.js
  3. +2 −1  package.json
2  entries2html.xsl
View
@@ -189,7 +189,7 @@
</span>
</h4>
<pre>
- <code><xsl:choose><xsl:when test="html"><xsl:attribute name="class">example demo-code</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="class">example</xsl:attribute></xsl:otherwise></xsl:choose>&lt;!doctype html&gt;
+ <code data-linenum="true"><xsl:choose><xsl:when test="html"><xsl:attribute name="class">example demo-code</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="class">example</xsl:attribute></xsl:otherwise></xsl:choose>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
21 grunt.js
View
@@ -4,13 +4,14 @@ module.exports = function( grunt ) {
var // modules
fs = require( "fs" ),
path = require( "path" ),
+ pygmentize = require( "pygmentize" ),
spawn = require( "child_process" ).spawn,
// files
entryFiles = grunt.file.expandFiles( "entries/*.xml" ),
resourceFiles = grunt.file.expandFiles( "resources/*" ),
- xmlFiles = [].concat( entryFiles, "categories.xml" );
+ xmlFiles = [].concat( entryFiles, "cat2tax.xsl", "categories.xml", "entries2html.xsl", "xml2json.xsl" );
function pathSlug( fileName ) {
return path.basename( fileName, path.extname( fileName ) );
@@ -85,10 +86,24 @@ grunt.registerTask( "build-entries", function() {
return;
}
grunt.verbose.ok();
+
targetFileName = targetDir + path.basename( fileName );
targetFileName = targetFileName.substr( 0, targetFileName.length - "xml".length ) + "html";
- grunt.file.write( targetFileName, result );
- fileDone();
+
+ grunt.verbose.write( "Pygmentizing " + targetFileName + "..." );
+ pygmentize.file( result, function( error, data ) {
+ if ( error ) {
+ grunt.verbose.error();
+ grunt.log.error( error );
+ fileDone();
+ return;
+ }
+ grunt.verbose.ok();
+
+ grunt.file.write( targetFileName, data );
+
+ fileDone();
+ });
});
}, function() {
if ( task.errorCount ) {
3  package.json
View
@@ -23,7 +23,8 @@
"dependencies": {
"grunt": "0.3.x",
"grunt-clean": "0.1.0",
- "grunt-wordpress": "0.1.1"
+ "grunt-wordpress": "0.1.1",
+ "pygmentize": "0.5.1"
},
"devDependencies": {},
"keywords": []
Please sign in to comment.
Something went wrong with that request. Please try again.