WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

14
node_modules/remark-stringify/index.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
'use strict';
var unherit = require('unherit');
var xtend = require('xtend');
var Compiler = require('./lib/compiler.js');
module.exports = stringify;
stringify.Compiler = Compiler;
function stringify(options) {
var Local = unherit(Compiler);
Local.prototype.options = xtend(Local.prototype.options, this.data('settings'), options);
this.Compiler = Local;
}

63
node_modules/remark-stringify/lib/compiler.js generated vendored Normal file
View 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
View 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;
}

247
node_modules/remark-stringify/lib/escape.js generated vendored Normal file
View File

@ -0,0 +1,247 @@
'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 BACKSLASH = '\\';
var BULLETS = ['*', '-', '+'];
var ALLIGNMENT = [':', '-', ' ', '|'];
var entities = {'<': '&lt;', ':': '&#x3A;', '&': '&amp;', '|': '&#x7C;', '~': '&#x7E;'};
/* 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 ? ['.', ')'] : ['.'];
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) && /\n\s*$/.test(prev.value);
} else {
afterNewLine = !parent || parent.type === 'root' || parent.type === 'paragraph';
}
function one(character) {
return escapable.indexOf(character) === -1 ?
entities[character] : BACKSLASH + character;
}
while (++position < length) {
character = value.charAt(position);
replace = false;
if (character === '\n') {
afterNewLine = true;
} else if (
character === BACKSLASH ||
character === '`' ||
character === '*' ||
character === '[' ||
character === '<' ||
(character === '&' && prefix(value.slice(position)) > 0) ||
(character === ']' && self.inLink) ||
(gfm && character === '~' && value.charAt(position + 1) === '~') ||
(gfm && character === '|' && (self.inTable || alignment(value, position))) ||
(
character === '_' &&
/* 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 === ':' && protocol(queue.join('')))
) {
replace = true;
} else if (afterNewLine) {
if (
character === '>' ||
character === '#' ||
BULLETS.indexOf(character) !== -1
) {
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 === ' ' || next === '\t' || next === '\n') {
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 === ' ' || character === '\t') {
continue;
}
if (character === '(' || character === ':') {
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) === '('
) {
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) === ':' &&
protocol(prev.value.slice(-6))
) {
escaped[0] = one(':');
}
/* Escape ampersand if it would otherwise
* start an entity. */
if (
text(next) &&
value.charAt(length - 1) === '&' &&
prefix('&' + next.value) !== 0
) {
escaped[escaped.length - 1] = one('&');
}
/* Escape double tildes in GFM. */
if (
gfm &&
text(next) &&
value.charAt(length - 1) === '~' &&
next.value.charAt(0) === '~'
) {
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 === '_' && (pedantic || !wordCharBefore || !wordCharAfter)) {
escaped.unshift(BACKSLASH);
}
} else {
if (
value.charAt(0) === '_' &&
(pedantic || !wordCharBefore || !alphanumeric(value.charAt(1)))
) {
escaped.unshift(BACKSLASH);
}
if (
value.charAt(length - 1) === '_' &&
(pedantic || !wordCharAfter || !alphanumeric(value.charAt(length - 2)))
) {
escaped.splice(escaped.length - 1, 0, BACKSLASH);
}
}
}
return escaped.join('');
}
}
/* Check if `index` in `value` is inside an alignment row. */
function alignment(value, index) {
var start = value.lastIndexOf('\n', index);
var end = value.indexOf('\n', index);
start = start === -1 ? -1 : start;
end = end === -1 ? value.length : end;
while (++start < end) {
if (ALLIGNMENT.indexOf(value.charAt(start)) === -1) {
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
View 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;
}

45
node_modules/remark-stringify/lib/macro/block.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
'use strict';
module.exports = block;
/* 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 newline
* between them. */
function block(node) {
var self = this;
var values = [];
var children = node.children;
var length = children.length;
var index = -1;
var child;
var prev;
while (++index < length) {
child = children[index];
if (prev) {
/* Duplicate nodes, such as a list
* directly following another list,
* often need multiple new lines.
*
* Additionally, code blocks following a list
* might easily be mistaken for a paragraph
* in the list itself. */
if (child.type === prev.type && prev.type === 'list') {
values.push(prev.ordered === child.ordered ? '\n\n\n' : '\n\n');
} else if (prev.type === 'list' && child.type === 'code' && !child.lang) {
values.push('\n\n\n');
} else {
values.push('\n\n');
}
}
values.push(self.visit(child, node));
prev = child;
}
return values.join('');
}

10
node_modules/remark-stringify/lib/macro/compile.js generated vendored Normal file
View 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));
}

