1. 程式人生 > >html頁面整合markdown編輯器

html頁面整合markdown編輯器

1、markdown安裝包下載地址:

https://github.com/pandao/editor.md/archive/master.zip

2、html中引入markdown時需要引入的js檔案包括:

editormd.js或者editormd.min.js

3、需要引入的css檔案包括:

editormd.css 或 editormd.min.css

相關檔案可以下載安裝包後解壓安裝包獲得。

4、然後在需要嵌入編輯器的html中引入上述js及css兩個檔案

<link rel="stylesheet" href="../css/editormd.css"
/>
<script src="../js/editormd.js"></script>

5、引入檔案後,在頁面中插入這段js程式碼:

<script type="text/javascript">
//    呼叫編輯器
var testEditor;
$(function() {
    testEditor = editormd("test-editormd", {
        width   : "1000px",
        height  : 640,
        syncScrolling : "single",
        path    : "../public/editormd/lib/"
}); });

6、最後,在html需要插入編輯器的位置插入:

<div id="test-editormd">
    <textarea style="display:none;" id="ts"></textarea>
</div>