├── .gitignore
├── .npmignore
├── .travis.yml
├── LICENSE
├── README.md
├── extract.js
├── index.js
├── package.json
├── template-parse.js
├── template-parser.js
├── template-safe-parse.js
├── template-safe-parser.js
├── template-tokenize.js
└── test
├── comment.js
├── html.js
├── index.js
├── interpolation.js
├── safe-parser.js
├── vue.js
└── xslt.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/node
2 |
3 | ### Node ###
4 | # Logs
5 | logs
6 | *.log
7 | npm-debug.log*
8 | yarn-debug.log*
9 | yarn-error.log*
10 |
11 | # Runtime data
12 | pids
13 | *.pid
14 | *.seed
15 | *.pid.lock
16 |
17 | # Directory for instrumented libs generated by jscoverage/JSCover
18 | lib-cov
19 |
20 | # Coverage directory used by tools like istanbul
21 | coverage
22 |
23 | # nyc test coverage
24 | .nyc_output
25 |
26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27 | .grunt
28 |
29 | # Bower dependency directory (https://bower.io/)
30 | bower_components
31 |
32 | # node-waf configuration
33 | .lock-wscript
34 |
35 | # Compiled binary addons (http://nodejs.org/api/addons.html)
36 | build/Release
37 |
38 | # Dependency directories
39 | node_modules/
40 | jspm_packages/
41 |
42 | # Typescript v1 declaration files
43 | typings/
44 |
45 | # Optional npm cache directory
46 | .npm
47 |
48 | # Optional eslint cache
49 | .eslintcache
50 |
51 | # Optional REPL history
52 | .node_repl_history
53 |
54 | # Output of 'npm pack'
55 | *.tgz
56 |
57 | # Yarn Integrity file
58 | .yarn-integrity
59 |
60 | # dotenv environment variables file
61 | .env
62 |
63 |
64 |
65 | # End of https://www.gitignore.io/api/node
66 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | *.log
2 | *.pid
3 | *.seed
4 | .editorconfig
5 | .eslintrc*
6 | .git
7 | .gitignore
8 | .grunt
9 | .lock-wscript
10 | .node_repl_history
11 | .nyc_output
12 | .stylelintrc*
13 | .travis.yml
14 | .vscode
15 | appveyor.yml
16 | coverage
17 | gulpfile.js
18 | lib-cov
19 | logs
20 | node_modules
21 | npm-debug.log*
22 | pids
23 | test
24 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: trusty
2 | sudo: false
3 | language: node_js
4 |
5 | node_js:
6 | - stable
7 |
8 | before_install:
9 | - curl -s https://raw.githubusercontent.com/gucong3000/postcss-syntaxes/HEAD/deps.js | node
10 |
11 | after_script:
12 | - codecov
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 刘祺
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | PostCSS HTML Syntax
2 | ====
3 |
4 | [](https://www.npmjs.com/package/postcss-html)
5 | [](https://travis-ci.org/gucong3000/postcss-html)
6 | [](https://travis-ci.org/gucong3000/postcss-syntaxes)
7 | [](https://codecov.io/gh/gucong3000/postcss-html)
8 | [](https://david-dm.org/gucong3000/postcss-html)
9 |
10 |
13 |
14 | [PostCSS](https://github.com/postcss/postcss) syntax for parsing HTML (and HTML-like)
15 | - [PHP](http://php.net)
16 | - [Vue Single-File Component](https://vue-loader.vuejs.org/spec.html)
17 | - [Quick App](https://doc.quickapp.cn/framework/source-file.html)
18 | - [XSLT](https://www.w3.org/TR/xslt-30/)
19 |
20 | ## Getting Started
21 |
22 | First thing's first, install the module:
23 |
24 | ```
25 | npm install postcss-syntax postcss-html --save-dev
26 | ```
27 |
28 | If you want support SCSS/SASS/LESS/SugarSS syntax, you need to install the corresponding module.
29 |
30 | - SCSS: [postcss-scss](https://github.com/postcss/postcss-scss)
31 | - SASS: [postcss-sass](https://github.com/aleshaoleg/postcss-sass)
32 | - LESS: [postcss-less](https://github.com/shellscape/postcss-less)
33 | - SugarSS: [sugarss](https://github.com/postcss/sugarss)
34 |
35 | ## Use Cases
36 |
37 | ```js
38 | const postcss = require('postcss');
39 | const syntax = require('postcss-html')({
40 | // syntax for parse scss (non-required options)
41 | scss: require('postcss-scss'),
42 | // syntax for parse less (non-required options)
43 | less: require('postcss-less'),
44 | // syntax for parse css blocks (non-required options)
45 | css: require('postcss-safe-parser'),
46 | });
47 | postcss(plugins).process(source, { syntax: syntax }).then(function (result) {
48 | // An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
49 | result.content
50 | });
51 | ```
52 |
53 | If you want support SCSS/SASS/LESS/SugarSS syntax, you need to install these module:
54 |
55 | - SCSS: [postcss-scss](https://github.com/postcss/postcss-scss)
56 | - SASS: [postcss-sass](https://github.com/aleshaoleg/postcss-sass)
57 | - LESS: [postcss-less](https://github.com/shellscape/postcss-less)
58 | - SugarSS: [sugarss](https://github.com/postcss/sugarss)
59 |
60 | ## Advanced Use Cases
61 |
62 | See: [postcss-syntax](https://github.com/gucong3000/postcss-syntax)
63 |
64 | ## Turning PostCSS off from within your HTML
65 |
66 | PostCSS can be temporarily turned off by using special comments in your HTML. For example:
67 |
68 | ```html
69 |
70 |