• markdown源文件转html


    前端

    <!DOCTYPE html>
    <html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>blog</title>
        <link rel="stylesheet" th:href="@{/lib/layui-v2.6.3/css/layui.css}">
        <link rel="stylesheet" th:href="@{/lib/editor.md-master/css/editormd.min.css}">
        <link rel="stylesheet" th:href="@{/lib/editor.md-master/css/editormd.preview.css}">
    </head>
    <body>
    
    <div id="EditorMdview">
        <textarea  th:text="${blog.getContent()}">ok</textarea>
    </div>
    
    <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}"></script>
    <script th:src="@{/lib/editor.md-master/editormd.min.js}"></script>
    <script th:src="@{/lib/editor.md-master/lib/marked.min.js}"></script>
    <script th:src="@{/lib/editor.md-master/lib/prettify.min.js}"></script>
    <script th:inline="none">
    editormd.markdownToHTML("EditorMdview", {
        htmlDecode: "style,script,iframe", //可以过滤标签解码
        emoji: true
    });
    
    </script>
    </body>
    </html>
    

    后端

        @GetMapping("/admin/only_blog/{id}")
        public ModelAndView only_blog(@PathVariable Integer id){
            Blog blog = blogService.getById(id);
            MarkdownUtil.markdownToHtmlExtens(blog.getContent());
            ModelAndView modelAndView = new ModelAndView();
            modelAndView.setViewName("/admin/blogdetail");
            modelAndView.addObject("blog",blog);
    //返回博客 return modelAndView; }

      

  • 相关阅读:
    Java网络编程
    IDEA maven-3.6.2 Unable to import maven project错误
    Java通过ArrayList的contains(Object o)方法实现去重字符串中的字符
    常用的Unicode值范围
    Java函数(方法)的默认值问题
    [Noip2017]宝藏
    [Noip2017]组合数问题
    [Noip2018]赛道修建
    [Noip2018]旅行(数据加强版)
    [Noip2019]树的重心
  • 原文地址:https://www.cnblogs.com/zhukaile/p/16126227.html
Copyright © 2020-2023  润新知