From 75cffa130d8c9ae7ba1d5ee74bb8bb5e4a8b2e50 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 18 Feb 2015 11:50:58 +0000 Subject: [PATCH] Tab Replacement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, the default tab width is 8. There’s an option within highlight.js to set a tab replacement, which I’ve set to 2 spaces. Changes have been made to run the post-processing as specified in [the docs](http://highlightjs.readthedocs.org/en/latest/api.html#fixmarkup-va lue) --- docco.js | 8 ++++++-- docco.litcoffee | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docco.js b/docco.js index de6aa418..ad53fc72 100644 --- a/docco.js +++ b/docco.js @@ -113,7 +113,7 @@ highlight: function(code, lang) { lang || (lang = language.name); if (highlightjs.getLanguage(lang)) { - return highlightjs.highlight(lang, code).value; + return highlightjs.fixMarkup(highlightjs.highlight(lang, code).value); } else { console.warn("docco: couldn't highlight code block with unknown language '" + lang + "' in " + source); return code; @@ -124,7 +124,7 @@ for (i = _i = 0, _len = sections.length; _i < _len; i = ++_i) { section = sections[i]; code = highlightjs.highlight(language.name, section.codeText).value; - code = code.replace(/\s+$/, ''); + code = highlightjs.fixMarkup(code).replace(/\s+$/, ''); section.codeHtml = "
" + code + "
"; _results.push(section.docsHtml = marked(section.docsText)); } @@ -242,6 +242,10 @@ version = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'))).version; + highlightjs.configure({ + tabReplace: ' ' + }); + run = function(args) { var c; if (args == null) { diff --git a/docco.litcoffee b/docco.litcoffee index d15f3fa7..67e179a8 100644 --- a/docco.litcoffee +++ b/docco.litcoffee @@ -176,7 +176,7 @@ if not specified. lang or= language.name if highlightjs.getLanguage(lang) - highlightjs.highlight(lang, code).value + highlightjs.fixMarkup highlightjs.highlight(lang, code).value else console.warn "docco: couldn't highlight code block with unknown language '#{lang}' in #{source}" code @@ -184,7 +184,7 @@ if not specified. for section, i in sections code = highlightjs.highlight(language.name, section.codeText).value - code = code.replace(/\s+$/, '') + code = highlightjs.fixMarkup(code).replace /\s+$/, '' section.codeHtml = "
#{code}
" section.docsHtml = marked(section.docsText) @@ -315,6 +315,10 @@ Keep it DRY. Extract the docco **version** from `package.json` version = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'))).version +Tabs are replaced by two spaces in the output. + + highlightjs.configure + tabReplace: ' ' Command Line Interface ----------------------