Permalink
Browse files

Fixes #8 - filter carriage returns before highlighting

  • Loading branch information...
Andris Reinman
Andris Reinman committed Apr 13, 2012
1 parent edccb41 commit 052fc34acbf7ada2be1eb87777206143e45151dd
Showing with 7 additions and 6 deletions.
  1. +5 −5 examples/test.js
  2. +1 −0 lib/highlight.js
  3. +1 −1 package.json
View
@@ -1,11 +1,11 @@
var hl = require("../lib/highlight.js").Highlight,
- code_string = "<?php\n"+
- "\techo \"Hello world!\";\n"+
- "\tfor($i=0;$i<100;$i++){\n"+
- "\t\techo \"$i\";\n"+
- "\t}\n"+
+ code_string = "<?php\r\n"+
+ "\techo \"Hello world!\";\r\n"+
+ "\tfor($i=0;$i<100;$i++){\r\n"+
+ "\t\techo \"$i\";\r\n"+
+ "\t}\r\n"+
"?>",
code_block = "<p>PHP code:</p>\n"+
View
@@ -146,6 +146,7 @@ var self = this;
**/
function highlight(text, tabReplace, useCodeBlocks){
tabReplace = tabReplace || ' ';
+ text = text.replace(/\r\n|\r|\n/g, '\n'); // remove \r
if (!!useCodeBlocks) {
// JS regexpes have some multiline issues, so we temporarily remove them
return text
View
@@ -1,7 +1,7 @@
{
"name" : "highlight",
"description" : "Highlight code syntax with node.js",
- "version" : "0.2.0",
+ "version" : "0.2.2",
"author" : "Andris Reinman",
"maintainers":[
{

0 comments on commit 052fc34

Please sign in to comment.