-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmd2html.js
39 lines (36 loc) · 1.07 KB
/
md2html.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const fs = require('fs')
const marked = require('marked')
fs.readFile('./titles.md', 'utf-8', (err, data)=>{
if(err){
throw err
}else{
// 3.使用marked方法,将md格式的文件转化为html格式
let htmlStr = marked(data.toString());
// 4.将转化的html格式的字符串,写入到新的文件中
fs.writeFile('./index.html', htmlStr, err=>{
if(err){
throw err
}else{
console.log("success")
console.log(htmlStr)
}
})
}
})
fs.readFile('./record.md', 'utf-8', (err, data)=>{
if(err){
throw err
}else{
// 3.使用marked方法,将md格式的文件转化为html格式
let htmlStr = marked(data.toString());
// 4.将转化的html格式的字符串,写入到新的文件中
fs.writeFile('./record.html', htmlStr, err=>{
if(err){
throw err
}else{
console.log("success")
console.log(htmlStr)
}
})
}
})