【问题标题】:How to convert contents saved from markdown back to html如何将从markdown保存的内容转换回html
【发布时间】:2016-04-01 11:11:38
【问题描述】:

我在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>

所有设置都很好,但是当我浏览保存的降价内容时,我得到与

相同的符号
#### 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

请帮忙。 谢谢

【问题讨论】:

  • “当我浏览markdown的保存内容时”是什么意思?
  • 我的意思是说,当我从textarea 保存内容时,所有降价内容都保存在数据库中,现在我想获取 HTML 格式的内容而不是降价内容'上面已经提到了。
  • 我认为您应该将 Markdown 保存在数据库中,并在请求内容时呈现 HTML。否则用户将很难编辑他们的内容

标签: javascript java html spring-mvc markdown


【解决方案1】:

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-21
  • 1970-01-01
  • 2016-05-08
  • 2017-06-01
  • 2021-07-30
  • 1970-01-01
  • 2019-11-20
相关资源
最近更新 更多