Files
react-native-devtools-frontend/node_modules/remark-parse/lib/tokenize/paragraph.js
T
Mathias Bynens 79e2cf0633 Add stylelint dependency
This also adds CC-BY-4.0 to the list of accepted licenses.

DISABLE_THIRD_PARTY_CHECK=update dependencies

Bug: chromium:1083142
Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
2020-06-11 06:20:04 +00:00

99 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict'
var trim = require('trim')
var trimTrailingLines = require('trim-trailing-lines')
var interrupt = require('../util/interrupt')
module.exports = paragraph
var tab = '\t'
var lineFeed = '\n'
var space = ' '
var tabSize = 4
// Tokenise paragraph.
function paragraph(eat, value, silent) {
var self = this
var settings = self.options
var commonmark = settings.commonmark
var tokenizers = self.blockTokenizers
var interruptors = self.interruptParagraph
var index = value.indexOf(lineFeed)
var length = value.length
var position
var subvalue
var character
var size
var now
while (index < length) {
// Eat everything if there’s no following newline.
if (index === -1) {
index = length
break
}
// Stop if the next character is NEWLINE.
if (value.charAt(index + 1) === lineFeed) {
break
}
// In commonmark-mode, following indented lines are part of the paragraph.
if (commonmark) {
size = 0
position = index + 1
while (position < length) {
character = value.charAt(position)
if (character === tab) {
size = tabSize
break
} else if (character === space) {
size++
} else {
break
}
position++
}
if (size >= tabSize && character !== lineFeed) {
index = value.indexOf(lineFeed, index + 1)
continue
}
}
subvalue = value.slice(index + 1)
// Check if the following code contains a possible block.
if (interrupt(interruptors, tokenizers, self, [eat, subvalue, true])) {
break
}
position = index
index = value.indexOf(lineFeed, index + 1)
if (index !== -1 && trim(value.slice(position, index)) === '') {
index = position
break
}
}
subvalue = value.slice(0, index)
/* istanbul ignore if - never used (yet) */
if (silent) {
return true
}
now = eat.now()
subvalue = trimTrailingLines(subvalue)
return eat(subvalue)({
type: 'paragraph',
children: self.tokenizeInline(subvalue, now)
})
}