优化基础样式;markdown编译器增加对任务列表,提醒文本的支持
parent
7c90a9ca62
commit
10f3dedd09
File diff suppressed because one or more lines are too long
|
@ -108,7 +108,7 @@ $cgr: #34495e #5d6d7e #2c3e50;
|
||||||
|
|
||||||
/* 单选和复选框 */
|
/* 单选和复选框 */
|
||||||
.do-ui-radio,
|
.do-ui-radio,
|
||||||
.do-ui-checkbox {display:inline-block;position:relative;width:auto;height:auto;min-height:30px;padding-left:35px;line-height:30px;border-radius:3px;text-align:center;color:nth($cgr, 1);
|
.do-ui-checkbox {display:inline-block;position:relative;width:auto;height:auto;min-height:30px;padding-left:35px;line-height:30px;border-radius:3px;color:nth($cgr, 1);
|
||||||
}
|
}
|
||||||
.do-ui-radio {padding-left:50px;
|
.do-ui-radio {padding-left:50px;
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ $cgr: #34495e #5d6d7e #2c3e50;
|
||||||
&.disabled {color:nth($cp, 3);}
|
&.disabled {color:nth($cp, 3);}
|
||||||
}
|
}
|
||||||
.do-ui-checkbox {
|
.do-ui-checkbox {
|
||||||
&.with-style {padding-left:5px;padding-right:35px;line-height:26px;border:2px solid nth($cp, 1);background:nth($cp, 1);
|
&.with-style {padding-left:5px;padding-right:35px;line-height:26px;border:2px solid nth($cp, 1);background:nth($cp, 1);text-align:center;
|
||||||
|
|
||||||
>input {left:auto;right:0;top:0;line-height:26px;border:0;background:#fff;color:nth($cgr, 2);
|
>input {left:auto;right:0;top:0;line-height:26px;border:0;background:#fff;color:nth($cgr, 2);
|
||||||
&:disabled {color:nth($cp, 3)!important;}
|
&:disabled {color:nth($cp, 3)!important;}
|
||||||
|
@ -177,11 +177,11 @@ $cgr: #34495e #5d6d7e #2c3e50;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 提醒文本 */
|
/* 提醒文本 */
|
||||||
.do-ui-warn,.do-ui-notice {position:relative;min-height:50px;margin:10px 0;padding:8px 8px 8px 50px;border:1px solid nth($co, 1);border-radius:10px;background:#fffbed;color:nth($co, 3);
|
.do-ui-warn,.do-ui-mark {display:inline-block;position:relative;min-height:50px;margin:10px 0;padding:8px 8px 8px 50px;border:1px solid nth($co, 1);border-radius:10px;background:#fffbed;color:nth($co, 3);
|
||||||
|
|
||||||
&::before {position:absolute;left:8px;top:0;font:30px/1.5 "ui font";color:nth($cr, 1);content:"\e6f6";}
|
&::before {position:absolute;left:8px;top:0;font:30px/1.5 "ui font";color:nth($cr, 1);content:"\e6f6";}
|
||||||
}
|
}
|
||||||
.do-ui-notice {border-color:nth($cg, 2);color:nth($cg, 3);background:#edfbf8;
|
.do-ui-mark {border-color:nth($cg, 2);color:nth($cg, 3);background:#edfbf8;
|
||||||
|
|
||||||
&::before {color:nth($cg, 3);content:"\e657";}
|
&::before {color:nth($cg, 3);content:"\e657";}
|
||||||
}
|
}
|
|
@ -19,6 +19,8 @@ var block = {
|
||||||
nptable: noop,
|
nptable: noop,
|
||||||
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
||||||
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
||||||
|
mark: /^( *;;;([\!]?)[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
||||||
|
task: /^ *- *\[([ x]?)\] *([^\n]*)/,
|
||||||
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
||||||
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
||||||
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
||||||
|
@ -42,6 +44,9 @@ block.list = replace(block.list)
|
||||||
block.blockquote = replace(block.blockquote)
|
block.blockquote = replace(block.blockquote)
|
||||||
('def', block.def)
|
('def', block.def)
|
||||||
();
|
();
|
||||||
|
block.mark = replace(block.mark)
|
||||||
|
('def', block.def)
|
||||||
|
();
|
||||||
|
|
||||||
block._tag = '(?!(?:'
|
block._tag = '(?!(?:'
|
||||||
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
||||||
|
@ -279,6 +284,38 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mark
|
||||||
|
if (cap = this.rules.mark.exec(src)) {
|
||||||
|
src = src.substring(cap[0].length);
|
||||||
|
|
||||||
|
this.tokens.push({
|
||||||
|
type: 'mark_start'
|
||||||
|
});
|
||||||
|
var sign = cap[2] === '!'
|
||||||
|
cap = cap[0].replace(/^ *;;;[\!]? ?/gm, '');
|
||||||
|
|
||||||
|
this.token(cap, top, true);
|
||||||
|
|
||||||
|
this.tokens.push({
|
||||||
|
type: 'mark_end',
|
||||||
|
mark: sign
|
||||||
|
});
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cap = this.rules.task.exec(src)) {
|
||||||
|
src = src.substring(cap[0].length);
|
||||||
|
|
||||||
|
this.tokens.push({
|
||||||
|
type: 'task',
|
||||||
|
mark: cap[1] === 'x',
|
||||||
|
text: cap[2]
|
||||||
|
});
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// list
|
// list
|
||||||
if (cap = this.rules.list.exec(src)) {
|
if (cap = this.rules.list.exec(src)) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
|
@ -799,15 +836,11 @@ Renderer.prototype.code = function(code, lang, escaped) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output += /*'<section><em class="linenum do-fn-noselect">'
|
output += '<code class="lang '
|
||||||
+ idx
|
|
||||||
+ '.</em>'
|
|
||||||
+ */'<code class="lang '
|
|
||||||
+ lang
|
+ lang
|
||||||
+ '">'
|
+ '">'
|
||||||
+ codes[idx - 1]
|
+ codes[idx - 1]
|
||||||
+ '\n</code>' //加\n为了避免空行时无法显示
|
+ '\n</code>' //加\n为了避免空行时无法显示
|
||||||
// + '</section>'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<pre :skip class="do-ui-blockcode">'
|
return '<pre :skip class="do-ui-blockcode">'
|
||||||
|
@ -818,6 +851,14 @@ Renderer.prototype.code = function(code, lang, escaped) {
|
||||||
Renderer.prototype.blockquote = function(quote) {
|
Renderer.prototype.blockquote = function(quote) {
|
||||||
return '<blockquote>\n' + quote + '</blockquote>\n';
|
return '<blockquote>\n' + quote + '</blockquote>\n';
|
||||||
};
|
};
|
||||||
|
Renderer.prototype.mark = function(mark, t) {
|
||||||
|
return '<mark class="' + (t ? 'do-ui-mark' : 'do-ui-warn') + '">\n' + mark + '</mark>\n';
|
||||||
|
};
|
||||||
|
|
||||||
|
Renderer.prototype.task = function(task, t) {
|
||||||
|
task = t ? ('<del>' + task + '</del>') : task
|
||||||
|
return '<section><label class="do-ui-checkbox"><input type="checkbox" ' + (t ? 'checked' : '') + ' disabled />' + task + '</label></section>\n';
|
||||||
|
};
|
||||||
|
|
||||||
Renderer.prototype.html = function(html) {
|
Renderer.prototype.html = function(html) {
|
||||||
return html;
|
return html;
|
||||||
|
@ -1078,6 +1119,18 @@ Parser.prototype.tok = function() {
|
||||||
|
|
||||||
return this.renderer.blockquote(body);
|
return this.renderer.blockquote(body);
|
||||||
}
|
}
|
||||||
|
case 'mark_start': {
|
||||||
|
var body = '';
|
||||||
|
|
||||||
|
while (this.next().type !== 'mark_end') {
|
||||||
|
body += this.tok();
|
||||||
|
}
|
||||||
|
return this.renderer.mark(body, this.token.mark);
|
||||||
|
}
|
||||||
|
case 'task': {
|
||||||
|
log(this.token)
|
||||||
|
return this.renderer.task(this.token.text, this.token.mark)
|
||||||
|
}
|
||||||
case 'list_start': {
|
case 'list_start': {
|
||||||
var body = ''
|
var body = ''
|
||||||
, ordered = this.token.ordered;
|
, ordered = this.token.ordered;
|
||||||
|
|
Reference in New Issue