laobubu / HyperMD

A WYSIWYG Markdown Editor for browsers. Break the Wall between writing and previewing.
MIT License
1.47k stars 137 forks source link

html无法得到渲染 #61

Open liuqinh2s opened 5 years ago

liuqinh2s commented 5 years ago

我按照快速开始中的代码:

var HyperMD = require("hypermd")
// hypermd 模块会引入 codemirror 和一堆 css 文件

// 如果需要为特殊元素添加语法高亮,请载入对应的模式
require("codemirror/mode/htmlmixed/htmlmixed") // Markdown 内嵌HTML
require("codemirror/mode/stex/stex") // TeX 数学公式
require("codemirror/mode/yaml/yaml") // Front Matter

// 如果需要用第三方库增强 HyperMD 功能,请载入所需的 PowerPacks
require("hypermd/powerpack/fold-math-with-katex") // 将会自动引入 "katex"
require("hypermd/powerpack/hover-with-marked") // 将会自动引入 "marked"
// 你还可以再此添加其他 power packs...
// Power packs 需要第三方库,别忘记安装它们!

var myTextarea = document.getElementById("myTextarea")
var cm = HyperMD.fromTextArea(myTextarea, {
  /* 在此添加其他编辑器选项 */
  hmdModeLoader: false, // 见下面的备注
})

发现html的表格不能渲染: image 错误的渲染: image 正确的渲染: image

liuqinh2s commented 5 years ago

所有的setOption失效,例如:

cm.setOption("hmdFoldEmoji", {
          enabled: false
        });

之后,表情还是会渲染。打印:

console.log(cm.getOption('hmdFoldEmoji'));

发现确实是false,但没卵用。

liuqinh2s commented 5 years ago

image

我通过打印 console.log(this.cm.hmd.Fold) 发现了其实通过setOption还是没有设置成功,然后我强行设置:

this.cm.hmd.Fold._enabled.emoji = false;
this.cm.hmd.Fold._enabled.html = true;

终于成功了