From 3a1337c0bdcc5ed63cb7a3eac93dea6e536b0eda Mon Sep 17 00:00:00 2001 From: Minho Date: Mon, 26 Mar 2018 13:32:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E5=85=A5=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/BookModel.go | 13 ++++++++----- static/css/markdown.preview.css | 5 ++++- static/js/kancloud.js | 4 ++-- views/document/default_read.tpl | 3 --- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/models/BookModel.go b/models/BookModel.go index fe8ca873..5e4bf8d9 100644 --- a/models/BookModel.go +++ b/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() diff --git a/static/css/markdown.preview.css b/static/css/markdown.preview.css index 37305702..9fdfff58 100644 --- a/static/css/markdown.preview.css +++ b/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; } diff --git a/static/js/kancloud.js b/static/js/kancloud.js index 54e7e160..520d90c2 100644 --- a/static/js/kancloud.js +++ b/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(); + } diff --git a/views/document/default_read.tpl b/views/document/default_read.tpl index a2cadc59..6f397143 100644 --- a/views/document/default_read.tpl +++ b/views/document/default_read.tpl @@ -21,13 +21,10 @@ - {{if eq .Model.Editor "markdown"}} - {{else}} - {{end}}