gpt4 book ai didi

javascript - simpleMDE 设置值无法正确解析

转载 作者:行者123 更新时间:2023-12-03 02:51:34 27 4
gpt4 key购买 nike

我正在使用simple markdown editor这在我的形式中就像

<textarea id="editor-board">
<script>
var simplemde = new SimpleMDE({ element: $("#editor-area")[0] });

simplemde.value("# How are
**This is bold** This is normal
_This is italic_ This is normal
```
commands goes here
demo commands
sudo apt update
```");

但这甚至没有在文本区域中加载插件。

然而,将 value 设置为 value('this is simple text'); 效果很好。

如何在编辑器中设置markdown语法?

最佳答案

您可以使用 ES6 Template literals 尝试类似的操作

var simplemde = new SimpleMDE();

simplemde.value(`# How are
**This is bold** This is normal
_This is italic_ This is normal
\`\`\`
commands goes here
demo commands
sudo apt update
\`\`\`
`);
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<link href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p><textarea rows="5" name="text"></textarea></p>

或者对 ES5 执行类似的操作:

var simplemde = new SimpleMDE();

simplemde.value("# How are\n **This is bold** This is normal\n _This is italic_ This is normal\n ```\n commands goes here\n demo commands\n sudo apt update\n ```\n");
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<link href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p><textarea rows="5" name="text"></textarea></p>

关于javascript - simpleMDE 设置值无法正确解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47832282/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com