优化导入后的显示

This commit is contained in:
Minho 2018-03-26 13:32:02 +08:00
parent ffe5dced44
commit 3a1337c0bd
4 changed files with 14 additions and 11 deletions

View File

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

View File

@ -56,9 +56,12 @@
border-radius:0; border-radius:0;
line-height: 1.4em; 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; padding: 0;
} }
.hljs{
padding: 10px 15px !important;
}
.editormd-preview-container ol.linenums, .editormd-html-preview ol.linenums{ .editormd-preview-container ol.linenums, .editormd-html-preview ol.linenums{
color: #999; color: #999;
} }

View File

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

View File

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