前言
这是一个更新的版本,演示站点仍为:CFLMY-生成至美PPT
新增数学函数支持
直接使用markdwon-it-katex
使用npm安装
1
| npm install markdown-it-katex
|
并导入依赖。
需要在header引入:
1 2
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">
|
新增视频支持
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| module.exports = function(md) { md.renderer.rules.link_open = function (tokens, idx, options, env, self) { const token = tokens[idx]; const alt = tokens[idx + 1].content; const href = tokens[idx].attrs[token.attrIndex('href')][1]; const match_IMG = alt.match(/^(IMG)-(.*?)-(.*)$/); const match_VIDEO = alt.match(/^(VIDEO)-(.*?)$/); if (match_IMG) { const prefix = match_IMG[1]; const imgHref = match_IMG[2]; const description = match_IMG[3]; tokens[idx + 1].content = description; token.customMatch_IMG = true; return `<a href="${href}"> <figure> <img alt="" src="${imgHref}"> <figcaption> <h2> `; } else if(match_VIDEO) { const prefix = match_VIDEO[1]; const description = match_VIDEO[2]; tokens[idx + 1].content = description; token.customMatch_VIDEO = true; return `<div class="wrap size-60"> <!-- Responsive video/iframe... Add <div class="embed"> --> <div class="embed"> <iframe width="800" height="450" src="${href}" allowfullscreen></iframe> </div> <p class="videocaption" > `; } return self.renderToken(tokens, idx, options); }; md.renderer.rules.link_close = function (tokens, idx, options, env, self) { const token = tokens[idx-2]; if (token.customMatch_IMG) { delete token.customMatch_IMG; return `</h2> </figcaption> </figure> </a>`; } else if(token.customMatch_VIDEO) { delete token.customMatch_VIDEO; return `</p> </div>`; } return self.renderToken(tokens, idx, options); }; };
|
为链接格式转化为视频。
其他更新
待更新
- 发现背景图片部分存在Bug,不影响显示效果,但生成的html文件存在问题,后续需要修改。
后记
0.0.4版本新增了对视频和函数的支持。
同系列
CFLMY-PPT自动生成记录文档001
CFLMY-PPT自动生成记录文档002
CFLMY-PPT自动生成记录文档003
CFLMY-PPT自动生成记录文档003