diff --git a/docs/docs-package/index.js b/docs/docs-package/index.js index 829cbe82a4..312841d329 100644 --- a/docs/docs-package/index.js +++ b/docs/docs-package/index.js @@ -18,7 +18,7 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage, .processor(require('./processors/generateNavigationDoc')) .processor(require('./processors/extractTitleFromGuides')) .processor(require('./processors/createOverviewDump')) - +.processor(require('./processors/checkUnbalancedBackTicks')) // Configure the log service .config(function(log) { diff --git a/docs/docs-package/processors/checkUnbalancedBackTicks.js b/docs/docs-package/processors/checkUnbalancedBackTicks.js new file mode 100644 index 0000000000..2d359c7785 --- /dev/null +++ b/docs/docs-package/processors/checkUnbalancedBackTicks.js @@ -0,0 +1,28 @@ +var _ = require('lodash'); + +/** + * @dgProcessor checkUnbalancedBackTicks + * @description + * Searches the rendered content for an odd number of (```) backticks, + * which would indicate an unbalanced pair and potentially a typo in the + * source content. + */ +module.exports = function checkUnbalancedBackTicks(log, createDocMessage) { + + var BACKTICK_REGEX = /^ *```/gm; + + return { + $runAfter: ['checkAnchorLinksProcessor'], + $process: function(docs) { + _.forEach(docs, function(doc) { + if ( doc.renderedContent ) { + var matches = doc.renderedContent.match(BACKTICK_REGEX); + if (matches && matches.length % 2 !== 0) { + log.warn(createDocMessage('checkUnbalancedBackTicks processor: unbalanced backticks found in rendered content', doc)); + console.log(doc.renderedContent); + } + } + }); + } + }; +}; \ No newline at end of file