如何将markdown保存的内容转换回html

时间:2015-12-27 09:57:35

标签: javascript java html spring-mvc markdown

我在jsp页面中将simplemde-markdown-editor渲染为

<article class="post">
    <div class="form-style-2">      
        <form:form method="post" commandName="post">
            <form:input cssClass="input-field" path="postTitle"/>            
            <form:textarea id="editor" path="postBody"/>
            <input type="submit" value="Save Post"/>    
        </form:form>
    </div>
</article>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
    <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>

    <script>
    new SimpleMDE({
        element: document.getElementById("editor"),
        spellChecker: false,
    });
</script>

所有设置都非常好,但是当我浏览保存的markdown内容时,我会得到与

相同的符号
#### Unordered
* Lists are a piece of cake
* They even auto continue as you type
* A double enter will end them
* Tabs and shift-tabs work too

请帮助。 感谢

1 个答案:

答案 0 :(得分:-1)

只需使用simplemde.markup(simplemde.value());