django markdown

Posted infaaf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django markdown相关的知识,希望对你有一定的参考价值。

1. 编辑器

css

1     <link rel="stylesheet" href="{% static ‘plugin/editor.md/css/editormd.css‘ %}">

 

div

1                 <div id="editormd" class="col-md-10 text-left">
2                     <textarea name="" style="display: none" id="id_body"></textarea>
3 
4                 </div>

提交使用ajax。初次测试使用post内容提交有误

                    <input type="button" class="btn btn-primary btn-lg" value="保存"
                    onclick="publish_article()">

js代码

{% block javasript %}
    <script src="{% static ‘plugin/editor.md/editormd.min.js‘ %}"></script>
    <script>
        $(function () {
            var editor=editormd("editormd",{
                width:"100%",
                height:"640",
                syncScrolling:"single",
                path:"{% static ‘plugin/editor.md/lib/‘ %}"
            });
        })
    </script>



    <script>
    function publish_article() {
        var title=$("#id_title").val();
        var columnid = $("#which_column").val();
        var body = $("#id_body").val();
        $.ajax({
            url:"{% url ‘article:article_post‘ %}",
            type:"POST",
            data:{"title":title,"columnid":columnid,"body":body},
            success:function (args) {
                if(args=="1"){
                    alert("保存完成");
                    location.href="{% url ‘article:article_list‘ %}";
                }else if(args==2){
                    console.log("todo2")
                }else{
                    alert("内容有误,重新填写")
                }
            }
        });
    }
    </script>
{% endblock %}

 

2.查看

{% block head %}
    <link rel="stylesheet" href="{% static ‘plugin/editor.md/css/editormd.preview.css‘ %}">
{% endblock %}


<div id="editormd-view" >
    <textarea name="" id="append-test" style="display: none">
{{ article.body }}
    </textarea>

</div>



{% block javasript %}
    <script src="{% static ‘plugin/editor.md/lib/marked.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/lib/prettify.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/lib/raphael.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/lib/underscore.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/lib/sequence-diagram.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/lib/flowchart.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/lib/jquery.flowchart.min.js‘ %}"></script>
    <script src="{% static ‘plugin/editor.md/editormd.min.js‘ %}"></script>

    <script>
        $(function () {
            editormd.markdownTohtml("editormd-view",{
                htmlDecode:"style,script,iframe",
                emoji:true,
                taskList:true,
                tex:true,
                flowChart:true,
                sequenceDiagram:true,
            });

        });
    </script>
{% endblock %}

 

以上是关于django markdown的主要内容,如果未能解决你的问题,请参考以下文章

markdown PHPExcel Notes和代码片段

markdown Git代码片段

markdown 岩组代码片段

markdown [magento] - 代码片段

markdown 在WordPress中使用jQuery代码片段

markdown 打字稿...编码说明,提示,作弊,指南,代码片段和教程文章