فهرست منبع

优化导入后的显示

Minho 7 سال پیش
والد
کامیت
3a1337c0bd
4فایلهای تغییر یافته به همراه14 افزوده شده و 11 حذف شده
  1. 8 5
      models/BookModel.go
  2. 4 1
      static/css/markdown.preview.css
  3. 2 2
      static/js/kancloud.js
  4. 0 3
      views/document/default_read.tpl

+ 8 - 5
models/BookModel.go

@@ -620,11 +620,14 @@ func (book *Book) ImportBook(zipPath string) error {
 					return link
 				})
 
-				doc.Content = string(blackfriday.Run([]byte(doc.Markdown),
-							blackfriday.WithExtensions(blackfriday.Tables),
-							blackfriday.WithExtensions(blackfriday.HeadingIDs),
-								blackfriday.WithExtensions(blackfriday.FencedCode),
-								blackfriday.WithExtensions(blackfriday.AutoHeadingIDs)))
+				//codeRe := regexp.MustCompile("```\\w+")
+
+				//doc.Markdown = codeRe.ReplaceAllStringFunc(doc.Markdown, func(s string) string {
+				//	//beego.Info(s)
+				//	return strings.Replace(s,"```","``` ",-1)
+				//})
+
+				doc.Content = string(blackfriday.Run([]byte(doc.Markdown)))
 
 				doc.Version = time.Now().Unix()
 

+ 4 - 1
static/css/markdown.preview.css

@@ -56,9 +56,12 @@
     border-radius:0;
     line-height: 1.4em;
 }
-.editormd-preview-container pre.prettyprint, .editormd-html-preview pre.prettyprint{
+.editormd-preview-container pre.prettyprint, .editormd-html-preview pre.prettyprint {
     padding: 0;
 }
+.hljs{
+    padding: 10px 15px !important;
+}
 .editormd-preview-container ol.linenums, .editormd-html-preview ol.linenums{
     color: #999;
 }

+ 2 - 2
static/js/kancloud.js

@@ -69,11 +69,11 @@ function loadDocument($url, $id, $callback) {
  * 初始化代码高亮
  */
 function initHighlighting() {
-    $('pre code,pre.ql-syntax').each(function (i, block) {
+    $('pre,pre.ql-syntax').each(function (i, block) {
         hljs.highlightBlock(block);
     });
-
     hljs.initLineNumbersOnLoad();
+
 }
 
 

+ 0 - 3
views/document/default_read.tpl

@@ -21,13 +21,10 @@
     <link href="{{cdncss "/static/nprogress/nprogress.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/css/kancloud.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/css/jstree.css"}}" rel="stylesheet">
-    {{if eq .Model.Editor "markdown"}}
     <link href="{{cdncss "/static/editor.md/css/editormd.preview.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/prettify/themes/prettify.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/css/markdown.preview.css"}}" rel="stylesheet">
-    {{else}}
     <link href="{{cdncss "/static/highlight/styles/vs.css"}}" rel="stylesheet">
-    {{end}}
     <link href="{{cdncss "/static/katex/katex.min.css"}}" rel="stylesheet">
     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->