From aecd558f1cd2640bea5348322839b7730165f530 Mon Sep 17 00:00:00 2001 From: Alexandre Stanislawski Date: Fri, 26 Jun 2015 17:15:53 +0200 Subject: [PATCH] Make the markdown parser able to generate anchors for headings It uses the following configuration key in the markdown section : idInHeadings. If set to true it will make the headings generated in the markdown have id's like on github. --- lib/jsdoc/util/markdown.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/jsdoc/util/markdown.js b/lib/jsdoc/util/markdown.js index 2708bbd8..ac6d7e9a 100644 --- a/lib/jsdoc/util/markdown.js +++ b/lib/jsdoc/util/markdown.js @@ -104,9 +104,11 @@ function getParseFunction(parserName, conf) { // Marked generates an "id" attribute for headers; this custom renderer suppresses it markedRenderer = new marked.Renderer(); - markedRenderer.heading = function(text, level) { - return util.format('%s', level, text, level); - }; + if(!conf.idInHeadings) { + markedRenderer.heading = function(text, level) { + return util.format('%s', level, text, level); + }; + } // Allow prettyprint to work on inline code samples markedRenderer.code = function(code, language) {