https://github.com/markdown-it/markdown-it
‘use strict‘; const md = require(‘markdown-it‘)(); const fs = require(‘fs‘); fs.watchFile(‘./txt/1.md‘, (curr, prev) => { let mdStr = fs.readFile(‘./txt/1.md‘, ‘utf-8‘, (err, data) => { let mdData = md.render(data); let htmlTemplate = fs.readFile(‘./txt/index.html‘, ‘utf-8‘, (err, data) => { let html = data.replace(‘{{content}}‘, mdData); console.log(mdData); fs.writeFile(‘./txt/nodejs.html‘, html, ‘utf-8‘, (err, data) => { if (err) { throw err; } else { console.log(‘OK‘); } }); }); }); });
时间: 2024-11-08 12:03:44