21
node_modules/remark-stringify/lib/macro/one.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
'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);
}

View File

@ -0,0 +1,37 @@
'use strict';
module.exports = orderedItems;
/* 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;
while (++index < length) {
bullet = (increment ? start + index : start) + '.';
values[index] = fn.call(self, children[index], node, index, bullet);
}
return values.join('\n');
}

View File

@ -0,0 +1,22 @@
'use strict';
module.exports = unorderedItems;
/* 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('\n');
}

168
node_modules/remark-stringify/lib/set-options.js generated vendored Normal file
View File

@ -0,0 +1,168 @@
'use strict';
var xtend = require('xtend');
var encode = require('stringify-entities');
var defaults = require('./defaults');
var escapeFactory = require('./escape');
var returner = require('./util/returner');
module.exports = setOptions;
/* Map of applicable enum's. */
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;
}
/* Throw an exception with in its `message` `value`
* and `name`. */
function raise(value, name) {
throw new Error('Invalid value `' + value + '` for setting `' + name + '`');
}
/* 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 returner;
}
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);
}
}

View File

@ -0,0 +1,60 @@
'use strict';
var entityPrefixLength = require('./entity-prefix-length');
module.exports = copy;
var PUNCTUATION = /[-!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~_]/;
/* 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 && !PUNCTUATION.test(value.charAt(index))) {
index += 1;
}
result.push(value.slice(start, index));
/* Advance `position` to the next punctuation character. */
while (position < count && !PUNCTUATION.test(identifier.charAt(position))) {
position += 1;
}
/* Take next punctuation characters from `identifier`. */
start = position;
while (position < count && PUNCTUATION.test(identifier.charAt(position))) {
if (identifier.charAt(position) === '&') {
position += entityPrefixLength(identifier.slice(position));
}
position += 1;
}
result.push(identifier.slice(start, position));
/* Advance `index` to the next non-punctuation character. */
while (index < length && PUNCTUATION.test(value.charAt(index))) {
index += 1;
}
}
return result.join('');
}

View File

@ -0,0 +1,13 @@
'use strict';
module.exports = enclose;
/* 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('"') === -1 ? '"' : '\'';
return delimiter + title + delimiter;
}

24
node_modules/remark-stringify/lib/util/enclose-uri.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
'use strict';
var count = require('ccount');
module.exports = enclose;
var re = /\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 || re.test(uri) || count(uri, '(') !== count(uri, ')')) {
return '<' + uri + '>';
}
return uri;
}

View File

@ -0,0 +1,36 @@
'use strict';
var returner = require('./returner');
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 exit = compiler.enterLink();
if (
node.referenceType !== 'shortcut' &&
node.referenceType !== 'collapsed'
) {
return exit;
}
compiler.escape = returner;
compiler.encode = returner;
return function () {
compiler.encode = encode;
compiler.escape = escape;
exit();
};
}

View File

@ -0,0 +1,23 @@
'use strict';
var decode = require('parse-entities');
module.exports = length;
/* 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 thats
* proper. */
if (value.charAt(0) !== '&') {
return 0;
}
prefix = value.split('&', 2).join('&');
return prefix.length - decode(prefix).length;
}

