Skip to content

Commit

Permalink
support more markdown syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
DesertsP committed Feb 25, 2019
1 parent 4d794c7 commit 5829c8a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion dist/Valine.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/Valine.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"css-loader": "^0.28.4",
"exports-loader": "^0.6.4",
"file-loader": "^0.11.2",
"marked": "^0.3.19",
"node-sass": "^4.5.3",
"postcss-loader": "^2.0.6",
"sass-loader": "^6.0.6",
Expand All @@ -52,6 +51,7 @@
"dependencies": {
"babel": "^6.23.0",
"blueimp-md5": "^2.8.0",
"markdown-it": "^8.4.2",
"source-map": "^0.5.6"
}
}
33 changes: 14 additions & 19 deletions src/Valine.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('./Valine.scss');
import marked from 'marked';
var md = require('markdown-it')();

var crypto = require('blueimp-md5');

Expand Down Expand Up @@ -389,7 +389,7 @@ class Valine {
}
}
defaultComment['rid'] = '';
defaultComment['nick'] = '小可爱';
defaultComment['nick'] = '访客';
getCache();
}

Expand All @@ -409,11 +409,12 @@ class Valine {
return;
}
if (defaultComment.nick == '') {
defaultComment['nick'] = '小调皮';
defaultComment['nick'] = '访客';
}
// replace smiles
defaultComment.comment = defaultComment.comment.replace(/!\(:(.*?\.\w+):\)/g, `![](${option.emoticon_url}/$1)`);
defaultComment.comment = marked(defaultComment.comment);
// render markdown
defaultComment.comment = md.render(HtmlUtil.decode(defaultComment.comment));
let idx = defaultComment.comment.indexOf(defaultComment.at);
if (idx > -1 && defaultComment.at != '') {
let at = `<a class="at" href='#${defaultComment.rid}'>${defaultComment.at}</a>`;
Expand All @@ -426,27 +427,21 @@ class Valine {
defaultComment['link'] = linkRet.k ? linkRet.v : '';
if (!mailRet.k && !linkRet.k) {
_root.alert.show({
type: 1,
text: '您的网址和邮箱格式不正确, 将导致无法正确显示头像和接收回复通知邮件。是否继续提交?',
cb() {
commitEvt()
}
type: 0,
text: '您的网址和邮箱格式不正确,请修正后提交!',
ctxt: '返回修改'
})
} else if (!mailRet.k) {
_root.alert.show({
type: 1,
text: '您的邮箱格式不正确, 将导致无法正确显示头像和接收回复通知邮件。是否继续提交?',
cb() {
commitEvt();
}
type: 0,
text: '请认真评论并填写正确的邮箱地址!<br>已开启<a href="https://deserts.io/diy-a-comment-system/" target="_blank">隐私防护</a>不会泄露您的个人信息,<a href="https://akismet.com/privacy/" target="_blank">了解反垃圾系统如何处理您的数据。</a>',
ctxt: '返回修改'
})
} else if (!linkRet.k) {
_root.alert.show({
type: 1,
text: '您的网址格式不正确, 是否继续提交?',
cb() {
commitEvt();
}
type: 0,
text: '您的网址格式不正确,请修正后提交!',
ctxt: '返回修改'
})
} else {
commitEvt();
Expand Down
16 changes: 9 additions & 7 deletions src/Valine.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
line-height: 1.42857143;
color: #3c484e;
transition: all .3s ease;
margin: 0;
padding: 0;
}
.vwrap {
overflow: hidden;
Expand Down Expand Up @@ -181,7 +179,7 @@
left: 0;
top: 0;
.valert {
padding: 3em 0 0 0;
padding: 2em 0 0 0;
.vtext {
color: #fff;
padding: 15px;
Expand Down Expand Up @@ -235,10 +233,6 @@
// color: #3eb0ef;
}
}
ul,
li {
list-style: none;
}
.txt-center {
text-align: center;
}
Expand Down Expand Up @@ -294,6 +288,9 @@
// border-top: 1px solid #dedede;
// border-bottom: 1px solid #dedede;
width: 100%;
list-style: none;
margin: 0;
padding: 0;
.vcard {
display: flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -372,6 +369,11 @@

.vcomment {
position: relative;
blockquote {
p {
padding-left: 12px;
}
}
p {
word-wrap: break-word;
white-space: pre-wrap;
Expand Down

0 comments on commit 5829c8a

Please sign in to comment.