|
@ -1,5 +1,8 @@ |
|
|
// Inline parser
|
|
|
/** internal |
|
|
|
|
|
* class ParserInline |
|
|
|
|
|
* |
|
|
|
|
|
* Tokenizes paragraph content. |
|
|
|
|
|
**/ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -44,13 +47,31 @@ function validateLink(url) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Inline Parser class
|
|
|
|
|
|
//
|
|
|
/** |
|
|
|
|
|
* new ParserInline() |
|
|
|
|
|
**/ |
|
|
function ParserInline() { |
|
|
function ParserInline() { |
|
|
// By default CommonMark allows too much in links
|
|
|
/** |
|
|
// If you need to restrict it - override this with your validator.
|
|
|
* ParserInline#validateLink(url) -> Boolean |
|
|
|
|
|
* |
|
|
|
|
|
* Link validation function. CommonMark allows too much in links. By default |
|
|
|
|
|
* we disable `javascript:` and `vbscript:` schemas. You can change this |
|
|
|
|
|
* behaviour. |
|
|
|
|
|
* |
|
|
|
|
|
* ```javascript
|
|
|
|
|
|
* var md = require('markdown-it')(); |
|
|
|
|
|
* // enable everything
|
|
|
|
|
|
* md.inline.validateLink = function () { return true; } |
|
|
|
|
|
* ``` |
|
|
|
|
|
**/ |
|
|
this.validateLink = validateLink; |
|
|
this.validateLink = validateLink; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* ParserInline#ruler -> Ruler |
|
|
|
|
|
* |
|
|
|
|
|
* [[Ruler]] instance. Keep configuration of inline rules. |
|
|
|
|
|
**/ |
|
|
this.ruler = new Ruler(); |
|
|
this.ruler = new Ruler(); |
|
|
|
|
|
|
|
|
for (var i = 0; i < _rules.length; i++) { |
|
|
for (var i = 0; i < _rules.length; i++) { |
|
@ -120,8 +141,11 @@ ParserInline.prototype.tokenize = function (state) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Parse input string.
|
|
|
/** |
|
|
//
|
|
|
* ParserInline.parse(str, options, env, outTokens) |
|
|
|
|
|
* |
|
|
|
|
|
* Process input string and push inline tokens into `outTokens` |
|
|
|
|
|
**/ |
|
|
ParserInline.prototype.parse = function (str, options, env, outTokens) { |
|
|
ParserInline.prototype.parse = function (str, options, env, outTokens) { |
|
|
var state = new StateInline(str, this, options, env, outTokens); |
|
|
var state = new StateInline(str, this, options, env, outTokens); |
|
|
|
|
|
|
|
|