16
node_modules/remark-stringify/lib/util/label.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
'use strict';
module.exports = label;
/* 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;
var value = type === 'full' ? node.identifier : '';
return type === 'shortcut' ? value : '[' + value + ']';
}

27
node_modules/remark-stringify/lib/util/pad.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
'use strict';
var repeat = require('repeat-string');
module.exports = pad;
var INDENT = 4;
/* Pad `value` with `level * INDENT` spaces. Respects
* lines. Ignores empty lines. */
function pad(value, level) {
var index;
var padding;
value = value.split('\n');
index = value.length;
padding = repeat(' ', level * INDENT);
while (index--) {
if (value[index].length !== 0) {
value[index] = padding + value[index];
}
}
return value.join('\n');
}

7
node_modules/remark-stringify/lib/util/returner.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
'use strict';
module.exports = returner;
function returner(value) {
return value;
}

View File

@ -0,0 +1,18 @@
'use strict';
module.exports = blockquote;
function blockquote(node) {
var values = this.block(node).split('\n');
var result = [];
var length = values.length;
var index = -1;
var value;
while (++index < length) {
value = values[index];
result[index] = (value ? ' ' : '') + value;
}
return '>' + result.join('\n>');
}

9
node_modules/remark-stringify/lib/visitors/break.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
'use strict';
module.exports = lineBreak;
var map = {true: '\\\n', false: ' \n'};
function lineBreak() {
return map[this.options.commonmark];
}

63
node_modules/remark-stringify/lib/visitors/code.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
'use strict';
var streak = require('longest-streak');
var repeat = require('repeat-string');
var pad = require('../util/pad');
module.exports = code;
/* 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:
*
* ```js
* foo();
* ```
*
* When in ``fence: `~` `` mode, uses tildes as fences:
*
* ~~~js
* foo();
* ~~~
*
* Knows about internal fences:
*
* ````markdown
* ```javascript
* foo();
* ```
* ````
*/
function code(node, parent) {
var self = this;
var value = node.value;
var options = self.options;
var marker = options.fence;
var language = self.encode(node.lang || '', node);
var fence;
/* Without (needed) fences. */
if (!language && !options.fences && value) {
/* Throw when pedantic, in a list item which
* isnt compiled using a tab. */
if (
parent &&
parent.type === 'listItem' &&
options.listItemIndent !== 'tab' &&
options.pedantic
) {
self.file.fail('Cannot indent code properly. See http://git.io/vgFvT', node.position);
}
return pad(value, 1);
}
fence = repeat(marker, Math.max(streak(value, marker) + 1, 3));
return fence + language + '\n' + value + '\n' + fence;
}

View File

@ -0,0 +1,23 @@
'use strict';
var uri = require('../util/enclose-uri');
var title = require('../util/enclose-title');
module.exports = definition;
/* Stringify an URL definition.
*
* Is smart about enclosing `url` (see `encloseURI()`) and
* `title` (see `encloseTitle()`).
*
* [foo]: <foo at bar dot com> 'An "example" e-mail'
*/
function definition(node) {
var content = uri(node.url);
if (node.title) {
content += ' ' + title(node.title);
}
return '[' + node.identifier + ']: ' + content;
}

7
node_modules/remark-stringify/lib/visitors/delete.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
'use strict';
module.exports = strikethrough;
function strikethrough(node) {
return '~~' + this.all(node).join('') + '~~';
}

16
node_modules/remark-stringify/lib/visitors/emphasis.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
'use strict';
module.exports = emphasis;
/* Stringify an `emphasis`.
*
* The marker used is configurable through `emphasis`, which
* defaults to an underscore (`'_'`) but also accepts an
* asterisk (`'*'`):
*
* *foo*
*/
function emphasis(node) {
var marker = this.options.emphasis;
return marker + this.all(node).join('') + marker;
}

View File

@ -0,0 +1,12 @@
'use strict';
var repeat = require('repeat-string');
module.exports = footnoteDefinition;
function footnoteDefinition(node) {
var id = node.identifier.toLowerCase();
var content = this.all(node).join('\n\n' + repeat(' ', 4));
return '[^' + id + ']: ' + content;
}

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = footnoteReference;
function footnoteReference(node) {
return '[^' + node.identifier + ']';
}

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = footnote;
function footnote(node) {
return '[^' + this.all(node).join('') + ']';
}

