我尝试使用这里提到的markdown-js:
How to print out a markdown file on the console using node.js?
function readmarkdown (error, page) {
if (error) {
Response.writeHead(404);
Response.write('Error');
Response.end();
} else {
Response.writeHead(200, { 'Content-Type': 'text/html' });
var markdown = require("markdown-js");
Response.write(markdown.makeHtml(page));
Response.end();
}
}
fs.readFile( __dirname + 'markdown.md', readmarkdown);
为什么我会收到此错误:
text = text.replace(/¨/g, '¨T');
TypeError: text.replace is not a function
at makeHtml