Monaco Editor 示例
First Post:
Last Update:
Word Count:
Read Time:
Page View: loading...
Last Update:
Word Count:
345
Read Time:
1 min
Page View: loading...
Monaco Editor
除了 Hexo 自带的 代码块 外,本主题还支持 VS Code 风格的 Monaco Editor。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17{% editor javascript %}
/* global hexo */
'use strict';
function render(data) {
return hexo.render.renderSync({ text: data, engine: 'markdown' });
}
hexo.extend.tag.register('hide', (args) => {
let content = ''
args.forEach((item) => {
content += ' ' + item
});
return `<span class="hide"><object>${render(content.slice(1)).trim()}</object></span>`;
})
{% endeditor %}
editor 标签支持以下参数:
1 | |
language默认为plaintext;theme默认为vs-dark;readOnly默认为true;height默认为300px。
较少使用的参数可通过 extras 项传入。例如,下面示例在超过 40 列时启用折行:
1 | |
更多扩展参数请参阅 Monaco Editor 文档;具体样式效果见 PR #215。
reward
支付宝 | Alipay


微信 | Wechat