39
node_modules/remark-stringify/lib/visitors/heading.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
'use strict';
var repeat = require('repeat-string');
module.exports = heading;
/* Stringify a heading.
*
* In `setext: true` mode and when `depth` is smaller than
* three, creates a setext header:
*
* Foo
* ===
*
* Otherwise, an ATX header is generated:
*
* ### Foo
*
* In `closeAtx: true` mode, the header is closed with
* hashes:
*
* ### 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 + '\n' + repeat(depth === 1 ? '=' : '-', content.length);
}
prefix = repeat('#', node.depth);
return prefix + ' ' + content + (closeAtx ? ' ' + prefix : '');
}

7
node_modules/remark-stringify/lib/visitors/html.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
'use strict';
module.exports = html;
function html(node) {
return node.value;
}

View File

@ -0,0 +1,9 @@
'use strict';
var label = require('../util/label');
module.exports = imageReference;
function imageReference(node) {
return '![' + (this.encode(node.alt, node) || '') + ']' + label(node);
}

31
node_modules/remark-stringify/lib/visitors/image.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
'use strict';
var uri = require('../util/enclose-uri');
var title = require('../util/enclose-title');
module.exports = image;
/* Stringify an image.
*
* Is smart about enclosing `url` (see `encloseURI()`) and
* `title` (see `encloseTitle()`).
*
* ![foo](</fav icon.png> 'My "favourite" icon')
*
* 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 += ' ' + title(self.encode(node.title, node));
}
return '![' + alt + '](' + content + ')';
}

View File

@ -0,0 +1,35 @@
'use strict';
var streak = require('longest-streak');
var repeat = require('repeat-string');
module.exports = inlineCode;
/* Stringify inline code.
*
* Knows about internal ticks (`\``), and ensures one more
* tick is used to enclose the inline code:
*
* ```foo ``bar`` baz```
*
* Even knows about inital and final ticks:
*
* `` `foo ``
* `` foo` ``
*/
function inlineCode(node) {
var value = node.value;
var ticks = repeat('`', streak(value, '`') + 1);
var start = ticks;
var end = ticks;
if (value.charAt(0) === '`') {
start += ' ';
}
if (value.charAt(value.length - 1) === '`') {
end = ' ' + end;
}
return start + value + end;
}

View File

@ -0,0 +1,21 @@
'use strict';
var copy = require('../util/copy-identifier-encoding');
var label = require('../util/label');
module.exports = linkReference;
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.identifier);
}
return '[' + value + ']' + label(node);
}

53
node_modules/remark-stringify/lib/visitors/link.js generated vendored Normal file
View File

@ -0,0 +1,53 @@
'use strict';
var uri = require('../util/enclose-uri');
var title = require('../util/enclose-title');
module.exports = link;
/* Expression for a protocol:
* 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:
*
* <http://example.com>
*
* Otherwise, is smart about enclosing `url` (see
* `encloseURI()`) and `title` (see `encloseTitle()`).
*
* [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 || escaped === 'mailto:' + 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 += ' ' + title(self.encode(self.escape(node.title, node), node));
}
return '[' + value + '](' + content + ')';
}

View File

@ -0,0 +1,61 @@
'use strict';
var repeat = require('repeat-string');
var pad = require('../util/pad');
module.exports = listItem;
/* Which checkbox to use. */
var CHECKBOX_MAP = {
undefined: '',
null: '',
true: '[x] ',
false: '[ ] '
};
/* Stringify a list item.
*
* Prefixes the content with a checked checkbox when
* `checked: true`:
*
* [x] foo
*
* Prefixes the content with an unchecked checkbox when
* `checked: false`:
*
* [ ] foo
*/
function listItem(node, parent, position, bullet) {
var self = this;
var style = self.options.listItemIndent;
var loose = node.loose;
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 = CHECKBOX_MAP[node.checked] + values.join(loose ? '\n\n' : '\n');
if (style === '1' || (style === 'mixed' && value.indexOf('\n') === -1)) {
indent = bullet.length + 1;
spacing = ' ';
} else {
indent = Math.ceil((bullet.length + 1) / 4) * 4;
spacing = repeat(' ', indent - bullet.length);
}
value = bullet + spacing + pad(value, indent / 4).slice(indent);
if (loose && parent.children.length - 1 !== position) {
value += '\n';
}
return value;
}

