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.
+78
View File
@@ -0,0 +1,78 @@
PostCSS HTML Syntax
====
[![NPM version](https://img.shields.io/npm/v/postcss-html.svg?style=flat-square)](https://www.npmjs.com/package/postcss-html)
[![Travis](https://img.shields.io/travis/gucong3000/postcss-html.svg)](https://travis-ci.org/gucong3000/postcss-html)
[![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-html.svg)](https://codecov.io/gh/gucong3000/postcss-html)
[![David](https://img.shields.io/david/gucong3000/postcss-html.svg)](https://david-dm.org/gucong3000/postcss-html)
<img align="right" width="95" height="95"
title="Philosopher’s stone, logo of PostCSS"
src="http://postcss.github.io/postcss/logo.svg">
[PostCSS](https://github.com/postcss/postcss) syntax for parsing HTML (and HTML-like)
- [PHP](http://php.net)
- [Vue Single-File Component](https://vue-loader.vuejs.org/spec.html)
- [Quick App](https://doc.quickapp.cn/framework/source-file.html)
- [XSLT](https://www.w3.org/TR/xslt-30/)
## Getting Started
First thing's first, install the module:
```
npm install postcss-syntax postcss-html --save-dev
```
If you want support SCSS/SASS/LESS/SugarSS syntax, you need to install the corresponding 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)
## Use Cases
```js
const postcss = require('postcss');
const syntax = require('postcss-html')({
// syntax for parse scss (non-required options)
scss: require('postcss-scss'),
// syntax for parse less (non-required options)
less: require('postcss-less'),
// syntax for parse css blocks (non-required options)
css: require('postcss-safe-parser'),
});
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
});
```
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)
## Advanced Use Cases
See: [postcss-syntax](https://github.com/gucong3000/postcss-syntax)
## Turning PostCSS off from within your HTML
PostCSS can be temporarily turned off by using special comments in your HTML. For example:
```html
<html>
<body>
<!-- postcss-disable -->
<a style="color: red;"></a>
<!-- postcss-enable -->
```
## Style Transformations
The main use case of this plugin is to apply PostCSS transformations to `<style>` tags and `<div style="*">` property in HTML (and HTML-like).
+122
View File
@@ -0,0 +1,122 @@
"use strict";
const htmlparser = require("htmlparser2");
const loadSyntax = require("postcss-syntax/load-syntax");
function iterateCode (source, onStyleTag, onStyleAttribute) {
const openTag = {};
let disable;
let style;
const parser = new htmlparser.Parser({
oncomment: (data) => {
if (!/(?:^|\s+)postcss-(\w+)(?:\s+|$)/i.test(data)) {
return;
}
data = RegExp.$1.toLowerCase();
if (data === "enable") {
disable = false;
} else if (data === "disable") {
disable = true;
}
},
onopentag (name, attribute) {
openTag[name] = true;
// Test if current tag is a valid <style> tag.
if (!/^style$/i.test(name)) {
return;
}
style = {
inXsls: openTag["xsl:stylesheet"],
inXslt: openTag["xsl:template"],
inHtml: openTag.html,
tagName: name,
attribute,
startIndex: parser.endIndex + 1,
};
},
onclosetag (name) {
openTag[name] = false;
if (disable || !style || name !== style.tagName) {
return;
}
let content = source.slice(style.startIndex, parser.startIndex);
const firstNewLine = /^[ \t]*\r?\n/.exec(content);
if (firstNewLine) {
const offset = firstNewLine[0].length;
style.startIndex += offset;
content = content.slice(offset);
}
style.content = content.replace(/[ \t]*$/, "");
onStyleTag(style);
style = null;
},
onattribute (name, content) {
if (disable || name !== "style") {
return;
}
const endIndex = parser._tokenizer._index;
const startIndex = endIndex - content.length;
if (source[startIndex - 1] !== source[endIndex] || !/\S/.test(source[endIndex])) {
return;
}
onStyleAttribute({
content,
startIndex,
inline: true,
inTemplate: openTag.template,
});
},
});
parser.parseComplete(source);
}
function getSubString (str, regexp) {
const subStr = str && regexp.exec(str);
if (subStr) {
return subStr[1].toLowerCase();
}
}
function getLang (attribute) {
return getSubString(attribute.type, /^\w+\/(?:x-)?(\w+)$/i) || getSubString(attribute.lang, /^(\w+)(?:\?.+)?$/) || "css";
}
function htmlParser (source, opts, styles) {
styles = styles || [];
const standard = opts.from && /\.(?:\w*html?|xht|xslt?|jsp|aspx?|ejs|php\d*|twig|liquid|m(?:ark)?d(?:ow)?n|mk?d)$/i.test(opts.from);
function onStyleTag (style) {
if (!(style.inHtml || style.inXsls || style.inXslt || standard) && (style.attribute.src || style.attribute.href) && !style.content.trim()) {
return;
}
style.lang = getLang(style.attribute);
styles.push(style);
}
function onStyleAttribute (style) {
if (/{[\s\S]*?}/g.test(style.content)) {
style.syntax = loadSyntax(opts, __dirname);
style.lang = "custom-template";
} else {
// style.ignoreErrors = opts.from && /\.(?:jsp|aspx?|ejs|php\d*|twig)$/i.test(opts.from);
style.lang = "css";
}
styles.push(style);
}
iterateCode(source, onStyleTag, onStyleAttribute);
return styles;
}
module.exports = htmlParser;
+5
View File
@@ -0,0 +1,5 @@
"use strict";
const extract = require("./extract");
const syntax = require("postcss-syntax/syntax")(extract, "html");
module.exports = syntax;
+94
View File
@@ -0,0 +1,94 @@
{
"_args": [
[
"postcss-html@0.36.0",
"/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror"
]
],
"_development": true,
"_from": "postcss-html@0.36.0",
"_id": "postcss-html@0.36.0",
"_inBundle": false,
"_integrity": "sha512-HeiOxGcuwID0AFsNAL0ox3mW6MHH5cstWN1Z3Y+n6H+g12ih7LHdYxWwEA/QmrebctLjo79xz9ouK3MroHwOJw==",
"_location": "/postcss-html",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-html@0.36.0",
"name": "postcss-html",
"escapedName": "postcss-html",
"rawSpec": "0.36.0",
"saveSpec": null,
"fetchSpec": "0.36.0"
},
"_requiredBy": [
"/stylelint"
],
"_resolved": "https://registry.npmjs.org/postcss-html/-/postcss-html-0.36.0.tgz",
"_spec": "0.36.0",
"_where": "/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror",
"author": {
"name": "gucong"
},
"bugs": {
"url": "https://github.com/gucong3000/postcss-html/issues"
},
"dependencies": {
"htmlparser2": "^3.10.0"
},
"description": "PostCSS syntax for parsing HTML (and HTML-like)",
"devDependencies": {
"autoprefixer": "^9.4.3",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"postcss": "^7.0.7",
"postcss-less": "^3.1.0",
"postcss-safe-parser": "^4.0.1",
"postcss-scss": "^2.0.0",
"postcss-syntax": ">=0.36.0",
"sugarss": "^2.0.0"
},
"homepage": "https://github.com/gucong3000/postcss-html#readme",
"keywords": [
"postcss",
"syntax",
"html",
"vue",
"quickapp",
"PHP",
"css",
"less",
"sass",
"scss",
"sss",
"sugarss"
],
"license": "MIT",
"name": "postcss-html",
"nyc": {
"reporter": [
"lcov",
"text"
],
"all": true,
"cache": true,
"check-coverage": true
},
"peerDependencies": {
"postcss": ">=5.0.0",
"postcss-syntax": ">=0.36.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gucong3000/postcss-html.git"
},
"scripts": {
"debug": "npm run mocha -- --inspect-brk",
"mocha": "mocha --no-timeouts",
"test": "nyc npm run mocha"
},
"version": "0.36.0"
}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
const TemplateParser = require("./template-parser");
const Input = require("postcss/lib/input");
function templateParse (css, opts) {
const input = new Input(css, opts);
const parser = new TemplateParser(input);
parser.parse();
return parser.root;
}
module.exports = templateParse;
+9
View File
@@ -0,0 +1,9 @@
"use strict";
const Parser = require("postcss/lib/parser");
const templateTokenize = require("./template-tokenize");
class TemplateParser extends Parser {
createTokenizer () {
this.tokenizer = templateTokenize(this.input);
}
}
module.exports = TemplateParser;
+14
View File
@@ -0,0 +1,14 @@
"use strict";
const TemplateSafeParser = require("./template-safe-parser");
const Input = require("postcss/lib/input");
function templateSafeParse (css, opts) {
const input = new Input(css, opts);
const parser = new TemplateSafeParser(input);
parser.parse();
return parser.root;
}
module.exports = templateSafeParse;
+9
View File
@@ -0,0 +1,9 @@
"use strict";
const SafeParser = require("postcss-safe-parser/lib/safe-parser");
const templateTokenize = require("./template-tokenize");
class TemplateSafeParser extends SafeParser {
createTokenizer () {
this.tokenizer = templateTokenize(this.input, { ignoreErrors: true });
}
}
module.exports = TemplateSafeParser;
+49
View File
@@ -0,0 +1,49 @@
"use strict";
const tokenize = require("postcss/lib/tokenize");
function templateTokenize () {
const tokenizer = tokenize.apply(this, arguments);
function nextToken () {
const args = arguments;
const returned = [];
let token;
let depth = 0;
let line;
let column;
while ((token = tokenizer.nextToken.apply(tokenizer, args))) {
if (token[0] !== "word") {
if (token[0] === "{") {
++depth;
} else if (token[0] === "}") {
--depth;
}
}
if (depth || returned.length) {
line = token[4] || token[2] || line;
column = token[5] || token[3] || column;
returned.push(token);
}
if (!depth) {
break;
}
}
if (returned.length) {
token = [
"word",
returned.map(token => token[1]).join(""),
returned[0][2],
returned[0][3],
line,
column,
];
}
return token;
}
return Object.assign({}, tokenizer, {
nextToken,
});
}
module.exports = templateTokenize;