Permalink
Browse files

Merge remote-tracking branch 'tjbaron/htmlfix'

  • Loading branch information...
2 parents 4a2a925 + d502bea commit 58ffb6d025eca08e3447da7e2e31e6f0f76a197b @jbt committed Feb 15, 2014
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/docker.js
View
@@ -924,11 +924,13 @@ Docker.prototype.languages = {
},
css: {
extensions: [ 'css' ],
- multiLine: [ /\/\*/, /\*\// ],
+ multiLine: [ /\/\*/, /\*\// ], // for when we detect multi-line comments
+ commentStart: '/*', commentEnd: '*/' // for when we add multi-line comments
},
html: {
extensions: [ 'html', 'htm' ],
- multiLine: [ /<!--/, /-->/ ]
+ multiLine: [ /<!--/, /-->/ ],
+ commentStart: '<!--', commentEnd: '-->'
}
};
@@ -985,7 +987,13 @@ Docker.prototype.highlight = function(sections, language, cb){
for(var i = 0; i < sections.length; i += 1){
input.push(sections[i].code);
}
- input = input.join('\n' + params.comment + '----DIVIDER----\n');
+ // If the language we are parsing doesn't have single line comments
+ // (like HTML and CSS) we use a multi-line comment.
+ if (params.comment) {
+ input = input.join('\n' + params.comment + '----DIVIDER----\n');
+ } else {
+ input = input.join('\n' + params.commentStart + '----DIVIDER----' + params.commentEnd + '\n');
+ }
if(this.languages[language].pygment) {
pygment = this.languages[language].pygment
@@ -994,7 +1002,7 @@ Docker.prototype.highlight = function(sections, language, cb){
// Run our input through pygments, then split the output back up into its constituent sections
this.pygments(input, pygment, function(out){
out = out.replace(/^\s*<div class="highlight"><pre>/,'').replace(/<\/pre><\/div>\s*$/,'');
- var bits = out.split(/^<span[^>]*>[^<]+(?:<\/span><span[^>]*>)?----DIVIDER----<\/span>$/gm);
+ var bits = out.split(/^<span[^>]*>[^<]+(?:<\/span><span[^>]*>)?----DIVIDER----[^<]*<\/span>$/gm);
for(var i = 0; i < sections.length; i += 1){
sections[i].codeHtml = '<div class="highlight"><pre>' + bits[i] + '</pre></div>';
sections[i].docHtml = showdown.makeHtml(sections[i].docs);

0 comments on commit 58ffb6d

Please sign in to comment.