13
node_modules/remark-stringify/lib/visitors/list.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
'use strict';
module.exports = list;
/* Which method to use based on `list.ordered`. */
var ORDERED_MAP = {
true: 'visitOrderedItems',
false: 'visitUnorderedItems'
};
function list(node) {
return this[ORDERED_MAP[node.ordered]](node);
}

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = paragraph;
function paragraph(node) {
return this.all(node).join('');
}

9
node_modules/remark-stringify/lib/visitors/root.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
'use strict';
module.exports = root;
/* Stringify a root.
* Adds a final newline to ensure valid POSIX files. */
function root(node) {
return this.block(node) + '\n';
}

18
node_modules/remark-stringify/lib/visitors/strong.js generated vendored Normal file
View 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 (`'_'`):
*
* __foo__
*/
function strong(node) {
var marker = repeat(this.options.strong, 2);
return marker + this.all(node).join('') + marker;
}

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = tableCell;
function tableCell(node) {
return this.all(node).join('');
}

66
node_modules/remark-stringify/lib/visitors/table.js generated vendored Normal file
View File

@ -0,0 +1,66 @@
'use strict';
var markdownTable = require('markdown-table');
module.exports = table;
/* Stringify table.
*
* Creates a fenced table by default, but not in
* `looseTable: true` mode:
*
* 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`:
*
* |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 = '| ';
end = ' |';
} else {
start = '|';
end = '|';
}
return markdownTable(result, {
align: node.align,
pad: pad,
start: start,
end: end,
stringLength: stringLength,
delimiter: spaced ? ' | ' : '|'
});
}

17
node_modules/remark-stringify/lib/visitors/text.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
'use strict';
module.exports = text;
/* Stringify text.
* Supports named entities in `settings.encode: true` mode:
*
* AT&amp;T
*
* Supports numbered entities in `settings.encode: numbers`
* mode:
*
* AT&#x26;T
*/
function text(node, parent) {
return this.encode(this.escape(node.value, node, parent), node);
}

View File

@ -0,0 +1,26 @@
'use strict';
var repeat = require('repeat-string');
module.exports = thematic;
/* Stringify a `thematic-break`.
* The character used is configurable through `rule`: (`'_'`)
*
* ___
*
* The number of repititions is defined through
* `ruleRepetition`: (`6`)
*
* ******
*
* Whether spaces delimit each character, is configured
* through `ruleSpaces`: (`true`)
*
* * * *
*/
function thematic() {
var options = this.options;
var rule = repeat(options.rule, options.ruleRepetition);
return options.ruleSpaces ? rule.split('').join(' ') : rule;
}

84
node_modules/remark-stringify/package.json generated vendored Normal file
View File

