12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 'use strict'
- // A line containing no characters, or a line containing only spaces (U+0020) or
- // tabs (U+0009), is called a blank line.
- // See <https://spec.commonmark.org/0.29/#blank-line>.
- var reBlankLine = /^[ \t]*(\n|$)/
- // Note that though blank lines play a special role in lists to determine
- // whether the list is tight or loose
- // (<https://spec.commonmark.org/0.29/#blank-lines>), it’s done by the list
- // tokenizer and this blank line tokenizer does not have to be responsible for
- // that.
- // Therefore, configs such as `blankLine.notInList` do not have to be set here.
- module.exports = blankLine
- function blankLine(eat, value, silent) {
- var match
- var subvalue = ''
- var index = 0
- var length = value.length
- while (index < length) {
- match = reBlankLine.exec(value.slice(index))
- if (match == null) {
- break
- }
- index += match[0].length
- subvalue += match[0]
- }
- if (subvalue === '') {
- return
- }
- /* istanbul ignore if - never used (yet) */
- if (silent) {
- return true
- }
- eat(subvalue)
- }
|