replaced remark-man with markdown2troff

master
Gregory Scheerlinck 8 years ago
parent 0f62b649be
commit de2552b6ce

@ -1,8 +1,5 @@
'use strict'; 'use strict';
var remark = require('remark');
var man = require('remark-man');
var remarkUnlink = require('remark-unlink');
var Promise = require('bluebird'); var Promise = require('bluebird');
var fsReadFile = Promise.promisify(require('fs').readFile); var fsReadFile = Promise.promisify(require('fs').readFile);
var fsWriteFile = Promise.promisify(require('fs').writeFile); var fsWriteFile = Promise.promisify(require('fs').writeFile);
@ -10,6 +7,7 @@ var fsUnlink = Promise.promisify(require('fs').unlink);
var path = require('path'); var path = require('path');
var getArticlePath = require('./util').getArticlePath; var getArticlePath = require('./util').getArticlePath;
var sanitize = require('sanitize-filename'); var sanitize = require('sanitize-filename');
var toTroff = require('markdown2troff');
var tmp = require('tmp'); var tmp = require('tmp');
var temp = null; var temp = null;
@ -18,11 +16,10 @@ exports.convert = convert;
exports.getContents = getContents; exports.getContents = getContents;
exports.tmpSave = tmpSave; exports.tmpSave = tmpSave;
exports.removeTmp = removeTmp; exports.removeTmp = removeTmp;
exports.processMd = processMd;
exports.getTmp = function getTmpLoc() { return temp; }; exports.getTmp = function getTmpLoc() { return temp; };
function convert(contents, options) { function convert(contents, options) {
return remark.use(man, options).process(contents); return toTroff(contents, options);
} }
function getContents(article) { function getContents(article) {
@ -56,12 +53,3 @@ function removeTmp() {
console.log('Error: ', + err); console.log('Error: ', + err);
}); });
} }
function processMd(article) {
article.contents = article.contents.split('\n').map(function fixContents(line) {
return line.replace(/^( *)\* +((\[[\d\.]+ )(.+?)\]\(#(.+?)\))$/i, '$1$2 ');
}).join('\n');
article.contents = remark().use(remarkUnlink).process(article.contents);
return article;
}

Loading…
Cancel
Save