@ -0,0 +1,84 @@
{
"_from": "remark-stringify@^5.0.0",
"_id": "remark-stringify@5.0.0",
"_inBundle": false,
"_integrity": "sha512-Ws5MdA69ftqQ/yhRF9XhVV29mhxbfGhbz0Rx5bQH+oJcNhhSM6nCu1EpLod+DjrFGrU0BMPs+czVmJZU7xiS7w==",
"_location": "/remark-stringify",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "remark-stringify@^5.0.0",
"name": "remark-stringify",
"escapedName": "remark-stringify",
"rawSpec": "^5.0.0",
"saveSpec": null,
"fetchSpec": "^5.0.0"
},
"_requiredBy": [
"/gatsby-transformer-remark"
],
"_resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-5.0.0.tgz",
"_shasum": "336d3a4d4a6a3390d933eeba62e8de4bd280afba",
"_spec": "remark-stringify@^5.0.0",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby-transformer-remark",
"author": {
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "http://wooorm.com"
},
"bugs": {
"url": "https://github.com/remarkjs/remark/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "http://wooorm.com"
},
{
"name": "Eugene Sharygin",
"email": "eush77@gmail.com"
}
],
"dependencies": {
"ccount": "^1.0.0",
"is-alphanumeric": "^1.0.0",
"is-decimal": "^1.0.0",
"is-whitespace-character": "^1.0.0",
"longest-streak": "^2.0.1",
"markdown-escapes": "^1.0.0",
"markdown-table": "^1.1.0",
"mdast-util-compact": "^1.0.0",
"parse-entities": "^1.0.2",
"repeat-string": "^1.5.4",
"state-toggle": "^1.0.0",
"stringify-entities": "^1.0.1",
"unherit": "^1.0.4",
"xtend": "^4.0.1"
},
"deprecated": false,
"description": "Markdown compiler for remark",
"files": [
"index.js",
"lib"
],
"homepage": "http://remark.js.org",
"keywords": [
"markdown",
"abstract",
"syntax",
"tree",
"ast",
"stringify"
],
"license": "MIT",
"name": "remark-stringify",
"repository": {
"type": "git",
"url": "https://github.com/remarkjs/remark/tree/master/packages/remark-stringify"
},
"version": "5.0.0",
"xo": false
}

263
node_modules/remark-stringify/readme.md generated vendored Normal file
View File

