add gfm line breaks.
This commit is contained in:
parent
262f8797ff
commit
7aa7934c90
@ -68,6 +68,12 @@ var main = function(argv) {
|
||||
case '--gfm':
|
||||
options.gfm = true;
|
||||
break;
|
||||
case '--tables':
|
||||
options.tables = true;
|
||||
break;
|
||||
case '--breaks':
|
||||
options.breaks = true;
|
||||
break;
|
||||
case '--sanitize':
|
||||
options.sanitize = true;
|
||||
break;
|
||||
|
@ -436,6 +436,7 @@ inline.normal = {
|
||||
url: inline.url,
|
||||
strong: inline.strong,
|
||||
em: inline.em,
|
||||
br: inline.br,
|
||||
text: inline.text
|
||||
};
|
||||
|
||||
@ -449,6 +450,11 @@ inline.gfm = {
|
||||
text: /^[\s\S]+?(?=[\\<!\[_*`]|https?:\/\/| {2,}\n|$)/
|
||||
};
|
||||
|
||||
inline.gfm.breaks = {
|
||||
br: replace(inline.br)('{2,}', '*')(),
|
||||
text: replace(inline.gfm.text)('{2,}', '*')()
|
||||
};
|
||||
|
||||
/**
|
||||
* Inline Lexer & Compiler
|
||||
*/
|
||||
@ -465,6 +471,18 @@ function InlineLexer(links, options) {
|
||||
inline.url = inline.normal.url;
|
||||
}
|
||||
|
||||
if (this.options.gfm && this.options.breaks) {
|
||||
inline.br = inline.gfm.breaks.br;
|
||||
inline.text = inline.gfm.breaks.text;
|
||||
} else {
|
||||
inline.br = inline.normal.br;
|
||||
if (this.options.gfm) {
|
||||
inline.text = inline.gfm.text;
|
||||
} else {
|
||||
inline.text = inline.normal.text;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.pedantic) {
|
||||
inline.em = inline.pedantic.em;
|
||||
inline.strong = inline.pedantic.strong;
|
||||
@ -909,6 +927,7 @@ marked.setOptions = function(opt) {
|
||||
marked.defaults = {
|
||||
gfm: true,
|
||||
tables: true,
|
||||
breaks: false,
|
||||
pedantic: false,
|
||||
sanitize: false,
|
||||
silent: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user