Skip to content

Commit f5101ad

Browse files
committed
markdown格式文本调整
1 parent 2e89ba5 commit f5101ad

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

build/crawler.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ function CreatMarkdown(from_path,to_path){
2525

2626
request.get(from_path).end(function(err, res){
2727
// console.log("to_path::",to_path)
28-
fs.writeFileSync(to_path, toMarkdown(res.text).toString() ,'utf-8');
28+
var md_str = res.text
29+
30+
md_str = md_str.replace(/<pre>/gi,'```\n')
31+
md_str = md_str.replace(/<\/pre>/gi,'\n```')
32+
md_str = md_str.replace(/<span.*?>/gi,'')
33+
md_str = md_str.replace(/<\/span>/gi,'')
34+
md_str = md_str.replace(/\[[^\]]*\]\(.*?\)/g,function(str){
35+
str.replace(/\[(.*?)\]/,'');
36+
return RegExp.$1;
37+
})
38+
39+
fs.writeFileSync(to_path, toMarkdown(md_str).toString() ,'utf-8');
2940
console.log(" → ",to_path)
3041
});
3142

0 commit comments

Comments
 (0)