@ -0,0 +1,263 @@
# remark-stringify [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]
[Compiler][] for [**unified**][unified]. Stringifies an
[**MDAST**][mdast] syntax tree to markdown. Used in the [**remark**
processor][processor]. Can be [extended][extend] to change how
markdown is compiled.
## Installation
[npm][]:
```sh
npm install remark-stringify
```
## Usage
```js
var unified = require('unified');
var createStream = require('unified-stream');
var parse = require('remark-parse');
var toc = require('remark-toc');
var stringify = require('remark-stringify');
var processor = unified()
.use(parse)
.use(toc)
.use(stringify, {
bullet: '*',
fence: '~',
fences: true,
incrementListMarker: false
});
process.stdin
.pipe(createStream(processor))
.pipe(process.stdout);
```
## Table of Contents
* [API](#api)
* [processor.use(stringify\[, options\])](#processorusestringify-options)
* [stringify.Compiler](#stringifycompiler)
* [Extending the Compiler](#extending-the-compiler)
* [Compiler#visitors](#compilervisitors)
* [function visitor(node\[, parent\])](#function-visitornode-parent)
* [License](#license)
## API
### `processor.use(stringify[, options])`
Configure the `processor` to stringify [**MDAST**][mdast] syntax trees
to markdown.
##### `options`
Options are passed directly, or passed later through [`processor.data()`][data].
###### `options.gfm`
Stringify with the required escapes for GFM compatible markdown (`boolean`,
default: `true`).
* Escape pipes (`|`, for tables)
* Escape colons (`:`, for literal URLs)
* Escape tildes (`~`, for strike-through)
###### `options.commonmark`
Stringify for CommonMark compatible markdown (`boolean`, default: `false`).
* Compile adjacent blockquotes separately
* Escape more characters using slashes, instead of as entities
###### `options.pedantic`
Stringify for pedantic compatible markdown (`boolean`, default: `false`).
* Escape underscores in words
###### `options.entities`
How to stringify entities (`string` or `boolean`, default: `false`):
* `true` — Entities are generated for special HTML characters
(`&` > `&amp;`) and non-ASCII characters (`©` > `&copy;`).
If named entities are not (widely) supported, numbered character
references are used (`` > `&#x2019;`)
* `'numbers'` — Numbered entities are generated (`&` > `&#x26;`)
for special HTML characters and non-ASCII characters
* `'escape'` — Special HTML characters are encoded (`&` >
`&amp;`, `` > `&#x2019;`), non-ASCII characters not (ö persists)
###### `options.setext`
Compile headings, when possible, in Setext-style (`boolean`, default: `false`).
Uses `=` for level one headings and `-` for level two headings. Other heading
levels are compiled as ATX (respecting `closeAtx`).
###### `options.closeAtx`
Compile ATX headings with the same amount of closing hashes as opening hashes
(`boolean`, default: `false`).
###### `options.looseTable`
Create tables without fences: initial and final pipes (`boolean`, default:
`false`).
###### `options.spacedTable`
Create tables without spacing between pipes and content (`boolean`, default:
`true`).
###### `options.paddedTable`
Create tables with padding in each cell so that they are the same size
(`boolean`, default: `true`).
###### `options.stringLength`
Function passed to [`markdown-table`][markdown-table] to detect the length of a
table cell (`Function`, default: [`s => s.length`][string-length]).
###### `options.fence`
Fence marker to use for code blocks (`'~'` or ``'`'``, default: ``'`'``).
###### `options.fences`
Stringify code blocks without language with fences (`boolean`, default:
`false`).
###### `options.bullet`
Bullet marker to use for unordered list items (`'-'`, `'*'`, or `'+'`,
default: `'-'`).
###### `options.listItemIndent`
How to indent the content from list items (`'tab'`, `'mixed'` or `'1'`,
default: `'tab'`).
* `'tab'`: use tab stops (4 spaces)
* `'1'`: use one space
* `'mixed'`: use `1` for tight and `tab` for loose list items
###### `options.incrementListMarker`
Whether to increment ordered list item bullets (`boolean`, default: `true`).
###### `options.rule`
Marker to use for thematic breaks / horizontal rules (`'-'`, `'*'`, or `'_'`,
default: `'*'`).
###### `options.ruleRepetition`
Number of markers to use for thematic breaks / horizontal rules (`number`,
default: `3`). Should be `3` or more.
###### `options.ruleSpaces`
Whether to pad thematic break (horizontal rule) markers with spaces (`boolean`,
default `true`).
###### `options.strong`
Marker to use for importance (`'_'` or `'*'`, default `'*'`).
###### `options.emphasis`
Marker to use for emphasis (`'_'` or `'*'`, default `'_'`).
### `stringify.Compiler`
Access to the raw [compiler][], if you need it.
## Extending the Compiler
If this plugin is used, it adds a [`Compiler`][compiler] constructor
to the `processor`. Other plugins can change and add visitors on
the compilers prototype to change how markdown is stringified.
The below plugin modifies a [visitor][] to add an extra blank line
before level two headings.
```js
module.exports = gap;
function gap() {
var Compiler = this.Compiler;
var visitors = Compiler.prototype.visitors;
var original = visitors.heading;
visitors.heading = function heading(node) {
return (node.depth === 2 ? '\n' : '') + original.apply(this, arguments);
}
}
```
### `Compiler#visitors`
An object mapping [node][] types to [`visitor`][visitor]s.
### `function visitor(node[, parent])`
Stringify `node`.
###### Parameters
* `node` ([`Node`][node]) — Node to compile
* `parent` ([`Node`][node], optional) — Parent of `node`
###### Returns
`string`, the compiled given `node`.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://img.shields.io/travis/remarkjs/remark.svg
[build-status]: https://travis-ci.org/remarkjs/remark
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark.svg
[coverage-status]: https://codecov.io/github/remarkjs/remark
[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg
[chat]: https://gitter.im/remarkjs/Lobby
[license]: https://github.com/remarkjs/remark/blob/master/LICENSE
[author]: http://wooorm.com
[npm]: https://docs.npmjs.com/cli/install
[unified]: https://github.com/unifiedjs/unified
[processor]: https://github.com/remarkjs/remark
[data]: https://github.com/unifiedjs/unified#processordatakey-value
[compiler]: https://github.com/unifiedjs/unified#processorcompiler
[mdast]: https://github.com/syntax-tree/mdast
[node]: https://github.com/syntax-tree/unist#node
[extend]: #extending-the-compiler
[visitor]: #function-visitornode-parent
[markdown-table]: https://github.com/wooorm/markdown-table
[string-length]: https://github.com/wooorm/markdown-table#stringlengthcell