added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 刘祺
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+85
View File
@@ -0,0 +1,85 @@
PostCSS Syntax
====
[![NPM version](https://img.shields.io/npm/v/postcss-syntax.svg?style=flat-square)](https://www.npmjs.com/package/postcss-syntax)
[![Travis](https://img.shields.io/travis/gucong3000/postcss-syntax.svg)](https://travis-ci.org/gucong3000/postcss-syntax)
[![Travis](https://img.shields.io/travis/gucong3000/postcss-syntaxes.svg?label=integration)](https://travis-ci.org/gucong3000/postcss-syntaxes)
[![Codecov](https://img.shields.io/codecov/c/github/gucong3000/postcss-syntax.svg)](https://codecov.io/gh/gucong3000/postcss-syntax)
[![David](https://img.shields.io/david/dev/gucong3000/postcss-syntax.svg)](https://david-dm.org/gucong3000/postcss-syntax?type=dev)
<img align="right" width="95" height="95"
title="Philosopher’s stone, logo of PostCSS"
src="http://postcss.github.io/postcss/logo.svg">
postcss-syntax can automatically switch the required [PostCSS](https://github.com/postcss/postcss) syntax by file extension/source
## Getting Started
First thing's first, install the module:
```
npm install postcss-syntax --save-dev
```
If you want support SCSS/SASS/LESS/SugarSS syntax, you need to install these module:
- SCSS: [postcss-scss](https://github.com/postcss/postcss-scss)
- SASS: [postcss-sass](https://github.com/aleshaoleg/postcss-sass)
- LESS: [postcss-less](https://github.com/shellscape/postcss-less)
- SugarSS: [sugarss](https://github.com/postcss/sugarss)
If you want support HTML (and HTML-like)/Markdown/CSS-in-JS file format, you need to install these module:
- CSS-in-JS: [postcss-jsx](https://github.com/gucong3000/postcss-jsx)
- HTML (and HTML-like): [postcss-html](https://github.com/gucong3000/postcss-html)
- Markdown: [postcss-markdown](https://github.com/gucong3000/postcss-markdown)
## Use Cases
```js
const postcss = require('postcss');
const syntax = require('postcss-syntax')({
rules: [
{
test: /\.(?:[sx]?html?|[sx]ht|vue|ux|php)$/i,
extract: 'html',
},
{
test: /\.(?:markdown|md)$/i,
extract: 'markdown',
},
{
test: /\.(?:m?[jt]sx?|es\d*|pac)$/i,
extract: 'jsx',
},
{
// custom language for file extension
test: /\.postcss$/i,
lang: 'scss'
},
{
// custom language for file extension
test: /\.customcss$/i,
lang: 'custom'
},
],
// custom parser for CSS (using `postcss-safe-parser`)
css: 'postcss-safe-parser',
// custom parser for SASS (PostCSS-compatible syntax.)
sass: require('postcss-sass'),
// custom parser for SCSS (by module name)
scss: 'postcss-scss',
// custom parser for LESS (by module path)
less: './node_modules/postcss-less',
// custom parser for SugarSS
sugarss: require('sugarss'),
// custom parser for custom language
custom: require('postcss-custom-syntax'),
});
postcss(plugins).process(source, { syntax: syntax }).then(function (result) {
// An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
result.content
});
```
+41
View File
@@ -0,0 +1,41 @@
"use strict";
const PostCssRoot = require("postcss/lib/root");
class Document extends PostCssRoot {
toString (stringifier) {
return super.toString(stringifier || {
stringify: require("./stringify"),
});
}
each (callback) {
const result = this.nodes.map(node => node.each(callback));
return result.every(result => result !== false) && result.pop();
}
append () {
this.last.append.apply(
this.last,
Array.from(arguments)
);
return this;
}
prepend () {
this.first.prepend.apply(
this.first,
Array.from(arguments)
);
return this;
}
insertBefore (exist, add) {
exist.prepend(add);
return this;
}
insertAfter (exist, add) {
exist.append(add);
return this;
}
}
module.exports = Document;
+111
View File
@@ -0,0 +1,111 @@
"use strict";
const languages = {
sass: /^sass$/i,
// https://github.com/Microsoft/vscode/blob/master/extensions/scss/package.json
scss: /^scss$/i,
// https://github.com/Microsoft/vscode/blob/master/extensions/less/package.json
less: /^less$/i,
// https://github.com/MhMadHamster/vscode-postcss-language/blob/master/package.json
sugarss: /^s(?:ugar)?ss$/i,
// https://github.com/d4rkr00t/language-stylus/blob/master/package.json
stylus: /^styl(?:us)?$/i,
// WXSS(WeiXin Style Sheets) See: https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxss.html
// acss(AntFinancial Style Sheet) See: https://docs.alipay.com/mini/framework/acss
// `*.pcss`, `*.postcss`
// https://github.com/Microsoft/vscode/blob/master/extensions/css/package.json
// https://github.com/rcsole/postcss-syntax/blob/master/package.json
css: /^(?:wx|\w*c)ss$/i,
};
const extracts = {
// https://github.com/Microsoft/vscode/blob/master/extensions/javascript/package.json
// https://github.com/Microsoft/vscode/blob/master/extensions/typescript-basics/package.json
// https://github.com/michaelgmcd/vscode-language-babel/blob/master/package.json
jsx: /^(?:m?[jt]sx?|es\d*|pac|babel|flow)$/i,
// *.*html? HTML https://github.com/Microsoft/vscode/blob/master/extensions/html/package.json
// *.xslt? XSLT https://msdn.microsoft.com/en-us/library/ms764661(v=vs.85).aspx
// *.vue VUE https://vue-loader.vuejs.org/spec.html
// *.wpy WePY https://github.com/Tencent/wepy/blob/master/docs/md/doc.md#wpy文件说明
// *.ux quickapp https://doc.quickapp.cn/framework/source-file.html
// *.php* PHP https://github.com/Microsoft/vscode/blob/master/extensions/php/package.json
// *.twig Twig https://github.com/mblode/vscode-twig-language/blob/master/package.json
// *.liquid Liquid https://github.com/GingerBear/vscode-liquid/blob/master/package.json
// *.svelte Svelte https://github.com/UnwrittenFun/svelte-vscode/blob/master/package.json
html: /^(?:\w*html?|xht|xslt?|mdoc|jsp|aspx?|volt|ejs|vue|wpy|ux|php\d*|ctp|twig|liquid|svelte)$/i,
// https://github.com/Microsoft/vscode/blob/master/extensions/markdown-basics/package.json
markdown: /^(?:m(?:ark)?d(?:ow)?n|mk?d)$/i,
// https://github.com/Microsoft/vscode/blob/master/extensions/xml/package.json
xml: /^(?:xml|xsd|ascx|atom|axml|bpmn|config|cpt|csl|csproj|csproj|user|dita|ditamap|dtd|dtml|fsproj|fxml|iml|isml|jmx|launch|menu|mxml|nuspec|opml|owl|proj|props|pt|publishsettings|pubxml|pubxml|user|rdf|rng|rss|shproj|storyboard|svg|targets|tld|tmx|vbproj|vbproj|user|vcxproj|vcxproj|filters|wsdl|wxi|wxl|wxs|xaml|xbl|xib|xlf|xliff|xpdl|xul|xoml)$/i,
};
function sourceType (source) {
source = source && source.trim();
if (!source) {
return;
}
let extract;
if (
// start with strict mode
// start with import code
// start with require code
/^(?:(?:\/\/[^\r\n]*\r?\n|\/\*.*?\*\/)\s*)*(?:(?:("|')use strict\1|import(?:\s+[^;]+\s+from)?\s+("|')[^'"]+?\2|export\s+[^;]+\s+[^;]+)\s*(;|\r?\n|$)|(?:(?:var|let|const)\s+[^;]+\s*=\s*)?(?:require|import)\(.+\))/.test(source) ||
// https://en.wikipedia.org/wiki/Shebang_(Unix)
(/^#!([^\r\n]+)/.test(source) && /(?:^|\s+|\/)(?:ts-)?node(?:\.\w+)?(?:\s+|$)$/.test(RegExp.$1))
) {
extract = "jsx";
} else if (
/^(?:<\?.*?\?>\s*)*<(?:!DOCTYPE\s+)?html(\s+[^<>]*)?>/i.test(source) ||
/^<\?php(?:\s+[\s\S]*)?(?:\?>|$)/.test(source)
) {
extract = "html";
} else if (/^<\?xml(\s+[^<>]*)?\?>/i.test(source)) {
// https://msdn.microsoft.com/en-us/library/ms764661(v=vs.85).aspx
if (/<xsl:\w+\b[^<>]*>/.test(source) || /<\/xsl:\w+>/i.test(source)) {
extract = "html";
} else {
extract = "xml";
}
} else if (/^(?:#+\s+\S+|\S+[^\r\n]*\r?\n=+(\r?\n|$))/.test(source)) {
extract = "markdown";
} else if (/<(\w+)(?:\s+[^<>]*)?>[\s\S]*?<\/\1>/.test(source)) {
extract = "html";
} else {
return;
}
return {
extract,
};
}
function extType (extName, languages) {
for (const langName in languages) {
if (languages[langName].test(extName)) {
return langName;
}
}
}
function fileType (file) {
if (file && /\.(\w+)(?:[?#].*?)?$/.test(file)) {
const extName = RegExp.$1;
const extract = extType(extName, extracts);
if (extract) {
return {
extract,
};
}
const lang = extType(extName, languages);
if (lang) {
return {
lang,
};
}
}
}
function getLang (file, source) {
return fileType(file) || sourceType(source);
}
module.exports = getLang;
+63
View File
@@ -0,0 +1,63 @@
"use strict";
const path = require("path");
const reSyntaxCSS = /^(?:post)?css$/i;
function cssSyntax () {
return {
stringify: require("postcss/lib/stringify"),
parse: require("postcss/lib/parse"),
};
}
function normalize (syntax) {
if (!syntax.parse) {
syntax = {
parse: syntax,
};
}
return syntax;
}
function requireSyntax (syntax) {
if (reSyntaxCSS.test(syntax)) {
return cssSyntax();
} else if (/^sugarss$/i.test(syntax)) {
syntax = "sugarss";
} else if (path.isAbsolute(syntax) || syntax[0] === ".") {
syntax = path.resolve(syntax);
} else {
syntax = syntax.toLowerCase().replace(/^(?:postcss-)?(\w+)/i, "postcss-$1");
}
return normalize(require(syntax));
}
function getSyntax (lang, opts) {
let syntax;
lang = lang || "css";
if (opts.syntax.config[lang]) {
syntax = opts.syntax.config[lang];
if (typeof syntax === "string") {
if (syntax !== lang && opts.syntax.config[syntax]) {
return getSyntax(syntax, opts);
}
syntax = requireSyntax(syntax);
} else {
syntax = normalize(syntax);
}
} else if (reSyntaxCSS.test(lang)) {
syntax = cssSyntax();
} else {
return requireSyntax(lang);
}
if (!syntax.stringify) {
if (reSyntaxCSS.test(lang)) {
syntax.stringify = require("postcss/lib/stringify");
} else {
syntax.stringify = getSyntax(null, opts).stringify;
}
}
opts.syntax.config[lang] = syntax;
return syntax;
}
module.exports = getSyntax;
+26
View File
@@ -0,0 +1,26 @@
"use strict";
const stringify = require("./stringify");
const parse = require("./parse");
const defaultConfig = {
postcss: "css",
stylus: "css",
babel: "jsx",
xml: "html",
};
function initSyntax (syntax) {
syntax.stringify = stringify.bind(syntax);
syntax.parse = parse.bind(syntax);
return syntax;
}
function syntax (config) {
return initSyntax({
config: Object.assign({}, defaultConfig, config),
});
}
initSyntax(syntax);
syntax.config = defaultConfig;
module.exports = syntax;
+23
View File
@@ -0,0 +1,23 @@
"use strict";
const getSyntax = require("./get-syntax");
const cache = {};
function loadSyntax (opts, id) {
const cssSyntax = getSyntax("css", opts);
const modulePath = id + "/template-" + (cssSyntax.parse.name === "safeParse" ? "safe-" : "") + "parse";
let syntax = cache[modulePath];
if (!syntax) {
syntax = {
parse: require(modulePath),
};
try {
syntax.stringify = require(id + "/template-stringify");
} catch (ex) {
syntax.stringify = cssSyntax.stringify;
}
cache[modulePath] = syntax;
}
return syntax;
}
module.exports = loadSyntax;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
function normalOpts (opts, syntax) {
if (!opts) {
opts = {};
}
opts.syntax = syntax;
return opts;
}
module.exports = normalOpts;
+133
View File
@@ -0,0 +1,133 @@
{
"_args": [
[
"postcss-syntax@0.36.2",
"/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror"
]
],
"_development": true,
"_from": "postcss-syntax@0.36.2",
"_id": "postcss-syntax@0.36.2",
"_inBundle": false,
"_integrity": "sha512-nBRg/i7E3SOHWxF3PpF5WnJM/jQ1YpY9000OaVXlAQj6Zp/kIqJxEDWIZ67tAd7NLuk7zqN4yqe9nc0oNAOs1w==",
"_location": "/postcss-syntax",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-syntax@0.36.2",
"name": "postcss-syntax",
"escapedName": "postcss-syntax",
"rawSpec": "0.36.2",
"saveSpec": null,
"fetchSpec": "0.36.2"
},
"_requiredBy": [
"/stylelint"
],
"_resolved": "https://registry.npmjs.org/postcss-syntax/-/postcss-syntax-0.36.2.tgz",
"_spec": "0.36.2",
"_where": "/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror",
"author": {
"name": "gucong"
},
"bugs": {
"url": "https://github.com/gucong3000/postcss-syntax/issues"
},
"description": "Automatically switch PostCSS syntax by file extensions",
"devDependencies": {
"chai": "^4.2.0",
"codecov": "^3.1.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"postcss": "^7.0.7",
"postcss-html": ">=0.36.0",
"postcss-jsx": ">=0.36.0",
"postcss-less": "^3.1.0",
"postcss-markdown": ">=0.36.0",
"postcss-safe-parser": "^4.0.1",
"postcss-scss": "^2.0.0",
"proxyquire": "^2.1.0",
"sugarss": "^2.0.0"
},
"extensions": [
".css",
".pcss",
".postcss",
".acss",
".wxss",
".sass",
".scss",
".less",
".sss",
".js",
".es6",
".mjs",
".pac",
".jsx",
".ts",
".tsx",
".babel",
".flow",
".html",
".htm",
".shtml",
".xhtml",
".mdoc",
".jsp",
".asp",
".aspx",
".jshtm",
".volt",
".ejs",
".rhtml",
".xsl",
".xslt",
".vue",
".wpy",
".ux",
".php",
".php4",
".php5",
".phtml",
".ctp",
".twig",
".liquid",
".md",
".mdown",
".markdown",
".markdn",
".svelte"
],
"homepage": "https://github.com/gucong3000/postcss-syntax#readme",
"keywords": [
"postcss",
"syntax",
"switch",
"extension"
],
"license": "MIT",
"name": "postcss-syntax",
"nyc": {
"reporter": [
"lcov",
"text"
],
"all": true,
"cache": true,
"check-coverage": true
},
"peerDependencies": {
"postcss": ">=5.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gucong3000/postcss-syntax.git"
},
"scripts": {
"debug": "npm run mocha -- --inspect-brk",
"mocha": "mocha --require ./test/fixtures/link --no-timeouts",
"test": "nyc npm run mocha"
},
"version": "0.36.2"
}
+127
View File
@@ -0,0 +1,127 @@
"use strict";
const reNewLine = /(?:\r?\n|\r)/gm;
const Input = require("postcss/lib/input");
const Document = require("./document");
const getSyntax = require("./get-syntax");
const patch = require("./patch-postcss");
class LocalFixer {
constructor (lines, style) {
let line = 0;
let column = style.startIndex;
lines.some((lineEndIndex, lineNumber) => {
if (lineEndIndex >= style.startIndex) {
line = lineNumber--;
if (lineNumber in lines) {
column = style.startIndex - lines[lineNumber] - 1;
}
return true;
}
});
this.line = line;
this.column = column;
this.style = style;
}
object (object) {
if (object) {
if (object.line === 1) {
object.column += this.column;
}
object.line += this.line;
}
}
node (node) {
this.object(node.source.start);
this.object(node.source.end);
}
root (root) {
this.node(root);
root.walk(node => {
this.node(node);
});
}
error (error) {
if (error && error.name === "CssSyntaxError") {
this.object(error);
this.object(error.input);
error.message = error.message.replace(/:\d+:\d+:/, ":" + error.line + ":" + error.column + ":");
}
return error;
}
parse (opts) {
const style = this.style;
const syntax = style.syntax || getSyntax(style.lang, opts);
let root = style.root;
try {
root = syntax.parse(style.content, Object.assign({}, opts, {
map: false,
}, style.opts));
} catch (error) {
if (style.ignoreErrors) {
return;
} else if (!style.skipConvert) {
this.error(error);
}
throw error;
}
if (!style.skipConvert) {
this.root(root);
}
root.source.inline = Boolean(style.inline);
root.source.lang = style.lang;
root.source.syntax = syntax;
return root;
}
}
function docFixer (source, opts) {
let match;
const lines = [];
reNewLine.lastIndex = 0;
while ((match = reNewLine.exec(source))) {
lines.push(match.index);
}
lines.push(source.length);
return function parseStyle (style) {
return new LocalFixer(lines, style).parse(opts);
};
}
function parseStyle (source, opts, styles) {
patch(Document);
const document = new Document();
let index = 0;
if (styles.length) {
const parseStyle = docFixer(source, opts);
styles.sort((a, b) => (
a.startIndex - b.startIndex
)).forEach(style => {
const root = parseStyle(style);
if (root) {
root.raws.beforeStart = source.slice(index, style.startIndex);
if (style.endIndex) {
index = style.endIndex;
} else {
index = style.startIndex + (style.content || root.source.input.css).length;
}
root.document = document;
document.nodes.push(root);
}
});
}
document.raws.afterEnd = index ? source.slice(index) : source;
document.source = {
input: new Input(source, opts),
start: {
line: 1,
column: 1,
},
opts,
};
return document;
}
module.exports = parseStyle;
+34
View File
@@ -0,0 +1,34 @@
"use strict";
const parser = require("./parser");
const processor = require("./processor");
const getLang = require("./get-lang");
const normalOpts = require("./normal-opts");
function getSyntax (opts, source) {
const rules = opts.syntax && opts.syntax.config && opts.syntax.config.rules;
const file = opts.from || "";
return (rules && rules.find(
rule => rule.test.test ? rule.test.test(file) : rule.test(file, source)
)) || getLang(file, source) || {
lang: "css",
};
}
function parse (source, opts) {
source = source.toString();
opts = normalOpts(opts, this);
const syntax = getSyntax(opts, source);
const syntaxOpts = Object.assign({}, opts, syntax.opts);
let root;
if (syntax.extract) {
root = processor(source, syntax.extract, syntaxOpts);
root.source.lang = syntax.extract;
} else {
root = parser(source, syntax.lang, syntaxOpts);
root.source.lang = syntax.lang;
}
return root;
}
module.exports = parse;
+18
View File
@@ -0,0 +1,18 @@
"use strict";
const getSyntax = require("./get-syntax");
const patch = require("./patch-postcss");
function parser (source, lang, opts) {
patch();
const syntax = getSyntax(lang, opts);
const root = syntax.parse(source, opts);
root.source.syntax = syntax;
root.source.lang = lang;
return root;
}
module.exports = parser;
+77
View File
@@ -0,0 +1,77 @@
"use strict";
const path = require("path");
const patched = {};
function isPromise (obj) {
return typeof obj === "object" && typeof obj.then === "function";
}
function runDocument (plugin) {
const result = this.result;
result.lastPlugin = plugin;
const promise = result.root.nodes.map(root => {
try {
return plugin(root, result);
} catch (error) {
this.handleError(error, plugin);
throw error;
}
});
if (promise.some(isPromise)) {
return Promise.all(promise);
}
}
function patchDocument (Document, LazyResult) {
LazyResult = LazyResult.prototype;
const runRoot = LazyResult.run;
LazyResult.run = function run () {
return (this.result.root instanceof Document ? runDocument : runRoot).apply(this, arguments);
};
}
function patchNode (Node) {
Node = Node.prototype;
const NodeToString = Node.toString;
Node.toString = function toString (stringifier) {
return NodeToString.call(this, stringifier || this.root().source.syntax);
};
}
function patch (Document) {
let fn;
let file;
if (Document) {
patch();
fn = patchDocument.bind(this, Document);
file = "lazy-result";
} else {
fn = patchNode;
file = "node";
}
findPostcss().map(dir => (
[dir + "lib", file].join(path.sep)
)).filter(file => (
!patched[file]
)).forEach(file => {
try {
fn(require(file));
} catch (ex) {
//
}
patched[file] = true;
});
}
function findPostcss () {
const result = {};
for (const file in require.cache) {
if (/^(.+?(\\|\/))postcss(\2)/.test(file)) {
result[RegExp.lastMatch] = true;
}
}
return Object.keys(result);
}
module.exports = patch;
+29
View File
@@ -0,0 +1,29 @@
"use strict";
const parseStyle = require("./parse-style");
function getSyntax (config, syntax) {
if (typeof syntax !== "string") {
return syntax;
}
let syntaxConfig = config[syntax];
if (syntaxConfig) {
syntaxConfig = getSyntax(config, syntaxConfig);
} else {
syntaxConfig = {
extract: require(syntax.toLowerCase().replace(/^(postcss-)?/i, "postcss-") + "/extract"),
};
config[syntax] = syntaxConfig;
}
return syntaxConfig;
}
function processor (source, lang, opts) {
const syntax = getSyntax(opts.syntax.config, lang);
const styles = (syntax.extract || syntax)(source, opts) || [];
return parseStyle(source, opts, styles);
}
module.exports = processor;
+20
View File
@@ -0,0 +1,20 @@
"use strict";
function stringify (document) {
let stringify;
if (document instanceof require("./document")) {
stringify = docStringify;
} else {
stringify = document.source.syntax.stringify;
}
return stringify.apply(this, arguments);
}
function docStringify (document, builder) {
document.nodes.forEach((root, i) => {
builder(root.raws.beforeStart, root, "beforeStart");
root.source.syntax && root.source.syntax.stringify(root, builder);
});
builder(document.raws.afterEnd, document, "afterEnd");
}
module.exports = stringify;
+37
View File
@@ -0,0 +1,37 @@
"use strict";
const stringify = require("./stringify");
const parseStyle = require("./parse-style");
const normalOpts = require("./normal-opts");
module.exports = (extract, lang) => {
const defaultConfig = {
postcss: "css",
stylus: "css",
babel: "jsx",
xml: "html",
};
function parse (source, opts) {
source = source.toString();
opts = normalOpts(opts, this);
const document = parseStyle(source, opts, extract(source, opts));
document.source.lang = lang;
return document;
}
function initSyntax (syntax) {
syntax.stringify = stringify.bind(syntax);
syntax.parse = parse.bind(syntax);
syntax.extract = extract.bind(syntax);
return syntax;
}
function syntax (config) {
return initSyntax({
config: Object.assign({}, defaultConfig, config),
});
}
initSyntax(syntax);
syntax.config = defaultConfig;
return syntax;
};