Skip to content

Commit

Permalink
fix: the mobile phone displays abnormally and Markdown does not allow…
Browse files Browse the repository at this point in the history
… conversion
  • Loading branch information
zhangsheng.93 committed Nov 20, 2023
1 parent b5f52c5 commit 346c942
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion conf/lang/en-us.ini
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ project_label_desc = Allows up to 10 labels, use ";" to separate multiple tags
cannot_change_own_status = Cannot change own status
cannot_change_super_status = Cannot change super administrator status
cannot_change_super_priv = Cannot change super administrator permissions
editors_not_compatible = two editors are not compatible

[blog]
author = Author
Expand Down Expand Up @@ -571,4 +572,4 @@ create_time = Create Time
creator = Creator
doc_amount = Number of Document
last_edit = Last Edit
delete_project = Delete Project
delete_project = Delete Project
1 change: 1 addition & 0 deletions conf/lang/zh-cn.ini
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ project_label_desc = 最多允许添加10个标签,多个标签请用“;”
cannot_change_own_status = 不能变更自己的状态
cannot_change_super_status = 不能变更超级管理员的状态
cannot_change_super_priv = 不能变更超级管理员的权限
editors_not_compatible = 两种编辑器不兼容

[blog]
author = 作者
Expand Down
3 changes: 3 additions & 0 deletions controllers/BookController.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func (c *BookController) SaveBook() {
book.CommentStatus = commentStatus
book.Publisher = publisher
//book.Label = tag
if book.Editor == EditorMarkdown && editor == EditorCherryMarkdown || book.Editor == EditorCherryMarkdown && editor == EditorMarkdown {
c.JsonResult(6006, i18n.Tr(c.Lang, "message.editors_not_compatible"))
}
book.Editor = editor
if editor == EditorCherryMarkdown {
book.Theme = "cherry"
Expand Down
15 changes: 11 additions & 4 deletions static/css/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,13 @@ iframe.cherry-dialog-iframe {
margin-right: 50px;
}

.markdown-article-body {
margin-right: 200px !important;
@media screen and (min-width: 840px) {
.markdown-article {
margin-right: 200px !important;
}
}

.markdown-article-head {
margin-right: 200px !important;
width: unset !important;
padding: unset !important;
padding-top: 10px !important;
Expand All @@ -562,4 +563,10 @@ iframe.cherry-dialog-iframe {
.markdown-title {
padding: unset !important;
width: 100% !important;
}
}

@media screen and (max-width: 839px) {
.toc {
display: none !important;
}
}
6 changes: 4 additions & 2 deletions utils/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func StripTags(s string) string {
return src
}

//自动提取文章摘要
// 自动提取文章摘要
func AutoSummary(body string, l int) string {

//匹配图片,如果图片语法是在代码块中,这里同样会处理
Expand All @@ -60,7 +60,7 @@ func AutoSummary(body string, l int) string {
return content
}

//安全处理HTML文档,过滤危险标签和属性.
// 安全处理HTML文档,过滤危险标签和属性.
func SafetyProcessor(html string) string {

//安全过滤,移除危险标签和属性
Expand Down Expand Up @@ -117,6 +117,8 @@ func SafetyProcessor(html string) string {
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 {
if selector := docQuery.Find("div.markdown-toc").First(); selector.Size() > 0 {
docQuery.Find("div.markdown-toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
} else if selector := docQuery.Find("dir.toc").First(); selector.Size() > 0 {
docQuery.Find("dir.toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
}
}

Expand Down

0 comments on commit 346c942

Please sign in to comment.