module.exports = function convertToJsonProcessor(log, createDocMessage) { return { $runAfter: ['checkUnbalancedBackTicks'], $runBefore: ['writeFilesProcessor'], docTypes: [], $process: function(docs) { const docTypes = this.docTypes; docs.forEach((doc) => { if (docTypes.indexOf(doc.docType) !== -1) { let contents = doc.renderedContent || ''; let title = doc.title; // We do allow an empty `title` but resort to `name` if it is not even defined if (title === undefined) { title = doc.name; } // If there is no title then try to extract it from the first h1 in the renderedContent if (title === undefined) { const match = /