This commit is contained in:
eric sciple 2020-01-24 12:20:19 -05:00
parent beb1329f9f
commit 2b95e76931
7736 changed files with 1874747 additions and 51184 deletions

View file

@ -0,0 +1,8 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export default function escapeHTML(str: string): string;
//# sourceMappingURL=escapeHTML.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"escapeHTML.d.ts","sourceRoot":"","sources":["../../../src/plugins/lib/escapeHTML.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD"}

View file

@ -0,0 +1,16 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = escapeHTML;
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function escapeHTML(str) {
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

View file

@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config, Printer } from '../../types';
export declare const printProps: (keys: string[], props: any, config: Config, indentation: string, depth: number, refs: any[], printer: Printer) => string;
export declare const printChildren: (children: any[], config: Config, indentation: string, depth: number, refs: any[], printer: Printer) => string;
export declare const printText: (text: string, config: Config) => string;
export declare const printComment: (comment: string, config: Config) => string;
export declare const printElement: (type: string, printedProps: string, printedChildren: string, config: Config, indentation: string) => string;
export declare const printElementAsLeaf: (type: string, config: Config) => string;
//# sourceMappingURL=markup.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"markup.d.ts","sourceRoot":"","sources":["../../../src/plugins/lib/markup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAE,OAAO,EAAO,MAAM,aAAa,CAAC;AAKlD,eAAO,MAAM,UAAU,2HAyCtB,CAAC;AAGF,eAAO,MAAM,aAAa,gHAiBb,CAAC;AAEd,eAAO,MAAM,SAAS,0CAGrB,CAAC;AAEF,eAAO,MAAM,YAAY,6CASxB,CAAC;AAMF,eAAO,MAAM,YAAY,8GA+BxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,0CAY9B,CAAC"}

147
node_modules/pretty-format/build/plugins/lib/markup.js generated vendored Normal file
View file

@ -0,0 +1,147 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = void 0;
var _escapeHTML = _interopRequireDefault(require('./escapeHTML'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Return empty string if keys is empty.
const printProps = (keys, props, config, indentation, depth, refs, printer) => {
const indentationNext = indentation + config.indent;
const colors = config.colors;
return keys
.map(key => {
const value = props[key];
let printed = printer(value, config, indentationNext, depth, refs);
if (typeof value !== 'string') {
if (printed.indexOf('\n') !== -1) {
printed =
config.spacingOuter +
indentationNext +
printed +
config.spacingOuter +
indentation;
}
printed = '{' + printed + '}';
}
return (
config.spacingInner +
indentation +
colors.prop.open +
key +
colors.prop.close +
'=' +
colors.value.open +
printed +
colors.value.close
);
})
.join('');
}; // Return empty string if children is empty.
exports.printProps = printProps;
const printChildren = (children, config, indentation, depth, refs, printer) =>
children
.map(
child =>
config.spacingOuter +
indentation +
(typeof child === 'string'
? printText(child, config)
: printer(child, config, indentation, depth, refs))
)
.join('');
exports.printChildren = printChildren;
const printText = (text, config) => {
const contentColor = config.colors.content;
return (
contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
);
};
exports.printText = printText;
const printComment = (comment, config) => {
const commentColor = config.colors.comment;
return (
commentColor.open +
'<!--' +
(0, _escapeHTML.default)(comment) +
'-->' +
commentColor.close
);
}; // Separate the functions to format props, children, and element,
// so a plugin could override a particular function, if needed.
// Too bad, so sad: the traditional (but unnecessary) space
// in a self-closing tagColor requires a second test of printedProps.
exports.printComment = printComment;
const printElement = (
type,
printedProps,
printedChildren,
config,
indentation
) => {
const tagColor = config.colors.tag;
return (
tagColor.open +
'<' +
type +
(printedProps &&
tagColor.close +
printedProps +
config.spacingOuter +
indentation +
tagColor.open) +
(printedChildren
? '>' +
tagColor.close +
printedChildren +
config.spacingOuter +
indentation +
tagColor.open +
'</' +
type
: (printedProps && !config.min ? '' : ' ') + '/') +
'>' +
tagColor.close
);
};
exports.printElement = printElement;
const printElementAsLeaf = (type, config) => {
const tagColor = config.colors.tag;
return (
tagColor.open +
'<' +
type +
tagColor.close +
' …' +
tagColor.open +
' />' +
tagColor.close
);
};
exports.printElementAsLeaf = printElementAsLeaf;