mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
升级queue为task
This commit is contained in:
1 parent
e7ce8c1f02
commit
5d7f57334f
14 files changed
+145
-130
No files matched your search
@@ -0,0 +1,16 @@
|
||||
global.Hydro.lib.html2md = module.exports = function html2md(str) {
|
||||
return str.replace(/<p>/gmi, '').replace(/<\/p>/gmi, ' ')
|
||||
.replace(/<h1>/gmi, '# ')
|
||||
.replace(/<h2>/gmi, '## ')
|
||||
.replace(/<h3>/gmi, '### ')
|
||||
.replace(/<h4>/gmi, '#### ')
|
||||
.replace(/<h5>/gmi, '##### ')
|
||||
.replace(/<h6>/gmi, '###### ')
|
||||
.replace(/<\/?code>/, '\n```\n')
|
||||
.replace(/<img.*?src=".*?".*?>.*?<\/img>/gmi, (substr) => {
|
||||
const RE_IMG = /<img.*?src="(.*?)".*?>(.*?)<\/img>/i;
|
||||
const res = RE_IMG.exec(substr);
|
||||
return `[${res[2]}](${res[1]})`;
|
||||
})
|
||||
.replace(/<\/h[0-6]>/, '\n');
|
||||
};
|
||||
Reference in new issue
Block a user