This commit is contained in:
63
node_modules/remark-stringify/lib/compiler.js
generated
vendored
Normal file
63
node_modules/remark-stringify/lib/compiler.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict'
|
||||
|
||||
var xtend = require('xtend')
|
||||
var toggle = require('state-toggle')
|
||||
|
||||
module.exports = Compiler
|
||||
|
||||
// Construct a new compiler.
|
||||
function Compiler(tree, file) {
|
||||
this.inLink = false
|
||||
this.inTable = false
|
||||
this.tree = tree
|
||||
this.file = file
|
||||
this.options = xtend(this.options)
|
||||
this.setOptions({})
|
||||
}
|
||||
|
||||
var proto = Compiler.prototype
|
||||
|
||||
// Enter and exit helpers. */
|
||||
proto.enterLink = toggle('inLink', false)
|
||||
proto.enterTable = toggle('inTable', false)
|
||||
proto.enterLinkReference = require('./util/enter-link-reference')
|
||||
|
||||
// Configuration.
|
||||
proto.options = require('./defaults')
|
||||
proto.setOptions = require('./set-options')
|
||||
|
||||
proto.compile = require('./macro/compile')
|
||||
proto.visit = require('./macro/one')
|
||||
proto.all = require('./macro/all')
|
||||
proto.block = require('./macro/block')
|
||||
proto.visitOrderedItems = require('./macro/ordered-items')
|
||||
proto.visitUnorderedItems = require('./macro/unordered-items')
|
||||
|
||||
// Expose visitors.
|
||||
proto.visitors = {
|
||||
root: require('./visitors/root'),
|
||||
text: require('./visitors/text'),
|
||||
heading: require('./visitors/heading'),
|
||||
paragraph: require('./visitors/paragraph'),
|
||||
blockquote: require('./visitors/blockquote'),
|
||||
list: require('./visitors/list'),
|
||||
listItem: require('./visitors/list-item'),
|
||||
inlineCode: require('./visitors/inline-code'),
|
||||
code: require('./visitors/code'),
|
||||
html: require('./visitors/html'),
|
||||
thematicBreak: require('./visitors/thematic-break'),
|
||||
strong: require('./visitors/strong'),
|
||||
emphasis: require('./visitors/emphasis'),
|
||||
break: require('./visitors/break'),
|
||||
delete: require('./visitors/delete'),
|
||||
link: require('./visitors/link'),
|
||||
linkReference: require('./visitors/link-reference'),
|
||||
imageReference: require('./visitors/image-reference'),
|
||||
definition: require('./visitors/definition'),
|
||||
image: require('./visitors/image'),
|
||||
footnote: require('./visitors/footnote'),
|
||||
footnoteReference: require('./visitors/footnote-reference'),
|
||||
footnoteDefinition: require('./visitors/footnote-definition'),
|
||||
table: require('./visitors/table'),
|
||||
tableCell: require('./visitors/table-cell')
|
||||
}
|
||||
28
node_modules/remark-stringify/lib/defaults.js
generated
vendored
Normal file
28
node_modules/remark-stringify/lib/defaults.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
gfm: true,
|
||||
commonmark: false,
|
||||
pedantic: false,
|
||||
entities: 'false',
|
||||
setext: false,
|
||||
closeAtx: false,
|
||||
looseTable: false,
|
||||
spacedTable: true,
|
||||
paddedTable: true,
|
||||
stringLength: stringLength,
|
||||
incrementListMarker: true,
|
||||
fences: false,
|
||||
fence: '`',
|
||||
bullet: '-',
|
||||
listItemIndent: 'tab',
|
||||
rule: '*',
|
||||
ruleSpaces: true,
|
||||
ruleRepetition: 3,
|
||||
strong: '*',
|
||||
emphasis: '_'
|
||||
}
|
||||
|
||||
function stringLength(value) {
|
||||
return value.length
|
||||
}
|
||||
299
node_modules/remark-stringify/lib/escape.js
generated
vendored
Normal file
299
node_modules/remark-stringify/lib/escape.js
generated
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
'use strict'
|
||||
|
||||
var decimal = require('is-decimal')
|
||||
var alphanumeric = require('is-alphanumeric')
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var escapes = require('markdown-escapes')
|
||||
var prefix = require('./util/entity-prefix-length')
|
||||
|
||||
module.exports = factory
|
||||
|
||||
var tab = '\t'
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var numberSign = '#'
|
||||
var ampersand = '&'
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
var asterisk = '*'
|
||||
var plusSign = '+'
|
||||
var dash = '-'
|
||||
var dot = '.'
|
||||
var colon = ':'
|
||||
var lessThan = '<'
|
||||
var greaterThan = '>'
|
||||
var leftSquareBracket = '['
|
||||
var backslash = '\\'
|
||||
var rightSquareBracket = ']'
|
||||
var underscore = '_'
|
||||
var graveAccent = '`'
|
||||
var verticalBar = '|'
|
||||
var tilde = '~'
|
||||
var exclamationMark = '!'
|
||||
|
||||
var entities = {
|
||||
'<': '<',
|
||||
':': ':',
|
||||
'&': '&',
|
||||
'|': '|',
|
||||
'~': '~'
|
||||
}
|
||||
|
||||
var shortcut = 'shortcut'
|
||||
var mailto = 'mailto'
|
||||
var https = 'https'
|
||||
var http = 'http'
|
||||
|
||||
var blankExpression = /\n\s*$/
|
||||
|
||||
// Factory to escape characters.
|
||||
function factory(options) {
|
||||
return escape
|
||||
|
||||
// Escape punctuation characters in a node’s value.
|
||||
function escape(value, node, parent) {
|
||||
var self = this
|
||||
var gfm = options.gfm
|
||||
var commonmark = options.commonmark
|
||||
var pedantic = options.pedantic
|
||||
var markers = commonmark ? [dot, rightParenthesis] : [dot]
|
||||
var siblings = parent && parent.children
|
||||
var index = siblings && siblings.indexOf(node)
|
||||
var prev = siblings && siblings[index - 1]
|
||||
var next = siblings && siblings[index + 1]
|
||||
var length = value.length
|
||||
var escapable = escapes(options)
|
||||
var position = -1
|
||||
var queue = []
|
||||
var escaped = queue
|
||||
var afterNewLine
|
||||
var character
|
||||
var wordCharBefore
|
||||
var wordCharAfter
|
||||
var offset
|
||||
var replace
|
||||
|
||||
if (prev) {
|
||||
afterNewLine = text(prev) && blankExpression.test(prev.value)
|
||||
} else {
|
||||
afterNewLine =
|
||||
!parent || parent.type === 'root' || parent.type === 'paragraph'
|
||||
}
|
||||
|
||||
while (++position < length) {
|
||||
character = value.charAt(position)
|
||||
replace = false
|
||||
|
||||
if (character === '\n') {
|
||||
afterNewLine = true
|
||||
} else if (
|
||||
character === backslash ||
|
||||
character === graveAccent ||
|
||||
character === asterisk ||
|
||||
(character === exclamationMark &&
|
||||
value.charAt(position + 1) === leftSquareBracket) ||
|
||||
character === leftSquareBracket ||
|
||||
character === lessThan ||
|
||||
(character === ampersand && prefix(value.slice(position)) > 0) ||
|
||||
(character === rightSquareBracket && self.inLink) ||
|
||||
(gfm && character === tilde && value.charAt(position + 1) === tilde) ||
|
||||
(gfm &&
|
||||
character === verticalBar &&
|
||||
(self.inTable || alignment(value, position))) ||
|
||||
(character === underscore &&
|
||||
// Delegate leading/trailing underscores to the multinode version below.
|
||||
position > 0 &&
|
||||
position < length - 1 &&
|
||||
(pedantic ||
|
||||
!alphanumeric(value.charAt(position - 1)) ||
|
||||
!alphanumeric(value.charAt(position + 1)))) ||
|
||||
(gfm && !self.inLink && character === colon && protocol(queue.join('')))
|
||||
) {
|
||||
replace = true
|
||||
} else if (afterNewLine) {
|
||||
if (
|
||||
character === greaterThan ||
|
||||
character === numberSign ||
|
||||
character === asterisk ||
|
||||
character === dash ||
|
||||
character === plusSign
|
||||
) {
|
||||
replace = true
|
||||
} else if (decimal(character)) {
|
||||
offset = position + 1
|
||||
|
||||
while (offset < length) {
|
||||
if (!decimal(value.charAt(offset))) {
|
||||
break
|
||||
}
|
||||
|
||||
offset++
|
||||
}
|
||||
|
||||
if (markers.indexOf(value.charAt(offset)) !== -1) {
|
||||
next = value.charAt(offset + 1)
|
||||
|
||||
if (!next || next === space || next === tab || next === lineFeed) {
|
||||
queue.push(value.slice(position, offset))
|
||||
position = offset
|
||||
character = value.charAt(position)
|
||||
replace = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (afterNewLine && !whitespace(character)) {
|
||||
afterNewLine = false
|
||||
}
|
||||
|
||||
queue.push(replace ? one(character) : character)
|
||||
}
|
||||
|
||||
// Multi-node versions.
|
||||
if (siblings && text(node)) {
|
||||
// Check for an opening parentheses after a link-reference (which can be
|
||||
// joined by white-space).
|
||||
if (prev && prev.referenceType === shortcut) {
|
||||
position = -1
|
||||
length = escaped.length
|
||||
|
||||
while (++position < length) {
|
||||
character = escaped[position]
|
||||
|
||||
if (character === space || character === tab) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (character === leftParenthesis || character === colon) {
|
||||
escaped[position] = one(character)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
// If the current node is all spaces / tabs, preceded by a shortcut,
|
||||
// and followed by a text starting with `(`, escape it.
|
||||
if (
|
||||
text(next) &&
|
||||
position === length &&
|
||||
next.value.charAt(0) === leftParenthesis
|
||||
) {
|
||||
escaped.push(backslash)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure non-auto-links are not seen as links. This pattern needs to
|
||||
// check the preceding nodes too.
|
||||
if (
|
||||
gfm &&
|
||||
!self.inLink &&
|
||||
text(prev) &&
|
||||
value.charAt(0) === colon &&
|
||||
protocol(prev.value.slice(-6))
|
||||
) {
|
||||
escaped[0] = one(colon)
|
||||
}
|
||||
|
||||
// Escape ampersand if it would otherwise start an entity.
|
||||
if (
|
||||
text(next) &&
|
||||
value.charAt(length - 1) === ampersand &&
|
||||
prefix(ampersand + next.value) !== 0
|
||||
) {
|
||||
escaped[escaped.length - 1] = one(ampersand)
|
||||
}
|
||||
|
||||
// Escape exclamation marks immediately followed by links.
|
||||
if (
|
||||
next &&
|
||||
next.type === 'link' &&
|
||||
value.charAt(length - 1) === exclamationMark
|
||||
) {
|
||||
escaped[escaped.length - 1] = one(exclamationMark)
|
||||
}
|
||||
|
||||
// Escape double tildes in GFM.
|
||||
if (
|
||||
gfm &&
|
||||
text(next) &&
|
||||
value.charAt(length - 1) === tilde &&
|
||||
next.value.charAt(0) === tilde
|
||||
) {
|
||||
escaped.splice(escaped.length - 1, 0, backslash)
|
||||
}
|
||||
|
||||
// Escape underscores, but not mid-word (unless in pedantic mode).
|
||||
wordCharBefore = text(prev) && alphanumeric(prev.value.slice(-1))
|
||||
wordCharAfter = text(next) && alphanumeric(next.value.charAt(0))
|
||||
|
||||
if (length === 1) {
|
||||
if (
|
||||
value === underscore &&
|
||||
(pedantic || !wordCharBefore || !wordCharAfter)
|
||||
) {
|
||||
escaped.unshift(backslash)
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
value.charAt(0) === underscore &&
|
||||
(pedantic || !wordCharBefore || !alphanumeric(value.charAt(1)))
|
||||
) {
|
||||
escaped.unshift(backslash)
|
||||
}
|
||||
|
||||
if (
|
||||
value.charAt(length - 1) === underscore &&
|
||||
(pedantic ||
|
||||
!wordCharAfter ||
|
||||
!alphanumeric(value.charAt(length - 2)))
|
||||
) {
|
||||
escaped.splice(escaped.length - 1, 0, backslash)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return escaped.join('')
|
||||
|
||||
function one(character) {
|
||||
return escapable.indexOf(character) === -1
|
||||
? entities[character]
|
||||
: backslash + character
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if `index` in `value` is inside an alignment row.
|
||||
function alignment(value, index) {
|
||||
var start = value.lastIndexOf(lineFeed, index)
|
||||
var end = value.indexOf(lineFeed, index)
|
||||
var char
|
||||
|
||||
end = end === -1 ? value.length : end
|
||||
|
||||
while (++start < end) {
|
||||
char = value.charAt(start)
|
||||
|
||||
if (
|
||||
char !== colon &&
|
||||
char !== dash &&
|
||||
char !== space &&
|
||||
char !== verticalBar
|
||||
) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Check if `node` is a text node.
|
||||
function text(node) {
|
||||
return node && node.type === 'text'
|
||||
}
|
||||
|
||||
// Check if `value` ends in a protocol.
|
||||
function protocol(value) {
|
||||
var val = value.slice(-6).toLowerCase()
|
||||
return val === mailto || val.slice(-5) === https || val.slice(-4) === http
|
||||
}
|
||||
18
node_modules/remark-stringify/lib/macro/all.js
generated
vendored
Normal file
18
node_modules/remark-stringify/lib/macro/all.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = all
|
||||
|
||||
// Visit all children of `parent`.
|
||||
function all(parent) {
|
||||
var self = this
|
||||
var children = parent.children
|
||||
var length = children.length
|
||||
var results = []
|
||||
var index = -1
|
||||
|
||||
while (++index < length) {
|
||||
results[index] = self.visit(children[index], parent)
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
54
node_modules/remark-stringify/lib/macro/block.js
generated
vendored
Normal file
54
node_modules/remark-stringify/lib/macro/block.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = block
|
||||
|
||||
var lineFeed = '\n'
|
||||
|
||||
var blank = lineFeed + lineFeed
|
||||
var triple = blank + lineFeed
|
||||
var comment = blank + '<!---->' + blank
|
||||
|
||||
// Stringify a block node with block children (e.g., `root` or `blockquote`).
|
||||
// Knows about code following a list, or adjacent lists with similar bullets,
|
||||
// and places an extra line feed between them.
|
||||
function block(node) {
|
||||
var self = this
|
||||
var options = self.options
|
||||
var fences = options.fences
|
||||
var gap = options.commonmark ? comment : triple
|
||||
var values = []
|
||||
var children = node.children
|
||||
var length = children.length
|
||||
var index = -1
|
||||
var prev
|
||||
var child
|
||||
|
||||
while (++index < length) {
|
||||
prev = child
|
||||
child = children[index]
|
||||
|
||||
if (prev) {
|
||||
// A list preceding another list that are equally ordered, or a
|
||||
// list preceding an indented code block, need a gap between them,
|
||||
// so as not to see them as one list, or content of the list,
|
||||
// respectively.
|
||||
//
|
||||
// In commonmark, only something that breaks both up can do that,
|
||||
// so we opt for an empty, invisible comment. In other flavours,
|
||||
// two blank lines are fine.
|
||||
if (
|
||||
prev.type === 'list' &&
|
||||
((child.type === 'list' && prev.ordered === child.ordered) ||
|
||||
(child.type === 'code' && (!child.lang && !fences)))
|
||||
) {
|
||||
values.push(gap)
|
||||
} else {
|
||||
values.push(blank)
|
||||
}
|
||||
}
|
||||
|
||||
values.push(self.visit(child, node))
|
||||
}
|
||||
|
||||
return values.join('')
|
||||
}
|
||||
10
node_modules/remark-stringify/lib/macro/compile.js
generated
vendored
Normal file
10
node_modules/remark-stringify/lib/macro/compile.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
var compact = require('mdast-util-compact')
|
||||
|
||||
module.exports = compile
|
||||
|
||||
// Stringify the given tree.
|
||||
function compile() {
|
||||
return this.visit(compact(this.tree, this.options.commonmark))
|
||||
}
|
||||
20
node_modules/remark-stringify/lib/macro/one.js
generated
vendored
Normal file
20
node_modules/remark-stringify/lib/macro/one.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = one
|
||||
|
||||
function one(node, parent) {
|
||||
var self = this
|
||||
var visitors = self.visitors
|
||||
|
||||
// Fail on unknown nodes.
|
||||
if (typeof visitors[node.type] !== 'function') {
|
||||
self.file.fail(
|
||||
new Error(
|
||||
'Missing compiler for node of type `' + node.type + '`: `' + node + '`'
|
||||
),
|
||||
node
|
||||
)
|
||||
}
|
||||
|
||||
return visitors[node.type].call(self, node, parent)
|
||||
}
|
||||
43
node_modules/remark-stringify/lib/macro/ordered-items.js
generated
vendored
Normal file
43
node_modules/remark-stringify/lib/macro/ordered-items.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = orderedItems
|
||||
|
||||
var lineFeed = '\n'
|
||||
var dot = '.'
|
||||
|
||||
var blank = lineFeed + lineFeed
|
||||
|
||||
// Visit ordered list items.
|
||||
//
|
||||
// Starts the list with
|
||||
// `node.start` and increments each following list item
|
||||
// bullet by one:
|
||||
//
|
||||
// 2. foo
|
||||
// 3. bar
|
||||
//
|
||||
// In `incrementListMarker: false` mode, does not increment
|
||||
// each marker and stays on `node.start`:
|
||||
//
|
||||
// 1. foo
|
||||
// 1. bar
|
||||
function orderedItems(node) {
|
||||
var self = this
|
||||
var fn = self.visitors.listItem
|
||||
var increment = self.options.incrementListMarker
|
||||
var values = []
|
||||
var start = node.start
|
||||
var children = node.children
|
||||
var length = children.length
|
||||
var index = -1
|
||||
var bullet
|
||||
|
||||
start = start == null ? 1 : start
|
||||
|
||||
while (++index < length) {
|
||||
bullet = (increment ? start + index : start) + dot
|
||||
values[index] = fn.call(self, children[index], node, index, bullet)
|
||||
}
|
||||
|
||||
return values.join(node.spread ? blank : lineFeed)
|
||||
}
|
||||
24
node_modules/remark-stringify/lib/macro/unordered-items.js
generated
vendored
Normal file
24
node_modules/remark-stringify/lib/macro/unordered-items.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = unorderedItems
|
||||
|
||||
var lineFeed = '\n'
|
||||
|
||||
var blank = lineFeed + lineFeed
|
||||
|
||||
// Visit unordered list items. Uses `options.bullet` as each item’s bullet.
|
||||
function unorderedItems(node) {
|
||||
var self = this
|
||||
var bullet = self.options.bullet
|
||||
var fn = self.visitors.listItem
|
||||
var children = node.children
|
||||
var length = children.length
|
||||
var index = -1
|
||||
var values = []
|
||||
|
||||
while (++index < length) {
|
||||
values[index] = fn.call(self, children[index], node, index, bullet)
|
||||
}
|
||||
|
||||
return values.join(node.spread ? blank : lineFeed)
|
||||
}
|
||||
160
node_modules/remark-stringify/lib/set-options.js
generated
vendored
Normal file
160
node_modules/remark-stringify/lib/set-options.js
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
'use strict'
|
||||
|
||||
var xtend = require('xtend')
|
||||
var encode = require('stringify-entities')
|
||||
var defaults = require('./defaults')
|
||||
var escapeFactory = require('./escape')
|
||||
var identity = require('./util/identity')
|
||||
|
||||
module.exports = setOptions
|
||||
|
||||
// Map of applicable enums.
|
||||
var maps = {
|
||||
entities: {true: true, false: true, numbers: true, escape: true},
|
||||
bullet: {'*': true, '-': true, '+': true},
|
||||
rule: {'-': true, _: true, '*': true},
|
||||
listItemIndent: {tab: true, mixed: true, 1: true},
|
||||
emphasis: {_: true, '*': true},
|
||||
strong: {_: true, '*': true},
|
||||
fence: {'`': true, '~': true}
|
||||
}
|
||||
|
||||
// Expose `validate`.
|
||||
var validate = {
|
||||
boolean: validateBoolean,
|
||||
string: validateString,
|
||||
number: validateNumber,
|
||||
function: validateFunction
|
||||
}
|
||||
|
||||
// Set options. Does not overwrite previously set options.
|
||||
function setOptions(options) {
|
||||
var self = this
|
||||
var current = self.options
|
||||
var ruleRepetition
|
||||
var key
|
||||
|
||||
if (options == null) {
|
||||
options = {}
|
||||
} else if (typeof options === 'object') {
|
||||
options = xtend(options)
|
||||
} else {
|
||||
throw new Error('Invalid value `' + options + '` for setting `options`')
|
||||
}
|
||||
|
||||
for (key in defaults) {
|
||||
validate[typeof defaults[key]](options, key, current[key], maps[key])
|
||||
}
|
||||
|
||||
ruleRepetition = options.ruleRepetition
|
||||
|
||||
if (ruleRepetition && ruleRepetition < 3) {
|
||||
raise(ruleRepetition, 'options.ruleRepetition')
|
||||
}
|
||||
|
||||
self.encode = encodeFactory(String(options.entities))
|
||||
self.escape = escapeFactory(options)
|
||||
|
||||
self.options = options
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// Validate a value to be boolean. Defaults to `def`. Raises an exception with
|
||||
// `context[name]` when not a boolean.
|
||||
function validateBoolean(context, name, def) {
|
||||
var value = context[name]
|
||||
|
||||
if (value == null) {
|
||||
value = def
|
||||
}
|
||||
|
||||
if (typeof value !== 'boolean') {
|
||||
raise(value, 'options.' + name)
|
||||
}
|
||||
|
||||
context[name] = value
|
||||
}
|
||||
|
||||
// Validate a value to be boolean. Defaults to `def`. Raises an exception with
|
||||
// `context[name]` when not a boolean.
|
||||
function validateNumber(context, name, def) {
|
||||
var value = context[name]
|
||||
|
||||
if (value == null) {
|
||||
value = def
|
||||
}
|
||||
|
||||
if (isNaN(value)) {
|
||||
raise(value, 'options.' + name)
|
||||
}
|
||||
|
||||
context[name] = value
|
||||
}
|
||||
|
||||
// Validate a value to be in `map`. Defaults to `def`. Raises an exception
|
||||
// with `context[name]` when not in `map`.
|
||||
function validateString(context, name, def, map) {
|
||||
var value = context[name]
|
||||
|
||||
if (value == null) {
|
||||
value = def
|
||||
}
|
||||
|
||||
value = String(value)
|
||||
|
||||
if (!(value in map)) {
|
||||
raise(value, 'options.' + name)
|
||||
}
|
||||
|
||||
context[name] = value
|
||||
}
|
||||
|
||||
// Validate a value to be function. Defaults to `def`. Raises an exception
|
||||
// with `context[name]` when not a function.
|
||||
function validateFunction(context, name, def) {
|
||||
var value = context[name]
|
||||
|
||||
if (value == null) {
|
||||
value = def
|
||||
}
|
||||
|
||||
if (typeof value !== 'function') {
|
||||
raise(value, 'options.' + name)
|
||||
}
|
||||
|
||||
context[name] = value
|
||||
}
|
||||
|
||||
// Factory to encode HTML entities. Creates a no-operation function when
|
||||
// `type` is `'false'`, a function which encodes using named references when
|
||||
// `type` is `'true'`, and a function which encodes using numbered references
|
||||
// when `type` is `'numbers'`.
|
||||
function encodeFactory(type) {
|
||||
var options = {}
|
||||
|
||||
if (type === 'false') {
|
||||
return identity
|
||||
}
|
||||
|
||||
if (type === 'true') {
|
||||
options.useNamedReferences = true
|
||||
}
|
||||
|
||||
if (type === 'escape') {
|
||||
options.escapeOnly = true
|
||||
options.useNamedReferences = true
|
||||
}
|
||||
|
||||
return wrapped
|
||||
|
||||
// Encode HTML entities using the bound options.
|
||||
function wrapped(value) {
|
||||
return encode(value, options)
|
||||
}
|
||||
}
|
||||
|
||||
// Throw an exception with in its `message` `value` and `name`.
|
||||
function raise(value, name) {
|
||||
throw new Error('Invalid value `' + value + '` for setting `' + name + '`')
|
||||
}
|
||||
67
node_modules/remark-stringify/lib/util/copy-identifier-encoding.js
generated
vendored
Normal file
67
node_modules/remark-stringify/lib/util/copy-identifier-encoding.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict'
|
||||
|
||||
var entityPrefixLength = require('./entity-prefix-length')
|
||||
|
||||
module.exports = copy
|
||||
|
||||
var ampersand = '&'
|
||||
|
||||
var punctuationExppresion = /[-!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~_]/
|
||||
|
||||
// For shortcut and collapsed reference links, the contents is also an
|
||||
// identifier, so we need to restore the original encoding and escaping
|
||||
// that were present in the source string.
|
||||
//
|
||||
// This function takes the unescaped & unencoded value from shortcut’s
|
||||
// child nodes and the identifier and encodes the former according to
|
||||
// the latter.
|
||||
function copy(value, identifier) {
|
||||
var length = value.length
|
||||
var count = identifier.length
|
||||
var result = []
|
||||
var position = 0
|
||||
var index = 0
|
||||
var start
|
||||
|
||||
while (index < length) {
|
||||
// Take next non-punctuation characters from `value`.
|
||||
start = index
|
||||
|
||||
while (index < length && !punctuationExppresion.test(value.charAt(index))) {
|
||||
index += 1
|
||||
}
|
||||
|
||||
result.push(value.slice(start, index))
|
||||
|
||||
// Advance `position` to the next punctuation character.
|
||||
while (
|
||||
position < count &&
|
||||
!punctuationExppresion.test(identifier.charAt(position))
|
||||
) {
|
||||
position += 1
|
||||
}
|
||||
|
||||
// Take next punctuation characters from `identifier`.
|
||||
start = position
|
||||
|
||||
while (
|
||||
position < count &&
|
||||
punctuationExppresion.test(identifier.charAt(position))
|
||||
) {
|
||||
if (identifier.charAt(position) === ampersand) {
|
||||
position += entityPrefixLength(identifier.slice(position))
|
||||
}
|
||||
|
||||
position += 1
|
||||
}
|
||||
|
||||
result.push(identifier.slice(start, position))
|
||||
|
||||
// Advance `index` to the next non-punctuation character.
|
||||
while (index < length && punctuationExppresion.test(value.charAt(index))) {
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
|
||||
return result.join('')
|
||||
}
|
||||
17
node_modules/remark-stringify/lib/util/enclose-title.js
generated
vendored
Normal file
17
node_modules/remark-stringify/lib/util/enclose-title.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = enclose
|
||||
|
||||
var quotationMark = '"'
|
||||
var apostrophe = "'"
|
||||
|
||||
// There is currently no way to support nested delimiters across Markdown.pl,
|
||||
// CommonMark, and GitHub (RedCarpet). The following code supports Markdown.pl
|
||||
// and GitHub.
|
||||
// CommonMark is not supported when mixing double- and single quotes inside a
|
||||
// title.
|
||||
function enclose(title) {
|
||||
var delimiter =
|
||||
title.indexOf(quotationMark) === -1 ? quotationMark : apostrophe
|
||||
return delimiter + title + delimiter
|
||||
}
|
||||
33
node_modules/remark-stringify/lib/util/enclose-uri.js
generated
vendored
Normal file
33
node_modules/remark-stringify/lib/util/enclose-uri.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
var count = require('ccount')
|
||||
|
||||
module.exports = enclose
|
||||
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
var lessThan = '<'
|
||||
var greaterThan = '>'
|
||||
|
||||
var expression = /\s/
|
||||
|
||||
// Wrap `url` in angle brackets when needed, or when
|
||||
// forced.
|
||||
// In links, images, and definitions, the URL part needs
|
||||
// to be enclosed when it:
|
||||
//
|
||||
// - has a length of `0`
|
||||
// - contains white-space
|
||||
// - has more or less opening than closing parentheses
|
||||
function enclose(uri, always) {
|
||||
if (
|
||||
always ||
|
||||
uri.length === 0 ||
|
||||
expression.test(uri) ||
|
||||
count(uri, leftParenthesis) !== count(uri, rightParenthesis)
|
||||
) {
|
||||
return lessThan + uri + greaterThan
|
||||
}
|
||||
|
||||
return uri
|
||||
}
|
||||
33
node_modules/remark-stringify/lib/util/enter-link-reference.js
generated
vendored
Normal file
33
node_modules/remark-stringify/lib/util/enter-link-reference.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
var identity = require('./identity')
|
||||
|
||||
module.exports = enter
|
||||
|
||||
// Shortcut and collapsed link references need no escaping and encoding during
|
||||
// the processing of child nodes (it must be implied from identifier).
|
||||
//
|
||||
// This toggler turns encoding and escaping off for shortcut and collapsed
|
||||
// references.
|
||||
//
|
||||
// Implies `enterLink`.
|
||||
function enter(compiler, node) {
|
||||
var encode = compiler.encode
|
||||
var escape = compiler.escape
|
||||
var exitLink = compiler.enterLink()
|
||||
|
||||
if (node.referenceType !== 'shortcut' && node.referenceType !== 'collapsed') {
|
||||
return exitLink
|
||||
}
|
||||
|
||||
compiler.escape = identity
|
||||
compiler.encode = identity
|
||||
|
||||
return exit
|
||||
|
||||
function exit() {
|
||||
compiler.encode = encode
|
||||
compiler.escape = escape
|
||||
exitLink()
|
||||
}
|
||||
}
|
||||
23
node_modules/remark-stringify/lib/util/entity-prefix-length.js
generated
vendored
Normal file
23
node_modules/remark-stringify/lib/util/entity-prefix-length.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
var decode = require('parse-entities')
|
||||
|
||||
module.exports = length
|
||||
|
||||
var ampersand = '&'
|
||||
|
||||
// Returns the length of HTML entity that is a prefix of the given string
|
||||
// (excluding the ampersand), 0 if it does not start with an entity.
|
||||
function length(value) {
|
||||
var prefix
|
||||
|
||||
/* istanbul ignore if - Currently also tested for at implemention, but we
|
||||
* keep it here because that’s proper. */
|
||||
if (value.charAt(0) !== ampersand) {
|
||||
return 0
|
||||
}
|
||||
|
||||
prefix = value.split(ampersand, 2).join(ampersand)
|
||||
|
||||
return prefix.length - decode(prefix).length
|
||||
}
|
||||
7
node_modules/remark-stringify/lib/util/identity.js
generated
vendored
Normal file
7
node_modules/remark-stringify/lib/util/identity.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = identity
|
||||
|
||||
function identity(value) {
|
||||
return value
|
||||
}
|
||||
27
node_modules/remark-stringify/lib/util/label.js
generated
vendored
Normal file
27
node_modules/remark-stringify/lib/util/label.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = label
|
||||
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
|
||||
var shortcut = 'shortcut'
|
||||
var collapsed = 'collapsed'
|
||||
|
||||
// Stringify a reference label.
|
||||
// Because link references are easily, mistakingly, created (for example,
|
||||
// `[foo]`), reference nodes have an extra property depicting how it looked in
|
||||
// the original document, so stringification can cause minimal changes.
|
||||
function label(node) {
|
||||
var type = node.referenceType
|
||||
|
||||
if (type === shortcut) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return (
|
||||
leftSquareBracket +
|
||||
(type === collapsed ? '' : node.label || node.identifier) +
|
||||
rightSquareBracket
|
||||
)
|
||||
}
|
||||
26
node_modules/remark-stringify/lib/util/pad.js
generated
vendored
Normal file
26
node_modules/remark-stringify/lib/util/pad.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
module.exports = pad
|
||||
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
|
||||
var tabSize = 4
|
||||
|
||||
// Pad `value` with `level * tabSize` spaces. Respects lines. Ignores empty
|
||||
// lines.
|
||||
function pad(value, level) {
|
||||
var values = value.split(lineFeed)
|
||||
var index = values.length
|
||||
var padding = repeat(space, level * tabSize)
|
||||
|
||||
while (index--) {
|
||||
if (values[index].length !== 0) {
|
||||
values[index] = padding + values[index]
|
||||
}
|
||||
}
|
||||
|
||||
return values.join(lineFeed)
|
||||
}
|
||||
22
node_modules/remark-stringify/lib/visitors/blockquote.js
generated
vendored
Normal file
22
node_modules/remark-stringify/lib/visitors/blockquote.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = blockquote
|
||||
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var greaterThan = '>'
|
||||
|
||||
function blockquote(node) {
|
||||
var values = this.block(node).split(lineFeed)
|
||||
var result = []
|
||||
var length = values.length
|
||||
var index = -1
|
||||
var value
|
||||
|
||||
while (++index < length) {
|
||||
value = values[index]
|
||||
result[index] = (value ? space : '') + value
|
||||
}
|
||||
|
||||
return greaterThan + result.join(lineFeed + greaterThan)
|
||||
}
|
||||
14
node_modules/remark-stringify/lib/visitors/break.js
generated
vendored
Normal file
14
node_modules/remark-stringify/lib/visitors/break.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = lineBreak
|
||||
|
||||
var backslash = '\\'
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
|
||||
var commonmark = backslash + lineFeed
|
||||
var normal = space + space + lineFeed
|
||||
|
||||
function lineBreak() {
|
||||
return this.options.commonmark ? commonmark : normal
|
||||
}
|
||||
79
node_modules/remark-stringify/lib/visitors/code.js
generated
vendored
Normal file
79
node_modules/remark-stringify/lib/visitors/code.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
'use strict'
|
||||
|
||||
var streak = require('longest-streak')
|
||||
var repeat = require('repeat-string')
|
||||
var pad = require('../util/pad')
|
||||
|
||||
module.exports = code
|
||||
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
|
||||
// Stringify code.
|
||||
// Creates indented code when:
|
||||
//
|
||||
// - No language tag exists
|
||||
// - Not in `fences: true` mode
|
||||
// - A non-empty value exists
|
||||
//
|
||||
// Otherwise, GFM fenced code is created:
|
||||
//
|
||||
// ````markdown
|
||||
// ```js
|
||||
// foo();
|
||||
// ```
|
||||
// ````
|
||||
//
|
||||
// When in ``fence: `~` `` mode, uses tildes as fences:
|
||||
//
|
||||
// ```markdown
|
||||
// ~~~js
|
||||
// foo();
|
||||
// ~~~
|
||||
// ```
|
||||
//
|
||||
// Knows about internal fences:
|
||||
//
|
||||
// `````markdown
|
||||
// ````markdown
|
||||
// ```javascript
|
||||
// foo();
|
||||
// ```
|
||||
// ````
|
||||
// `````
|
||||
function code(node, parent) {
|
||||
var self = this
|
||||
var value = node.value
|
||||
var options = self.options
|
||||
var marker = options.fence
|
||||
var info = node.lang || ''
|
||||
var fence
|
||||
|
||||
if (info && node.meta) {
|
||||
info += space + node.meta
|
||||
}
|
||||
|
||||
info = self.encode(self.escape(info, node))
|
||||
|
||||
// Without (needed) fences.
|
||||
if (!info && !options.fences && value) {
|
||||
// Throw when pedantic, in a list item which isn’t compiled using a tab.
|
||||
if (
|
||||
parent &&
|
||||
parent.type === 'listItem' &&
|
||||
options.listItemIndent !== 'tab' &&
|
||||
options.pedantic
|
||||
) {
|
||||
self.file.fail(
|
||||
'Cannot indent code properly. See https://git.io/fxKR8',
|
||||
node.position
|
||||
)
|
||||
}
|
||||
|
||||
return pad(value, 1)
|
||||
}
|
||||
|
||||
fence = repeat(marker, Math.max(streak(value, marker) + 1, 3))
|
||||
|
||||
return fence + info + lineFeed + value + lineFeed + fence
|
||||
}
|
||||
36
node_modules/remark-stringify/lib/visitors/definition.js
generated
vendored
Normal file
36
node_modules/remark-stringify/lib/visitors/definition.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict'
|
||||
|
||||
var uri = require('../util/enclose-uri')
|
||||
var title = require('../util/enclose-title')
|
||||
|
||||
module.exports = definition
|
||||
|
||||
var space = ' '
|
||||
var colon = ':'
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
|
||||
// Stringify an URL definition.
|
||||
//
|
||||
// Is smart about enclosing `url` (see `encloseURI()`) and `title` (see
|
||||
// `encloseTitle()`).
|
||||
//
|
||||
// ```markdown
|
||||
// [foo]: <foo at bar dot com> 'An "example" e-mail'
|
||||
// ```
|
||||
function definition(node) {
|
||||
var content = uri(node.url)
|
||||
|
||||
if (node.title) {
|
||||
content += space + title(node.title)
|
||||
}
|
||||
|
||||
return (
|
||||
leftSquareBracket +
|
||||
(node.label || node.identifier) +
|
||||
rightSquareBracket +
|
||||
colon +
|
||||
space +
|
||||
content
|
||||
)
|
||||
}
|
||||
11
node_modules/remark-stringify/lib/visitors/delete.js
generated
vendored
Normal file
11
node_modules/remark-stringify/lib/visitors/delete.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = strikethrough
|
||||
|
||||
var tilde = '~'
|
||||
|
||||
var fence = tilde + tilde
|
||||
|
||||
function strikethrough(node) {
|
||||
return fence + this.all(node).join('') + fence
|
||||
}
|
||||
38
node_modules/remark-stringify/lib/visitors/emphasis.js
generated
vendored
Normal file
38
node_modules/remark-stringify/lib/visitors/emphasis.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = emphasis
|
||||
|
||||
var underscore = '_'
|
||||
var asterisk = '*'
|
||||
|
||||
// Stringify an `emphasis`.
|
||||
//
|
||||
// The marker used is configurable through `emphasis`, which defaults to an
|
||||
// underscore (`'_'`) but also accepts an asterisk (`'*'`):
|
||||
//
|
||||
// ```markdown
|
||||
// *foo*
|
||||
// ```
|
||||
//
|
||||
// In `pedantic` mode, text which itself contains an underscore will cause the
|
||||
// marker to default to an asterisk instead:
|
||||
//
|
||||
// ```markdown
|
||||
// *foo_bar*
|
||||
// ```
|
||||
function emphasis(node) {
|
||||
var marker = this.options.emphasis
|
||||
var content = this.all(node).join('')
|
||||
|
||||
// When in pedantic mode, prevent using underscore as the marker when there
|
||||
// are underscores in the content.
|
||||
if (
|
||||
this.options.pedantic &&
|
||||
marker === underscore &&
|
||||
content.indexOf(marker) !== -1
|
||||
) {
|
||||
marker = asterisk
|
||||
}
|
||||
|
||||
return marker + content + marker
|
||||
}
|
||||
30
node_modules/remark-stringify/lib/visitors/footnote-definition.js
generated
vendored
Normal file
30
node_modules/remark-stringify/lib/visitors/footnote-definition.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var colon = ':'
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var caret = '^'
|
||||
|
||||
var tabSize = 4
|
||||
var blank = lineFeed + lineFeed
|
||||
var indent = repeat(space, tabSize)
|
||||
|
||||
module.exports = footnoteDefinition
|
||||
|
||||
function footnoteDefinition(node) {
|
||||
var content = this.all(node).join(blank + indent)
|
||||
|
||||
return (
|
||||
leftSquareBracket +
|
||||
caret +
|
||||
(node.label || node.identifier) +
|
||||
rightSquareBracket +
|
||||
colon +
|
||||
space +
|
||||
content
|
||||
)
|
||||
}
|
||||
16
node_modules/remark-stringify/lib/visitors/footnote-reference.js
generated
vendored
Normal file
16
node_modules/remark-stringify/lib/visitors/footnote-reference.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = footnoteReference
|
||||
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var caret = '^'
|
||||
|
||||
function footnoteReference(node) {
|
||||
return (
|
||||
leftSquareBracket +
|
||||
caret +
|
||||
(node.label || node.identifier) +
|
||||
rightSquareBracket
|
||||
)
|
||||
}
|
||||
13
node_modules/remark-stringify/lib/visitors/footnote.js
generated
vendored
Normal file
13
node_modules/remark-stringify/lib/visitors/footnote.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = footnote
|
||||
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var caret = '^'
|
||||
|
||||
function footnote(node) {
|
||||
return (
|
||||
leftSquareBracket + caret + this.all(node).join('') + rightSquareBracket
|
||||
)
|
||||
}
|
||||
51
node_modules/remark-stringify/lib/visitors/heading.js
generated
vendored
Normal file
51
node_modules/remark-stringify/lib/visitors/heading.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
module.exports = heading
|
||||
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var numberSign = '#'
|
||||
var dash = '-'
|
||||
var equalsTo = '='
|
||||
|
||||
// Stringify a heading.
|
||||
//
|
||||
// In `setext: true` mode and when `depth` is smaller than three, creates a
|
||||
// setext header:
|
||||
//
|
||||
// ```markdown
|
||||
// Foo
|
||||
// ===
|
||||
// ```
|
||||
//
|
||||
// Otherwise, an ATX header is generated:
|
||||
//
|
||||
// ```markdown
|
||||
// ### Foo
|
||||
// ```
|
||||
//
|
||||
// In `closeAtx: true` mode, the header is closed with hashes:
|
||||
//
|
||||
// ```markdown
|
||||
// ### Foo ###
|
||||
// ```
|
||||
function heading(node) {
|
||||
var self = this
|
||||
var depth = node.depth
|
||||
var setext = self.options.setext
|
||||
var closeAtx = self.options.closeAtx
|
||||
var content = self.all(node).join('')
|
||||
var prefix
|
||||
|
||||
if (setext && depth < 3) {
|
||||
return (
|
||||
content + lineFeed + repeat(depth === 1 ? equalsTo : dash, content.length)
|
||||
)
|
||||
}
|
||||
|
||||
prefix = repeat(numberSign, node.depth)
|
||||
|
||||
return prefix + space + content + (closeAtx ? space + prefix : '')
|
||||
}
|
||||
7
node_modules/remark-stringify/lib/visitors/html.js
generated
vendored
Normal file
7
node_modules/remark-stringify/lib/visitors/html.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = html
|
||||
|
||||
function html(node) {
|
||||
return node.value
|
||||
}
|
||||
19
node_modules/remark-stringify/lib/visitors/image-reference.js
generated
vendored
Normal file
19
node_modules/remark-stringify/lib/visitors/image-reference.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
var label = require('../util/label')
|
||||
|
||||
module.exports = imageReference
|
||||
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var exclamationMark = '!'
|
||||
|
||||
function imageReference(node) {
|
||||
return (
|
||||
exclamationMark +
|
||||
leftSquareBracket +
|
||||
(this.encode(node.alt, node) || '') +
|
||||
rightSquareBracket +
|
||||
label(node)
|
||||
)
|
||||
}
|
||||
47
node_modules/remark-stringify/lib/visitors/image.js
generated
vendored
Normal file
47
node_modules/remark-stringify/lib/visitors/image.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict'
|
||||
|
||||
var uri = require('../util/enclose-uri')
|
||||
var title = require('../util/enclose-title')
|
||||
|
||||
module.exports = image
|
||||
|
||||
var space = ' '
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var exclamationMark = '!'
|
||||
|
||||
// Stringify an image.
|
||||
//
|
||||
// Is smart about enclosing `url` (see `encloseURI()`) and `title` (see
|
||||
// `encloseTitle()`).
|
||||
//
|
||||
// ```markdown
|
||||
// 
|
||||
// ```
|
||||
//
|
||||
// Supports named entities in `url`, `alt`, and `title` when in
|
||||
// `settings.encode` mode.
|
||||
function image(node) {
|
||||
var self = this
|
||||
var content = uri(self.encode(node.url || '', node))
|
||||
var exit = self.enterLink()
|
||||
var alt = self.encode(self.escape(node.alt || '', node))
|
||||
|
||||
exit()
|
||||
|
||||
if (node.title) {
|
||||
content += space + title(self.encode(node.title, node))
|
||||
}
|
||||
|
||||
return (
|
||||
exclamationMark +
|
||||
leftSquareBracket +
|
||||
alt +
|
||||
rightSquareBracket +
|
||||
leftParenthesis +
|
||||
content +
|
||||
rightParenthesis
|
||||
)
|
||||
}
|
||||
41
node_modules/remark-stringify/lib/visitors/inline-code.js
generated
vendored
Normal file
41
node_modules/remark-stringify/lib/visitors/inline-code.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict'
|
||||
|
||||
var streak = require('longest-streak')
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
module.exports = inlineCode
|
||||
|
||||
var space = ' '
|
||||
var graveAccent = '`'
|
||||
|
||||
// Stringify inline code.
|
||||
//
|
||||
// Knows about internal ticks (`\``), and ensures one more tick is used to
|
||||
// enclose the inline code:
|
||||
//
|
||||
// ````markdown
|
||||
// ```foo ``bar`` baz```
|
||||
// ````
|
||||
//
|
||||
// Even knows about inital and final ticks:
|
||||
//
|
||||
// ``markdown
|
||||
// `` `foo ``
|
||||
// `` foo` ``
|
||||
// ```
|
||||
function inlineCode(node) {
|
||||
var value = node.value
|
||||
var ticks = repeat(graveAccent, streak(value, graveAccent) + 1)
|
||||
var start = ticks
|
||||
var end = ticks
|
||||
|
||||
if (value.charAt(0) === graveAccent) {
|
||||
start += space
|
||||
}
|
||||
|
||||
if (value.charAt(value.length - 1) === graveAccent) {
|
||||
end = space + end
|
||||
}
|
||||
|
||||
return start + value + end
|
||||
}
|
||||
27
node_modules/remark-stringify/lib/visitors/link-reference.js
generated
vendored
Normal file
27
node_modules/remark-stringify/lib/visitors/link-reference.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
var copy = require('../util/copy-identifier-encoding')
|
||||
var label = require('../util/label')
|
||||
|
||||
module.exports = linkReference
|
||||
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
|
||||
var shortcut = 'shortcut'
|
||||
var collapsed = 'collapsed'
|
||||
|
||||
function linkReference(node) {
|
||||
var self = this
|
||||
var type = node.referenceType
|
||||
var exit = self.enterLinkReference(self, node)
|
||||
var value = self.all(node).join('')
|
||||
|
||||
exit()
|
||||
|
||||
if (type === shortcut || type === collapsed) {
|
||||
value = copy(value, node.label || node.identifier)
|
||||
}
|
||||
|
||||
return leftSquareBracket + value + rightSquareBracket + label(node)
|
||||
}
|
||||
65
node_modules/remark-stringify/lib/visitors/link.js
generated
vendored
Normal file
65
node_modules/remark-stringify/lib/visitors/link.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
'use strict'
|
||||
|
||||
var uri = require('../util/enclose-uri')
|
||||
var title = require('../util/enclose-title')
|
||||
|
||||
module.exports = link
|
||||
|
||||
var space = ' '
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
|
||||
// Expression for a protocol:
|
||||
// See <http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax>.
|
||||
var protocol = /^[a-z][a-z+.-]+:\/?/i
|
||||
|
||||
// Stringify a link.
|
||||
//
|
||||
// When no title exists, the compiled `children` equal `url`, and `url` starts
|
||||
// with a protocol, an auto link is created:
|
||||
//
|
||||
// ```markdown
|
||||
// <http://example.com>
|
||||
// ```
|
||||
//
|
||||
// Otherwise, is smart about enclosing `url` (see `encloseURI()`) and `title`
|
||||
// (see `encloseTitle()`).
|
||||
// ```
|
||||
//
|
||||
// ```markdown
|
||||
// [foo](<foo at bar dot com> 'An "example" e-mail')
|
||||
// ```
|
||||
//
|
||||
// Supports named entities in the `url` and `title` when in `settings.encode`
|
||||
// mode.
|
||||
function link(node) {
|
||||
var self = this
|
||||
var content = self.encode(node.url || '', node)
|
||||
var exit = self.enterLink()
|
||||
var escaped = self.encode(self.escape(node.url || '', node))
|
||||
var value = self.all(node).join('')
|
||||
|
||||
exit()
|
||||
|
||||
if (node.title == null && protocol.test(content) && escaped === value) {
|
||||
// Backslash escapes do not work in autolinks, so we do not escape.
|
||||
return uri(self.encode(node.url), true)
|
||||
}
|
||||
|
||||
content = uri(content)
|
||||
|
||||
if (node.title) {
|
||||
content += space + title(self.encode(self.escape(node.title, node), node))
|
||||
}
|
||||
|
||||
return (
|
||||
leftSquareBracket +
|
||||
value +
|
||||
rightSquareBracket +
|
||||
leftParenthesis +
|
||||
content +
|
||||
rightParenthesis
|
||||
)
|
||||
}
|
||||
75
node_modules/remark-stringify/lib/visitors/list-item.js
generated
vendored
Normal file
75
node_modules/remark-stringify/lib/visitors/list-item.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
var pad = require('../util/pad')
|
||||
|
||||
module.exports = listItem
|
||||
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var lowercaseX = 'x'
|
||||
|
||||
var ceil = Math.ceil
|
||||
var blank = lineFeed + lineFeed
|
||||
|
||||
var tabSize = 4
|
||||
|
||||
// Stringify a list item.
|
||||
//
|
||||
// Prefixes the content with a checked checkbox when `checked: true`:
|
||||
//
|
||||
// ```markdown
|
||||
// [x] foo
|
||||
// ```
|
||||
//
|
||||
// Prefixes the content with an unchecked checkbox when `checked: false`:
|
||||
//
|
||||
// ```markdown
|
||||
// [ ] foo
|
||||
// ```
|
||||
function listItem(node, parent, position, bullet) {
|
||||
var self = this
|
||||
var style = self.options.listItemIndent
|
||||
var marker = bullet || self.options.bullet
|
||||
var spread = node.spread == null ? true : node.spread
|
||||
var checked = node.checked
|
||||
var children = node.children
|
||||
var length = children.length
|
||||
var values = []
|
||||
var index = -1
|
||||
var value
|
||||
var indent
|
||||
var spacing
|
||||
|
||||
while (++index < length) {
|
||||
values[index] = self.visit(children[index], node)
|
||||
}
|
||||
|
||||
value = values.join(spread ? blank : lineFeed)
|
||||
|
||||
if (typeof checked === 'boolean') {
|
||||
// Note: I’d like to be able to only add the space between the check and
|
||||
// the value, but unfortunately github does not support empty list-items
|
||||
// with a checkbox :(
|
||||
value =
|
||||
leftSquareBracket +
|
||||
(checked ? lowercaseX : space) +
|
||||
rightSquareBracket +
|
||||
space +
|
||||
value
|
||||
}
|
||||
|
||||
if (style === '1' || (style === 'mixed' && value.indexOf(lineFeed) === -1)) {
|
||||
indent = marker.length + 1
|
||||
spacing = space
|
||||
} else {
|
||||
indent = ceil((marker.length + 1) / tabSize) * tabSize
|
||||
spacing = repeat(space, indent - marker.length)
|
||||
}
|
||||
|
||||
return value
|
||||
? marker + spacing + pad(value, indent / tabSize).slice(indent)
|
||||
: marker
|
||||
}
|
||||
8
node_modules/remark-stringify/lib/visitors/list.js
generated
vendored
Normal file
8
node_modules/remark-stringify/lib/visitors/list.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = list
|
||||
|
||||
function list(node) {
|
||||
var fn = node.ordered ? this.visitOrderedItems : this.visitUnorderedItems
|
||||
return fn.call(this, node)
|
||||
}
|
||||
7
node_modules/remark-stringify/lib/visitors/paragraph.js
generated
vendored
Normal file
7
node_modules/remark-stringify/lib/visitors/paragraph.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = paragraph
|
||||
|
||||
function paragraph(node) {
|
||||
return this.all(node).join('')
|
||||
}
|
||||
11
node_modules/remark-stringify/lib/visitors/root.js
generated
vendored
Normal file
11
node_modules/remark-stringify/lib/visitors/root.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = root
|
||||
|
||||
var lineFeed = '\n'
|
||||
|
||||
// Stringify a root.
|
||||
// Adds a final newline to ensure valid POSIX files. */
|
||||
function root(node) {
|
||||
return this.block(node) + lineFeed
|
||||
}
|
||||
18
node_modules/remark-stringify/lib/visitors/strong.js
generated
vendored
Normal file
18
node_modules/remark-stringify/lib/visitors/strong.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
module.exports = strong
|
||||
|
||||
// Stringify a `strong`.
|
||||
//
|
||||
// The marker used is configurable by `strong`, which defaults to an asterisk
|
||||
// (`'*'`) but also accepts an underscore (`'_'`):
|
||||
//
|
||||
// ```markdown
|
||||
// __foo__
|
||||
// ```
|
||||
function strong(node) {
|
||||
var marker = repeat(this.options.strong, 2)
|
||||
return marker + this.all(node).join('') + marker
|
||||
}
|
||||
7
node_modules/remark-stringify/lib/visitors/table-cell.js
generated
vendored
Normal file
7
node_modules/remark-stringify/lib/visitors/table-cell.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = tableCell
|
||||
|
||||
function tableCell(node) {
|
||||
return this.all(node).join('')
|
||||
}
|
||||
68
node_modules/remark-stringify/lib/visitors/table.js
generated
vendored
Normal file
68
node_modules/remark-stringify/lib/visitors/table.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict'
|
||||
|
||||
var markdownTable = require('markdown-table')
|
||||
|
||||
module.exports = table
|
||||
|
||||
var space = ' '
|
||||
var verticalBar = '|'
|
||||
|
||||
// Stringify table.
|
||||
//
|
||||
// Creates a fenced table by default, but not in `looseTable: true` mode:
|
||||
//
|
||||
// ```markdown
|
||||
// Foo | Bar
|
||||
// :-: | ---
|
||||
// Baz | Qux
|
||||
//
|
||||
// NOTE: Be careful with `looseTable: true` mode, as a loose table inside an
|
||||
// indented code block on GitHub renders as an actual table!
|
||||
//
|
||||
// Creates a spaced table by default, but not in `spacedTable: false`:
|
||||
//
|
||||
// ```markdown
|
||||
// |Foo|Bar|
|
||||
// |:-:|---|
|
||||
// |Baz|Qux|
|
||||
// ```
|
||||
function table(node) {
|
||||
var self = this
|
||||
var options = self.options
|
||||
var loose = options.looseTable
|
||||
var spaced = options.spacedTable
|
||||
var pad = options.paddedTable
|
||||
var stringLength = options.stringLength
|
||||
var rows = node.children
|
||||
var index = rows.length
|
||||
var exit = self.enterTable()
|
||||
var result = []
|
||||
var start
|
||||
var end
|
||||
|
||||
while (index--) {
|
||||
result[index] = self.all(rows[index])
|
||||
}
|
||||
|
||||
exit()
|
||||
|
||||
if (loose) {
|
||||
start = ''
|
||||
end = ''
|
||||
} else if (spaced) {
|
||||
start = verticalBar + space
|
||||
end = space + verticalBar
|
||||
} else {
|
||||
start = verticalBar
|
||||
end = verticalBar
|
||||
}
|
||||
|
||||
return markdownTable(result, {
|
||||
align: node.align,
|
||||
pad: pad,
|
||||
start: start,
|
||||
end: end,
|
||||
stringLength: stringLength,
|
||||
delimiter: spaced ? space + verticalBar + space : verticalBar
|
||||
})
|
||||
}
|
||||
19
node_modules/remark-stringify/lib/visitors/text.js
generated
vendored
Normal file
19
node_modules/remark-stringify/lib/visitors/text.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = text
|
||||
|
||||
// Stringify text.
|
||||
// Supports named entities in `settings.encode: true` mode:
|
||||
//
|
||||
// ```markdown
|
||||
// AT&T
|
||||
// ```
|
||||
//
|
||||
// Supports numbered entities in `settings.encode: numbers` mode:
|
||||
//
|
||||
// ```markdown
|
||||
// AT&T
|
||||
// ```
|
||||
function text(node, parent) {
|
||||
return this.encode(this.escape(node.value, node, parent), node)
|
||||
}
|
||||
31
node_modules/remark-stringify/lib/visitors/thematic-break.js
generated
vendored
Normal file
31
node_modules/remark-stringify/lib/visitors/thematic-break.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
module.exports = thematic
|
||||
|
||||
var space = ' '
|
||||
|
||||
// Stringify a `thematic-break`.
|
||||
// The character used is configurable through `rule`: (`'_'`):
|
||||
//
|
||||
// ```markdown
|
||||
// ___
|
||||
// ```
|
||||
//
|
||||
// The number of repititions is defined through `ruleRepetition` (`6`):
|
||||
//
|
||||
// ```markdown
|
||||
// ******
|
||||
// ```
|
||||
//
|
||||
// Whether spaces delimit each character, is configured through `ruleSpaces`
|
||||
// (`true`):
|
||||
// ```markdown
|
||||
// * * *
|
||||
// ```
|
||||
function thematic() {
|
||||
var options = this.options
|
||||
var rule = repeat(options.rule, options.ruleRepetition)
|
||||
return options.ruleSpaces ? rule.split('').join(space) : rule
|
||||
}
|
||||
Reference in New Issue
Block a user