Created
February 16, 2014 15:35
-
-
Save Aimeast/9036104 to your computer and use it in GitHub Desktop.
Combine Highlight.js
This file contains hidden or 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
// A highlight.js packer which work for Git Candy© | |
// The output please reference to https://github.com/Aimeast/GitCandy/blob/dev/GitCandy/Scripts/highlight.pack.js | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var writer = new StreamWriter("highlight.pack.js")) | |
{ | |
writer.WriteLine("//https://github.com/isagalaev/highlight.js"); | |
writer.WriteLine("//Version 8.0 (f08dbfd8c33d7d5c30d736b5a4ef4d1f361e93ae)"); | |
writer.WriteLine(); | |
writer.WriteLine("; (function (window) {"); | |
writer.WriteLine("var hljs = new "); | |
writer.Write(ReadToEnd("highlight.js")); | |
writer.WriteLine("();"); | |
foreach (var item in Directory.GetFiles("languages", "*.js")) | |
{ | |
writer.WriteLine("hljs.registerLanguage(\"" + Path.GetFileNameWithoutExtension(item) + "\","); | |
writer.Write(ReadToEnd(item)); | |
writer.WriteLine(");"); | |
writer.WriteLine(); | |
} | |
writer.WriteLine("window.hljs = hljs;"); | |
writer.WriteLine("hljs.initHighlightingOnLoad();"); | |
writer.WriteLine("})(window);"); | |
} | |
} | |
static string ReadToEnd(string filename) | |
{ | |
using (var reader = new StreamReader(filename)) | |
{ | |
var sb = new StringBuilder(); | |
while (!reader.EndOfStream) | |
sb.AppendLine(reader.ReadLine()); | |
return sb.ToString().TrimEnd(new[] { '\r', '\n' }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment