flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
432
BACK_BACK/node_modules/posthtml/CHANGELOG.md
generated
vendored
Executable file
432
BACK_BACK/node_modules/posthtml/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,432 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.11.6](https://github.com/posthtml/posthtml/compare/v0.11.5...v0.11.6) (2019-08-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* typings ([97d89ad](https://github.com/posthtml/posthtml/commit/97d89ad))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **typings:** Type-inference for node.prototype.match ([90d3c48](https://github.com/posthtml/posthtml/commit/90d3c48))
|
||||
|
||||
### [0.11.5](https://github.com/posthtml/posthtml/compare/v0.11.4...v0.11.5) (2019-08-27)
|
||||
|
||||
### Perf
|
||||
* **perf:** Add TypeScript typings ([89bf763](https://github.com/posthtml/posthtml/commit/89bf763q))
|
||||
|
||||
### Plugins
|
||||
* **plugin:** Add posthtml-minify-classnames ([9844a08](https://github.com/posthtml/posthtml/commit/9844a08))
|
||||
* **plugin:** Add posthtml-pseudo ([8b86f58](https://github.com/posthtml/posthtml/commit/8b86f58))
|
||||
* **plugin:** Add posthtml-lazyload ([1009bff](https://github.com/posthtml/posthtml/commit/1009bff))
|
||||
* **plugin:** Add posthtml-link-noreferrer ([1009bff](https://github.com/posthtml/posthtml/commit/1009bff))
|
||||
|
||||
### [0.11.4](https://github.com/posthtml/posthtml/compare/v0.11.3...v0.11.4) (2019-05-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **index:** if tree not object ([3fd9548](https://github.com/posthtml/posthtml/commit/3fd9548))
|
||||
* **readme:** adds missing bracket ([ff3102f](https://github.com/posthtml/posthtml/commit/ff3102f))
|
||||
* **test/options:** incorrect transfer option for the process ([c5fd774](https://github.com/posthtml/posthtml/commit/c5fd774))
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* remove pkg lock ([5c9b45a](https://github.com/posthtml/posthtml/commit/5c9b45a))
|
||||
* update build system, close [#279](https://github.com/posthtml/posthtml/issues/279) ([ca77e4a](https://github.com/posthtml/posthtml/commit/ca77e4a))
|
||||
* update depDev ([c975225](https://github.com/posthtml/posthtml/commit/c975225))
|
||||
|
||||
|
||||
### Tests
|
||||
|
||||
* update init for mocha ([be634f6](https://github.com/posthtml/posthtml/commit/be634f6))
|
||||
* **message:** add test for extending from prevent tree ([6cb238a](https://github.com/posthtml/posthtml/commit/6cb238a))
|
||||
* **options:** if tree not object ([dcdb3e7](https://github.com/posthtml/posthtml/commit/dcdb3e7))
|
||||
|
||||
|
||||
|
||||
<a name="0.11.3"></a>
|
||||
## [0.11.3](https://github.com/posthtml/posthtml/compare/v0.11.2...v0.11.3) (2018-02-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **index:** instance new api between files, close [#250](https://github.com/posthtml/posthtml/issues/250) ([25120a9](https://github.com/posthtml/posthtml/commit/25120a9))
|
||||
* **index:** if tree not object ([3fd9548](https://github.com/posthtml/posthtml/commit/3fd9548))
|
||||
* **test/options:** incorrect transfer option for the process ([c5fd774](https://github.com/posthtml/posthtml/commit/c5fd774))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **api:** rewrite to constructor, close [#258](https://github.com/posthtml/posthtml/issues/258) ([89238cb](https://github.com/posthtml/posthtml/commit/89238cb))
|
||||
* **api:** api is not a place for concatenation. ([f428425](https://github.com/posthtml/posthtml/commit/f428425))
|
||||
* **api:** inherit from the previous tree ([4e69577](https://github.com/posthtml/posthtml/commit/4e69577))
|
||||
* **api:** move message to posthtml constructor ([c51e40f](https://github.com/posthtml/posthtml/commit/c51e40f))
|
||||
* **api:** rename api to extendApi ([846e386](https://github.com/posthtml/posthtml/commit/846e386))
|
||||
* **index:** set the previous tree as the context value for api ([21170c7](https://github.com/posthtml/posthtml/commit/21170c7))
|
||||
* made a repetitive design in a private function ([fabeef4](https://github.com/posthtml/posthtml/commit/fabeef4))
|
||||
|
||||
### Reverts
|
||||
|
||||
* **api:** return export api methods ([90e3565](https://github.com/posthtml/posthtml/commit/90e3565))
|
||||
|
||||
|
||||
|
||||
<a name="0.11.2"></a>
|
||||
## [0.11.2](https://github.com/posthtml/posthtml/compare/v0.11.1...v0.11.2) (2018-01-19)
|
||||
|
||||
|
||||
|
||||
<a name="0.11.1"></a>
|
||||
## [0.11.1](https://github.com/posthtml/posthtml/compare/v0.11.0...v0.11.1) (2018-01-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **index:** don't throw on empty tree () ([c66f9e2](https://github.com/posthtml/posthtml/commit/c66f9e2))
|
||||
|
||||
|
||||
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://github.com/posthtml/posthtml/compare/v0.10.1...v0.11.0) (2017-12-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **readme:** typo in webpack config, close [#222](https://github.com/posthtml/posthtml/issues/222) ([92b0261](https://github.com/posthtml/posthtml/commit/92b0261))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **index:** add support for `messages` (`result.messages`) ([e38bb9b](https://github.com/posthtml/posthtml/commit/e38bb9b))
|
||||
|
||||
|
||||
|
||||
<a name="0.10.1"></a>
|
||||
## [0.10.1](https://github.com/posthtml/posthtml/compare/v0.10.0...v0.10.1) (2017-11-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **index:** did not pass options for parser ([b8cd535](https://github.com/posthtml/posthtml/commit/b8cd535))
|
||||
|
||||
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://github.com/posthtml/posthtml/compare/v0.9.2...v0.10.0) (2017-11-23)
|
||||
|
||||
* **docs** add directives description ([876315e](https://github.com/posthtml/posthtml/pull/231/commits/876315e))
|
||||
* **chore** update posthtml-parser ([0e767d8](https://github.com/posthtml/posthtml/pull/231/commits/0e767d8))
|
||||
* **test** for option directives ([015433f](https://github.com/posthtml/posthtml/pull/231/commits/015433f))
|
||||
* **test** update title ([5ea4023](https://github.com/posthtml/posthtml/pull/231/commits/5ea4023))
|
||||
* **test** fix not support string template old nodes ([3f07e1c](https://github.com/posthtml/posthtml/pull/231/commits/3f07e1c))
|
||||
* **test** fix typo ([32e29e3](https://github.com/posthtml/posthtml/pull/231/commits/32e29e3))
|
||||
|
||||
<a name="0.9.2"></a>
|
||||
## [0.9.2](https://github.com/posthtml/posthtml/compare/v0.9.1...v0.9.2) (2017-01-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Cannot read property 'length' of undefined ([03da01e](https://github.com/posthtml/posthtml/commit/03da01e))
|
||||
* **index:** trailing space ([3cd00b7](https://github.com/posthtml/posthtml/commit/3cd00b7))
|
||||
* **index:** typo in require method ([088c9e3](https://github.com/posthtml/posthtml/commit/088c9e3))
|
||||
* **test:** fix tree for test options set ([03286ea](https://github.com/posthtml/posthtml/commit/03286ea))
|
||||
|
||||
|
||||
|
||||
<a name="0.9.1"></a>
|
||||
## [0.9.1](https://github.com/posthtml/posthtml/compare/v0.9.0...v0.9.1) (2016-09-29)
|
||||
|
||||
|
||||
|
||||
<a name="0.9.0"></a>
|
||||
# [0.9.0](https://github.com/posthtml/posthtml/compare/v0.8.7...v0.9.0) (2016-07-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix run jscs after version update ([124f857](https://github.com/posthtml/posthtml/commit/124f857))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* make parser configurable ([bfa3e6d](https://github.com/posthtml/posthtml/commit/bfa3e6d))
|
||||
* **lib:** make use method variadic ([43d6a6b](https://github.com/posthtml/posthtml/commit/43d6a6b))
|
||||
|
||||
|
||||
|
||||
<a name="0.8.7"></a>
|
||||
## [0.8.7](https://github.com/posthtml/posthtml/compare/v0.8.6...v0.8.7) (2016-05-04)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **lib:** on demand html rendering ([4ef0df9](https://github.com/posthtml/posthtml/commit/4ef0df9))
|
||||
|
||||
|
||||
|
||||
<a name="0.8.6"></a>
|
||||
## [0.8.6](https://github.com/posthtml/posthtml/compare/v0.8.5...v0.8.6) (2016-04-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **api:** report true for boolean attrs ([70cec9d](https://github.com/posthtml/posthtml/commit/70cec9d))
|
||||
* **docs:** correct typo ([b5133f5](https://github.com/posthtml/posthtml/commit/b5133f5))
|
||||
|
||||
|
||||
|
||||
<a name="0.8.5"></a>
|
||||
## [0.8.5](https://github.com/posthtml/posthtml/compare/v0.8.4...v0.8.5) (2016-03-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **README:** fix style in Readme ([9944446](https://github.com/posthtml/posthtml/commit/9944446))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **api:** remove extra slice call ([8a3ff11](https://github.com/posthtml/posthtml/commit/8a3ff11))
|
||||
|
||||
|
||||
|
||||
<a name="0.8.4"></a>
|
||||
## [0.8.4](https://github.com/posthtml/posthtml/compare/v0.8.3...v0.8.4) (2016-03-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* promise check and tests ([79bcff9](https://github.com/posthtml/posthtml/commit/79bcff9))
|
||||
|
||||
### Features
|
||||
|
||||
* **docs:** update README, add docs folder ([619a97c](https://github.com/posthtml/posthtml/commit/619a97c))
|
||||
|
||||
|
||||
|
||||
<a name="0.8.3"></a>
|
||||
## [0.8.3](https://github.com/posthtml/posthtml/compare/v0.8.2...v0.8.3) (2016-02-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* promise check and tests ([0162f97](https://github.com/posthtml/posthtml/commit/0162f97))
|
||||
|
||||
|
||||
|
||||
<a name="0.8.2"></a>
|
||||
## [0.8.2](https://github.com/posthtml/posthtml/compare/v0.8.1...v0.8.2) (2016-02-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* remove compilations. Support for NodeJS v0.10 ([ac437b7](https://github.com/posthtml/posthtml/commit/ac437b7))
|
||||
|
||||
|
||||
|
||||
<a name"0.8.1"></a>
|
||||
### 0.8.1 (2016-01-08)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **api:** fix binds tree for import API ([a8f25007](https://github.com/posthtml/posthtml/commit/a8f25007))
|
||||
* **docs:** fix readme ([cd61bc11](https://github.com/posthtml/posthtml/commit/cd61bc11))
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **docs:**
|
||||
* add more plugins in plugin list ([52bfcad2](https://github.com/posthtml/posthtml/commit/52bfcad2))
|
||||
* add Gitter chat badge ([97ba9847](https://github.com/posthtml/posthtml/commit/97ba9847))
|
||||
* add new plugins link & add plugin boilerplate link ([40644039](https://github.com/posthtml/posthtml/commit/40644039))
|
||||
|
||||
|
||||
<a name"0.8.0"></a>
|
||||
## 0.8.0 (2015-11-24)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **docs:** delete parse section ([16511096](https://github.com/posthtml/posthtml/commit/16511096))
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* ***:** upd nodejs deps in travis.yml ([481378db](https://github.com/posthtml/posthtml/commit/481378db))
|
||||
* **api:** chaining ([03080a6e](https://github.com/posthtml/posthtml/commit/03080a6e))
|
||||
* **docs:** upd plugin sections in Readme ([c69bc2b9](https://github.com/posthtml/posthtml/commit/c69bc2b9))
|
||||
|
||||
|
||||
<a name"0.7.0"></a>
|
||||
## 0.7.0 (2015-10-21)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* ***:** new dependencies·for posthtml-parser posthtml-render ([a5bc312b](https://github.com/posthtml/posthtml/commit/a5bc312b))
|
||||
* **api:** delete matchClass method ([912f72ad](https://github.com/posthtml/posthtml/commit/912f72ad))
|
||||
* **docs:** add dependency info to readme ([6c3419cf](https://github.com/posthtml/posthtml/commit/6c3419cf))
|
||||
|
||||
|
||||
<a name"0.6.0"></a>
|
||||
## 0.6.0 (2015-10-17)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* ***:** fix code style ([7a743f78](https://github.com/posthtml/posthtml/commit/7a743f78))
|
||||
* **api:** Support RegExp in matcher Object ([e3bd9918](https://github.com/posthtml/posthtml/commit/e3bd9918))
|
||||
* **docs:** add matchClass deprecated info ([14f1757e](https://github.com/posthtml/posthtml/commit/14f1757e))
|
||||
|
||||
|
||||
<a name"0.5.0"></a>
|
||||
## 0.5.0 (2015-10-10)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **api:** support RegExp matchers ([783c5663](https://github.com/posthtml/posthtml/commit/783c5663))
|
||||
* **docs:**
|
||||
* add project-stub link. Fix long titles. Upd PostHTMLTree example ([57f48334](https://github.com/posthtml/posthtml/commit/57f48334))
|
||||
* add posthtml-retext info & upd links ([541dbc03](https://github.com/posthtml/posthtml/commit/541dbc03))
|
||||
* add license info to readme ([32300239](https://github.com/posthtml/posthtml/commit/32300239))
|
||||
* add posthtml-bem plugin in readme ([2eea4b19](https://github.com/posthtml/posthtml/commit/2eea4b19))
|
||||
|
||||
|
||||
<a name"0.4.1"></a>
|
||||
### 0.4.1 (2015-10-04)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **posthtml:** fix build ES2015 ([829ba49c](https://github.com/posthtml/posthtml/commit/829ba49c))
|
||||
|
||||
|
||||
<a name"0.4.0"></a>
|
||||
## 0.4.0 (2015-10-03)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **lint:** fix jscsrc ([a534e0a0](https://github.com/posthtml/posthtml/commit/a534e0a0))
|
||||
* **posthtml:**
|
||||
* extend new object with api methods on each plugin call ([82e096ea](https://github.com/posthtml/posthtml/commit/82e096ea))
|
||||
* code style fix ([d1b3484d](https://github.com/posthtml/posthtml/commit/d1b3484d))
|
||||
* code style fix ([26e6d7e3](https://github.com/posthtml/posthtml/commit/26e6d7e3))
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **api:** handle array matchers ([335b5aac](https://github.com/posthtml/posthtml/commit/335b5aac))
|
||||
* **docs:**
|
||||
* write array matchers example in jsdocs/readme ([a14b7675](https://github.com/posthtml/posthtml/commit/a14b7675))
|
||||
* add logo to readme ([78740c34](https://github.com/posthtml/posthtml/commit/78740c34))
|
||||
* **lint:** upd jscs ([cef42d5d](https://github.com/posthtml/posthtml/commit/cef42d5d))
|
||||
* **posthtml:** implement truly sync and async modes, and tests for them ([337243f5](https://github.com/posthtml/posthtml/commit/337243f5))
|
||||
|
||||
|
||||
<a name"0.3.0"></a>
|
||||
## 0.3.0 (2015-09-25)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **parser:** skip template if tag === false ([3cc9e59f](https://github.com/posthtml/posthtml/commit/3cc9e59f))
|
||||
|
||||
|
||||
<a name"0.2.1"></a>
|
||||
### 0.2.1 (2015-09-24)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **api:** optimize matchClass func ([b0311cd7](https://github.com/posthtml/posthtml/commit/b0311cd7))
|
||||
* **docs:**
|
||||
* Write example Gulp plugin for PostHTML in docs ([b9c8ceff](https://github.com/posthtml/posthtml/commit/b9c8ceff))
|
||||
* Add Textr plugin to Readme ([bdd3270b](https://github.com/posthtml/posthtml/commit/bdd3270b))
|
||||
|
||||
|
||||
<a name"0.2.0"></a>
|
||||
## 0.2.0 (2015-09-23)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **test:** fix typo & cleanup ([e33ba7fa](https://github.com/posthtml/posthtml/commit/e33ba7fa))
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **api:**
|
||||
* rename eachClass to matchClass ([efc9b349](https://github.com/posthtml/posthtml/commit/efc9b349))
|
||||
* use options in plugin ([0d8c4555](https://github.com/posthtml/posthtml/commit/0d8c4555))
|
||||
* **docs:** `options` docs write in readme ([d72c2741](https://github.com/posthtml/posthtml/commit/d72c2741))
|
||||
* **lint:** own jscs config ([74332ab8](https://github.com/posthtml/posthtml/commit/74332ab8))
|
||||
* **parser:**
|
||||
* toHtml tests ([789ee545](https://github.com/posthtml/posthtml/commit/789ee545))
|
||||
* own render html func ([1520e5ff](https://github.com/posthtml/posthtml/commit/1520e5ff))
|
||||
|
||||
|
||||
<a name"0.1.0"></a>
|
||||
## 0.1.0 (2015-09-14)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **api:** base API ([096654a6](https://github.com/posthtml/posthtml/commit/096654a6))
|
||||
|
||||
|
||||
<a name"0.0.4"></a>
|
||||
### 0.0.4 (2015-09-13)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **lib:** fix option declare ([db95e066](https://github.com/posthtml/posthtml/commit/db95e066))
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* ***:** upd deps ([054bd94c](https://github.com/posthtml/posthtml/commit/054bd94c))
|
||||
* **lib:** delete getOptions method ([931a03a0](https://github.com/posthtml/posthtml/commit/931a03a0))
|
||||
* **parser:**
|
||||
* no skip parse text simbols ([42b4d156](https://github.com/posthtml/posthtml/commit/42b4d156))
|
||||
* Own parser html to tree ([748d8f1e](https://github.com/posthtml/posthtml/commit/748d8f1e))
|
||||
* init ([1ca1b39b](https://github.com/posthtml/posthtml/commit/1ca1b39b))
|
||||
* **readme:** add tree example ([e46e9bc2](https://github.com/posthtml/posthtml/commit/e46e9bc2))
|
||||
|
||||
|
||||
<a name"0.0.3"></a>
|
||||
### 0.0.3 (2015-08-13)
|
||||
|
||||
* ***:** upd dependencies ([b1f4f2664106034d6fd530962a4f9bd9c378d17a](https://github.com/posthtml/posthtml/commit/b1f4f2664106034d6fd530962a4f9bd9c378d17a))
|
||||
|
||||
#### Features
|
||||
|
||||
* **lint:** use jshint ([504f3c06](https://github.com/posthtml/posthtml/commit/504f3c06))
|
||||
|
||||
|
||||
<a name"0.0.2"></a>
|
||||
### 0.0.2 (2015-07-02)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* ***:**
|
||||
* add-travis-and-coverage ([92c9ee81](https://github.com/posthtml/posthtml/commit/92c9ee81))
|
||||
* changelog build ([044fd58d](https://github.com/posthtml/posthtml/commit/044fd58d))
|
||||
* deep results objects #13 ([96b86c90](https://github.com/posthtml/posthtml/commit/96b86c90))
|
||||
* add skipParse options ([45eeb9e3](https://github.com/posthtml/posthtml/commit/45eeb9e3))
|
||||
* **gulp:** refactor config ([2fe4ecb2](https://github.com/posthtml/posthtml/commit/2fe4ecb2))
|
||||
|
||||
|
||||
<a name"0.0.1"></a>
|
||||
### 0.0.1
|
||||
init
|
||||
21
BACK_BACK/node_modules/posthtml/LICENSE
generated
vendored
Executable file
21
BACK_BACK/node_modules/posthtml/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2015 PostHTML
|
||||
|
||||
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.
|
||||
772
BACK_BACK/node_modules/posthtml/README.md
generated
vendored
Executable file
772
BACK_BACK/node_modules/posthtml/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,772 @@
|
|||
[![NPM][npm]][npm-url]
|
||||
[![Deps][deps]][deps-url]
|
||||
[![Tests][build]][build-url]
|
||||
[![Coverage][cover]][cover-url]
|
||||
[![Standard Code Style][code-style]][code-style-url]
|
||||
[![Chat][chat]][chat-url]
|
||||
|
||||
# PostHTML <img align="right" width="220" height="200" title="PostHTML" src="http://posthtml.github.io/posthtml/logo.svg">
|
||||
|
||||
PostHTML is a tool for transforming HTML/XML with JS plugins. PostHTML itself is very small. It includes only a HTML parser, a HTML node tree API and a node tree stringifier.
|
||||
|
||||
All HTML transformations are made by plugins. And these plugins are just small plain JS functions, which receive a HTML node tree, transform it, and return a modified tree.
|
||||
|
||||
For more detailed information about PostHTML in general take a look at the [docs][docs].
|
||||
|
||||
### Dependencies
|
||||
|
||||
| Name | Status | Description |
|
||||
|:----:|:------:|:-----------:|
|
||||
|[posthtml-parser][parser]|[![npm][parser-badge]][parser-npm]| Parser HTML/XML to PostHTMLTree |
|
||||
|[posthtml-render][render]|[![npm][render-badge]][render-npm]| Render PostHTMLTree to HTML/XML |
|
||||
|
||||
|
||||
[docs]: https://github.com/posthtml/posthtml/blob/master/docs
|
||||
|
||||
[parser]: https://github.com/posthtml/posthtml-parser
|
||||
[parser-badge]: https://img.shields.io/npm/v/posthtml-parser.svg
|
||||
[parser-npm]: https://npmjs.com/package/posthtml-parser
|
||||
|
||||
[render]: https://github.com/posthtml/posthtml-render
|
||||
[render-badge]: https://img.shields.io/npm/v/posthtml-render.svg
|
||||
[render-npm]: https://npmjs.com/package/posthtml-render
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i -D posthtml
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### API
|
||||
|
||||
**Sync**
|
||||
|
||||
```js
|
||||
import posthtml from 'posthtml'
|
||||
|
||||
const html = `
|
||||
<component>
|
||||
<title>Super Title</title>
|
||||
<text>Awesome Text</text>
|
||||
</component>
|
||||
`
|
||||
|
||||
const result = posthtml()
|
||||
.use(require('posthtml-custom-elements')())
|
||||
.process(html, { sync: true })
|
||||
.html
|
||||
|
||||
console.log(result)
|
||||
```
|
||||
|
||||
```html
|
||||
<div class="component">
|
||||
<div class="title">Super Title</div>
|
||||
<div class="text">Awesome Text</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
> :warning: Async Plugins can't be used in sync mode and will throw an Error. It's recommended to use PostHTML asynchronously whenever possible.
|
||||
|
||||
**Async**
|
||||
|
||||
```js
|
||||
import posthtml from 'posthtml'
|
||||
|
||||
const html = `
|
||||
<html>
|
||||
<body>
|
||||
<p class="wow">OMG</p>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
||||
posthtml(
|
||||
[
|
||||
require('posthtml-to-svg-tags')(),
|
||||
require('posthtml-extend-attrs')({
|
||||
attrsTree: {
|
||||
'.wow' : {
|
||||
id: 'wow_id',
|
||||
fill: '#4A83B4',
|
||||
'fill-rule': 'evenodd',
|
||||
'font-family': 'Verdana'
|
||||
}
|
||||
}
|
||||
})
|
||||
])
|
||||
.process(html/*, options */)
|
||||
.then((result) => console.log(result.html))
|
||||
```
|
||||
|
||||
```html
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<text
|
||||
class="wow"
|
||||
id="wow_id"
|
||||
fill="#4A83B4"
|
||||
fill-rule="evenodd" font-family="Verdana">
|
||||
OMG
|
||||
</text>
|
||||
</svg>
|
||||
```
|
||||
|
||||
**Directives**
|
||||
|
||||
```js
|
||||
import posthtml from 'posthtml'
|
||||
|
||||
const php = `
|
||||
<component>
|
||||
<title><?php echo $title; ?></title>
|
||||
<text><?php echo $article; ?></text>
|
||||
</component>
|
||||
`
|
||||
|
||||
const result = posthtml()
|
||||
.use(require('posthtml-custom-elements')())
|
||||
.process(html, {
|
||||
directives: [
|
||||
{ name: '?php', start: '<', end: '>' }
|
||||
]
|
||||
})
|
||||
.html
|
||||
|
||||
console.log(result)
|
||||
```
|
||||
|
||||
```html
|
||||
<div class="component">
|
||||
<div class="title"><?php echo $title; ?></div>
|
||||
<div class="text"><?php echo $article; ?></div>
|
||||
</div>
|
||||
```
|
||||
|
||||
### [CLI](https://npmjs.com/package/posthtml-cli)
|
||||
|
||||
```bash
|
||||
npm i posthtml-cli
|
||||
```
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"posthtml": "posthtml -o output.html -i input.html -c config.json"
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
npm run posthtml
|
||||
```
|
||||
|
||||
### [Gulp](https://gulpjs.com)
|
||||
|
||||
```bash
|
||||
npm i -D gulp-posthtml
|
||||
```
|
||||
|
||||
```js
|
||||
import tap from 'gulp-tap'
|
||||
import posthtml from 'gulp-posthtml'
|
||||
import { task, src, dest } from 'gulp'
|
||||
|
||||
task('html', () => {
|
||||
let path
|
||||
|
||||
const plugins = [ require('posthtml-include')({ root: `${path}` }) ]
|
||||
const options = {}
|
||||
|
||||
src('src/**/*.html')
|
||||
.pipe(tap((file) => path = file.path))
|
||||
.pipe(posthtml(plugins, options))
|
||||
.pipe(dest('build/'))
|
||||
})
|
||||
```
|
||||
|
||||
Check [project-stub](https://github.com/posthtml/project-stub) for an example with Gulp
|
||||
|
||||
### [Grunt](https://gruntjs.com)
|
||||
|
||||
```bash
|
||||
npm i -D grunt-posthtml
|
||||
```
|
||||
|
||||
```js
|
||||
posthtml: {
|
||||
options: {
|
||||
use: [
|
||||
require('posthtml-doctype')({ doctype: 'HTML 5' }),
|
||||
require('posthtml-include')({ root: './', encoding: 'utf-8' })
|
||||
]
|
||||
},
|
||||
build: {
|
||||
files: [
|
||||
{
|
||||
dot: true,
|
||||
cwd: 'html/',
|
||||
src: ['*.html'],
|
||||
dest: 'tmp/',
|
||||
expand: true,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### [Webpack](https://webpack.js.org)
|
||||
|
||||
```bash
|
||||
npm i -D html-loader posthtml-loader
|
||||
```
|
||||
|
||||
#### v1.x
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
const config = {
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
test: /\.html$/,
|
||||
loader: 'html!posthtml'
|
||||
}
|
||||
]
|
||||
},
|
||||
posthtml: (ctx) => ({
|
||||
parser: require('posthtml-pug'),
|
||||
plugins: [
|
||||
require('posthtml-bem')()
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
export default config
|
||||
```
|
||||
|
||||
#### v2.x
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
import { LoaderOptionsPlugin } from 'webpack'
|
||||
|
||||
const config = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.html$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'html-loader',
|
||||
options: { minimize: true }
|
||||
},
|
||||
{
|
||||
loader: 'posthtml-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new LoaderOptionsPlugin({
|
||||
options: {
|
||||
posthtml(ctx) {
|
||||
return {
|
||||
parser: require('posthtml-pug'),
|
||||
plugins: [
|
||||
require('posthtml-bem')()
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
export default config
|
||||
```
|
||||
|
||||
### [Rollup](https://rollupjs.org/)
|
||||
|
||||
```bash
|
||||
$ npm i rollup-plugin-posthtml -D
|
||||
# or
|
||||
$ npm i rollup-plugin-posthtml-template -D
|
||||
```
|
||||
|
||||
```js
|
||||
import { join } from 'path';
|
||||
|
||||
import posthtml from 'rollup-plugin-posthtml-template';
|
||||
// or
|
||||
// import posthtml from 'rollup-plugin-posthtml';
|
||||
|
||||
import sugarml from 'posthtml-sugarml'; // npm i posthtml-sugarml -D
|
||||
import include from 'posthtml-include'; // npm i posthtml-include -D
|
||||
|
||||
export default {
|
||||
entry: join(__dirname, 'main.js'),
|
||||
dest: join(__dirname, 'bundle.js'),
|
||||
format: 'iife',
|
||||
plugins: [
|
||||
posthtml({
|
||||
parser: sugarml(),
|
||||
plugins: [include()],
|
||||
template: true // only rollup-plugin-posthtml-template
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
## Parser
|
||||
|
||||
```js
|
||||
import pug from 'posthtml-pug'
|
||||
|
||||
posthtml().process(html, { parser: pug(options) }).then((result) => result.html)
|
||||
```
|
||||
|
||||
| Name |Status|Description|
|
||||
|:-----|:-----|:----------|
|
||||
|[posthtml-pug][pug]|[![npm][pug-badge]][pug-npm]|Pug Parser|
|
||||
|[sugarml][sugar]|[![npm][sugar-badge]][sugar-npm]|SugarML Parser|
|
||||
|
||||
|
||||
[pug]: https://github.com/posthtml/posthtml-pug
|
||||
[pug-badge]: https://img.shields.io/npm/v/posthtml-pug.svg
|
||||
[pug-npm]: https://npmjs.com/package/posthtml-pug
|
||||
|
||||
[sugar]: https://github.com/posthtml/sugarml
|
||||
[sugar-badge]: https://img.shields.io/npm/v/sugarml.svg
|
||||
[sugar-npm]: https://npmjs.com/package/sugarml
|
||||
|
||||
## [Plugins](http://maltsev.github.io/posthtml-plugins)
|
||||
|
||||
In case you want to develop your own plugin, we recommend using [posthtml-plugin-boilerplate][plugin] for getting started.
|
||||
|
||||
[plugin]: https://github.com/posthtml/posthtml-plugin-boilerplate
|
||||
|
||||
#### TEXT
|
||||
|
||||
| Name |Status|Description|
|
||||
|:-----|:-----|:----------|
|
||||
|[posthtml-md][md]|[![npm][md-badge]][md-npm]|Easily use context-sensitive markdown within HTML|
|
||||
|[posthtml-lorem][lorem]|[![npm][lorem-badge]][lorem-npm]|Add lorem ipsum placeholder text to any document|
|
||||
|[posthtml-retext][text]|[![npm][text-badge]][text-npm]|Extensible system for analysing and manipulating natural language|
|
||||
|[prevent-widows][prevent-widows]|[![npm][prevent-widows-badge]][prevent-widows-npm]|Prevent widows from appearing at the end of paragraphs|
|
||||
|
||||
[md]: https://github.com/jonathantneal/posthtml-md
|
||||
[md-badge]: https://img.shields.io/npm/v/posthtml-md.svg
|
||||
[md-npm]: https://npmjs.com/package/posthtml-md
|
||||
|
||||
[text]: https://github.com/voischev/posthtml-retext
|
||||
[text-badge]: https://img.shields.io/npm/v/posthtml-retext.svg
|
||||
[text-npm]: https://npmjs.com/package/posthtml-retext
|
||||
|
||||
[lorem]: https://github.com/jonathantneal/posthtml-lorem
|
||||
[lorem-badge]: https://img.shields.io/npm/v/posthtml-lorem.svg
|
||||
[lorem-npm]: https://npmjs.com/package/posthtml-lorem
|
||||
|
||||
[prevent-widows]: https://github.com/bashaus/prevent-widows
|
||||
[prevent-widows-badge]: https://img.shields.io/npm/v/prevent-widows.svg
|
||||
[prevent-widows-npm]: https://npmjs.com/package/prevent-widows
|
||||
|
||||
#### HTML
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:----:|:----------|
|
||||
|[posthtml-doctype][doctype]|[![npm][doctype-badge]][doctype-npm]|Set !DOCTYPE|
|
||||
|[posthtml-head-elements][head]|[![npm][head-badge]][head-npm]|Include head elements from JSON file|
|
||||
|[posthtml-include][include]|[![npm][include-badge]][include-npm]|Include HTML|
|
||||
|[posthtml-modules][modules]|[![npm][modules-badge]][modules-npm]|Include and process HTML|
|
||||
|[posthtml-extend][extend]|[![npm][extend-badge]][extend-npm]|Extend Layout (Pug-like)|
|
||||
|[posthtml-extend-attrs][attrs]|[![npm][attrs-badge]][attrs-npm]|Extend Attrs|
|
||||
|[posthtml-expressions][exp]|[![npm][exp-badge]][exp-npm]|Template Expressions|
|
||||
|[posthtml-inline-assets][assets]|[![npm][assets-badge]][assets-npm]|Inline external scripts, styles, and images|
|
||||
|[posthtml-static-react][react]|[![npm][react-badge]][react-npm]| Render custom elements as static React components|
|
||||
|[posthtml-custom-elements][elem]|[![npm][elem-badge]][elem-npm]|Use custom elements|
|
||||
|[posthtml-web-component][web]|[![npm][web-badge]][web-npm]|Web Component server-side rendering, Component as a Service (CaaS)|
|
||||
|[posthtml-spaceless][spaceless]|[![npm][spaceless-badge]][spaceless-npm]|Remove whitespace between HTML tags|
|
||||
|[posthtml-cache][cache]|[![npm][cache-badge]][cache-npm]|Add a nanoid to links in you tags|
|
||||
|[posthtml-highlight][highlight]|[![npm][highlight-badge]][highlight-npm]|Syntax highlight code elements|
|
||||
|[posthtml-pseudo][pseudo]|[![npm][pseudo-badge]][pseudo-npm]|Add pseudo selector class names to elements|
|
||||
|
||||
[cache]: https://github.com/posthtml/posthtml-cache
|
||||
[cache-badge]: https://img.shields.io/npm/v/posthtml-cache.svg
|
||||
[cache-npm]: https://npmjs.com/package/posthtml-cache
|
||||
|
||||
[spaceless]: https://github.com/posthtml/posthtml-spaceless
|
||||
[spaceless-badge]: https://img.shields.io/npm/v/posthtml-spaceless.svg
|
||||
[spaceless-npm]: https://npmjs.com/package/posthtml-spaceless
|
||||
|
||||
[doctype]: https://github.com/posthtml/posthtml-doctype
|
||||
[doctype-badge]: https://img.shields.io/npm/v/posthtml-doctype.svg
|
||||
[doctype-npm]: https://npmjs.com/package/posthtml-doctype
|
||||
|
||||
[head]: https://github.com/TCotton/posthtml-head-elements
|
||||
[head-badge]: https://img.shields.io/npm/v/posthtml-head-elements.svg
|
||||
[head-npm]: https://npmjs.com/package/posthtml-head-elements
|
||||
|
||||
[include]: https://github.com/posthtml/posthtml-include
|
||||
[include-badge]: https://img.shields.io/npm/v/posthtml-include.svg
|
||||
[include-npm]: https://npmjs.com/package/posthtml-include
|
||||
|
||||
[modules]: https://github.com/posthtml/posthtml-modules
|
||||
[modules-badge]: https://img.shields.io/npm/v/posthtml-modules.svg
|
||||
[modules-npm]: https://npmjs.com/package/posthtml-modules
|
||||
|
||||
[content]: https://github.com/posthtml/posthtml-content
|
||||
[content-badge]: https://img.shields.io/npm/v/posthtml-content.svg
|
||||
[content-npm]: https://npmjs.com/package/posthtml-content
|
||||
|
||||
[exp]: https://github.com/posthtml/posthtml-exp
|
||||
[exp-badge]: https://img.shields.io/npm/v/posthtml-exp.svg
|
||||
[exp-npm]: https://npmjs.com/package/posthtml-exp
|
||||
|
||||
[extend]: https://github.com/posthtml/posthtml-extend
|
||||
[extend-badge]: https://img.shields.io/npm/v/posthtml-extend.svg
|
||||
[extend-npm]: https://npmjs.com/package/posthtml-extend
|
||||
|
||||
[attrs]: https://github.com/theprotein/posthtml-extend-attrs
|
||||
[attrs-badge]: https://img.shields.io/npm/v/posthtml-extend-attrs.svg
|
||||
[attrs-npm]: https://npmjs.com/package/posthtml-extend-attrs
|
||||
|
||||
[assets]: https://github.com/jonathantneal/posthtml-inline-assets
|
||||
[assets-badge]: https://img.shields.io/npm/v/posthtml-inline-assets.svg
|
||||
[assets-npm]: https://npmjs.com/package/posthtml-inline-assets
|
||||
|
||||
[elem]: https://github.com/posthtml/posthtml-custom-elements
|
||||
[elem-badge]: https://img.shields.io/npm/v/posthtml-custom-elements.svg
|
||||
[elem-npm]: https://npmjs.com/package/posthtml-custom-elements
|
||||
|
||||
[web]: https://github.com/island205/posthtml-web-component
|
||||
[web-badge]: https://img.shields.io/npm/v/posthtml-web-component.svg
|
||||
[web-npm]: https://npmjs.com/package/posthtml-web-components
|
||||
|
||||
[prefix]: https://github.com/stevenbenisek/posthtml-prefix-class
|
||||
[prefix-badge]: https://img.shields.io/npm/v/posthtml-prefix-class.svg
|
||||
[prefix-npm]: https://npmjs.com/package/posthtml-prefix-class
|
||||
|
||||
[react]: https://github.com/rasmusfl0e/posthtml-static-react
|
||||
[react-badge]: https://img.shields.io/npm/v/posthtml-static-react.svg
|
||||
[react-npm]: https://npmjs.com/package/posthtml-static-react
|
||||
|
||||
[highlight]: https://github.com/caseyWebb/posthtml-highlight
|
||||
[highlight-badge]: https://img.shields.io/npm/v/posthtml-highlight.svg
|
||||
[highlight-npm]: https://npmjs.com/package/posthtml-highlight
|
||||
|
||||
[pseudo]: https://github.com/kevinkace/posthtml-pseudo
|
||||
[pseudo-badge]: https://img.shields.io/npm/v/posthtml-pseudo.svg
|
||||
[pseudo-npm]: https://npmjs.com/package/posthtml-pseudo
|
||||
|
||||
#### CSS
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:-----|:----------|
|
||||
|[posthtml-bem][bem]|[![npm][bem-badge]][bem-npm]|Support BEM naming in html structure|
|
||||
|[posthtml-postcss][css]|[![npm][css-badge]][css-npm]|Use [PostCSS][css-gh] in HTML document|
|
||||
|[posthtml-px2rem][px2rem]|[![npm][px2rem-badge]][px2rem-npm]|Change px to rem in Inline CSS|
|
||||
|[posthtml-css-modules][css-modules]|[![npm][css-modules-badge]][css-modules-npm]|Use CSS modules in HTML|
|
||||
|[posthtml-postcss-modules][postcss-modules]|[![npm][postcss-modules-badge]][postcss-modules-npm]|CSS Modules in html|
|
||||
|[posthtml-classes][classes]|[![npm][classes-badge]][classes-npm]|Get a list of classes from HTML|
|
||||
|[posthtml-prefix-class][prefix]|[![npm][prefix-badge]][prefix-npm]|Prefix class names
|
||||
|[posthtml-modular-css][modular]|[![npm][modular-badge]][modular-npm]|Make CSS modular|
|
||||
|[posthtml-inline-css][in]|[![npm][in-badge]][in-npm]|CSS Inliner|
|
||||
|[posthtml-collect-styles][collect-styles]|[![npm][collect-styles-badge]][collect-styles-npm]|Collect styles from html and put it in the head|
|
||||
|[posthtml-collect-inline-styles][collect]|[![npm][collect-badge]][collect-npm]|Collect inline styles and insert to head tag|
|
||||
|[posthtml-style-to-file][style]|[![npm][style-badge]][style-npm]| Save HTML style nodes and attributes to CSS file|
|
||||
|[posthtml-color-shorthand-hex-to-six-digit][hex]|[![npm][hex-badge]][hex-npm]|Enforce all hex color codes to be 6-char long|
|
||||
|[posthtml-minify-classnames][minify]|[![npm][minify-badge]][minify-npm]|Rewrites classnames and ids inside of html and css files to reduce file size.|
|
||||
|
||||
|
||||
[bem]: https://github.com/rajdee/posthtml-bem
|
||||
[bem-badge]: https://img.shields.io/npm/v/posthtml-bem.svg
|
||||
[bem-npm]: https://npmjs.com/package/posthtml-bem
|
||||
|
||||
[css]: https://github.com/posthtml/posthtml-postcss
|
||||
[css-badge]: https://img.shields.io/npm/v/posthtml-postcss.svg
|
||||
[css-npm]: https://npmjs.com/package/posthtml-postcss
|
||||
[css-gh]: https://github.com/postcss/postcss
|
||||
|
||||
[postcss-modules]: https://github.com/posthtml/posthtml-postcss-modules
|
||||
[postcss-modules-badge]: https://img.shields.io/npm/v/posthtml-postcss-modules.svg
|
||||
[postcss-modules-npm]: https://npmjs.com/package/posthtml-postcss-modules
|
||||
|
||||
[css-modules]: https://github.com/posthtml/posthtml-css-modules
|
||||
[css-modules-badge]: https://img.shields.io/npm/v/posthtml-css-modules.svg
|
||||
[css-modules-npm]: https://npmjs.com/package/posthtml-css-modules
|
||||
|
||||
[collect-styles]: https://github.com/posthtml/posthtml-collect-styles
|
||||
[collect-styles-badge]: https://img.shields.io/npm/v/posthtml-collect-styles.svg
|
||||
[collect-styles-npm]: https://npmjs.com/package/posthtml-collect-styles
|
||||
|
||||
[collect]: https://github.com/totora0155/posthtml-collect-inline-styles
|
||||
[collect-badge]: https://img.shields.io/npm/v/posthtml-collect-inline-styles.svg
|
||||
[collect-npm]: https://npmjs.com/package/posthtml-collect-inline-styles
|
||||
|
||||
[px2rem]: https://github.com/weixin/posthtml-px2rem
|
||||
[px2rem-badge]: https://img.shields.io/npm/v/posthtml-px2rem.svg
|
||||
[px2rem-npm]: https://npmjs.com/package/posthtml-px2rem
|
||||
|
||||
[classes]: https://github.com/rajdee/posthtml-classes
|
||||
[classes-badge]: https://img.shields.io/npm/v/posthtml-classes.svg
|
||||
[classes-npm]: https://npmjs.com/package/posthtml-classes
|
||||
|
||||
[prefix]: https://github.com/stevenbenisek/posthtml-prefix-class
|
||||
[prefix-badge]: https://img.shields.io/npm/v/posthtml-prefix-class.svg
|
||||
[prefix-npm]: https://npmjs.com/package/posthtml-prefix-class
|
||||
|
||||
[modular]: https://github.com/admdh/posthtml-modular-css
|
||||
[modular-badge]: https://img.shields.io/npm/v/posthtml-modular-css.svg
|
||||
[modular-npm]: https://npmjs.com/package/posthtml-modular-css
|
||||
|
||||
[in]: https://github.com/posthtml/posthtml-inline-css
|
||||
[in-badge]: https://img.shields.io/npm/v/posthtml-inline-css.svg
|
||||
[in-npm]: https://npmjs.com/package/posthtml-inline-css
|
||||
|
||||
[style]: https://github.com/posthtml/posthtml-style-to-file
|
||||
[style-badge]: https://img.shields.io/npm/v/posthtml-style-to-file.svg
|
||||
[style-npm]: https://npmjs.com/package/posthtml-style-to-file
|
||||
|
||||
[hex]: https://github.com/posthtml/posthtml-color-shorthand-hex-to-six-digit
|
||||
[hex-badge]: https://img.shields.io/npm/v/posthtml-color-shorthand-hex-to-six-digit.svg
|
||||
[hex-npm]: https://npmjs.com/package/posthtml-color-shorthand-hex-to-six-digit
|
||||
|
||||
[minify]: https://github.com/simonlc/posthtml-minify-classnames
|
||||
[minify-badge]: https://img.shields.io/npm/v/posthtml-minify-classnames.svg
|
||||
[minify-npm]: https://npmjs.com/package/posthtml-minify-classnames
|
||||
|
||||
#### IMG & SVG
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:-----|:----------|
|
||||
|[posthtml-img-autosize][img]|[![npm][img-badge]][img-npm]|Auto setting the width and height of \<img\>|
|
||||
|[posthtml-to-svg-tags][svg]|[![npm][svg-badge]][svg-npm]|Convert html tags to svg equals|
|
||||
|[posthtml-webp][webp]|[![npm][webp-badge]][webp-npm]|Add WebP support for images|
|
||||
|[posthtml-favicons][favicons]|[![npm][favicons-badge]][favicons-npm]|Generate Favicons and add related tags|
|
||||
|
||||
[img]: https://github.com/posthtml/posthtml-img-autosize
|
||||
[img-badge]: https://img.shields.io/npm/v/posthtml-img-autosize.svg
|
||||
[img-npm]: https://npmjs.com/package/posthtml-img-autosize
|
||||
|
||||
[svg]: https://github.com/theprotein/posthtml-to-svg-tags
|
||||
[svg-badge]: https://img.shields.io/npm/v/posthtml-to-svg-tags.svg
|
||||
[svg-npm]: https://npmjs.com/package/posthtml-to-svg-tags
|
||||
|
||||
[webp]: https://github.com/posthtml/posthtml-webp
|
||||
[webp-badge]: https://img.shields.io/npm/v/posthtml-webp.svg
|
||||
[webp-npm]: https://npmjs.com/package/posthtml-webp
|
||||
|
||||
[favicons]: https://github.com/mohsen1/posthtml-favicons
|
||||
[favicons-badge]: https://img.shields.io/npm/v/posthtml-favicons.svg
|
||||
[favicons-npm]: https://www.npmjs.com/package/posthtml-favicons
|
||||
|
||||
#### Accessibility
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:-----|:----------|
|
||||
|[posthtml-aria-tabs][aria]|[![npm][aria-badge]][aria-npm]|Write accessible tabs with minimal markup|
|
||||
|[posthtml-alt-always][alt]|[![npm][alt-badge]][alt-npm]|Always add alt attribute for images that don't have it|
|
||||
|[posthtml-schemas][schemas]|[![npm][schemas-badge]][schemas-npm]| Add microdata to your HTML|
|
||||
|
||||
|
||||
[alt]: https://github.com/ismamz/posthtml-alt-always
|
||||
[alt-badge]: https://img.shields.io/npm/v/posthtml-alt-always.svg
|
||||
[alt-npm]: https://npmjs.com/package/posthtml-alt-always
|
||||
|
||||
[aria]: https://github.com/jonathantneal/posthtml-aria-tabs
|
||||
[aria-badge]: https://img.shields.io/npm/v/posthtml-aria-tabs.svg
|
||||
[aria-npm]: https://npmjs.com/package/posthtml-aria-tabs
|
||||
|
||||
[schemas]: https://github.com/jonathantneal/posthtml-schemas
|
||||
[schemas-badge]: https://img.shields.io/npm/v/posthtml-schemas.svg
|
||||
[schemas-npm]: https://npmjs.com/package/posthtml-schemas
|
||||
|
||||
#### Optimization
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:-----|:----------|
|
||||
|[posthtml-shorten][shorten]|[![npm][shorten-badge]][shorten-npm]|Shorten URLs in HTML|
|
||||
|[posthtml-uglify][uglify]|[![npm][uglify-badge]][uglify-npm]|Shorten CSS in HTML|
|
||||
|[posthtml-minifier][minifier]|[![npm][minifier-badge]][minifier-npm]|Minify HTML|
|
||||
|[posthtml-remove-attributes][remove]|[![npm][remove-badge]][remove-npm]|Remove attributes unconditionally or with content match|
|
||||
|[posthtml-remove-tags][remove-tags]|[![npm][remove-tags-badge]][remove-tags-npm]|Remove tags with content match|
|
||||
|[posthtml-remove-duplicates][remove-duplicates]|[![npm][remove-duplicates-badge]][remove-duplicates-npm]|Remove duplicate elements from your html|
|
||||
|[posthtml-transformer][transform]|[![npm][transform-badge]][transform-npm]|Process HTML by directives in node attrs, such as inline scripts and styles, remove useless tags, concat scripts and styles etc.|
|
||||
|[htmlnano][nano]|[![npm][nano-badge]][nano-npm]|HTML Minifier|
|
||||
|[posthtml-link-noreferrer][noreferrer]|[![npm][noreferrer-badge]][noreferrer-npm]|Add `rel="noopener"` and `rel="noreferrer"` to all links that contain the attribute `target="_blank"` |
|
||||
|[posthtml-lazyload][lazyload]|[![npm][lazyload-badge]][lazyload-npm]|Add native lazyload attribute|
|
||||
|
||||
[remove]: https://github.com/princed/posthtml-remove-attributes
|
||||
[remove-badge]: https://img.shields.io/npm/v/posthtml-remove-attributes.svg
|
||||
[remove-npm]: https://npmjs.com/package/posthtml-remove-attributes
|
||||
|
||||
[remove-tags]: https://github.com/posthtml/posthtml-remove-tags
|
||||
[remove-tags-badge]: https://img.shields.io/npm/v/posthtml-remove-tags.svg
|
||||
[remove-tags-npm]: https://npmjs.com/package/posthtml-remove-tags
|
||||
|
||||
[remove-duplicates]: https://github.com/canvaskisa/posthtml-remove-duplicates
|
||||
[remove-duplicates-badge]: https://img.shields.io/npm/v/posthtml-remove-duplicates.svg
|
||||
[remove-duplicates-npm]: https://npmjs.com/package/posthtml-remove-duplicates
|
||||
|
||||
[minifier]: https://github.com/Rebelmail/posthtml-minifier
|
||||
[minifier-badge]: https://img.shields.io/npm/v/posthtml-minifier.svg
|
||||
[minifier-npm]: https://npmjs.com/package/posthtml-minifier
|
||||
|
||||
[shorten]: https://github.com/Rebelmail/posthtml-shorten
|
||||
[shorten-badge]: https://img.shields.io/npm/v/posthtml-shorten.svg
|
||||
[shorten-npm]: https://npmjs.com/package/posthtml-shorten
|
||||
|
||||
[uglify]: https://github.com/Rebelmail/posthtml-uglify
|
||||
[uglify-badge]: https://img.shields.io/npm/v/posthtml-uglify.svg
|
||||
[uglify-npm]: https://npmjs.com/package/posthtml-uglify
|
||||
|
||||
[nano]: https://github.com/maltsev/htmlnano
|
||||
[nano-badge]: https://img.shields.io/npm/v/htmlnano.svg
|
||||
[nano-npm]: https://npmjs.com/package/htmlnano
|
||||
|
||||
[transform]: https://github.com/flashlizi/posthtml-transformer
|
||||
[transform-badge]: https://img.shields.io/npm/v/posthtml-transformer.svg
|
||||
[transform-npm]: https://npmjs.com/package/posthtml-transformer
|
||||
|
||||
[noreferrer]: https://github.com/webistomin/posthtml-link-noreferrer
|
||||
[noreferrer-badge]: https://img.shields.io/npm/v/posthtml-link-noreferrer.svg
|
||||
[noreferrer-npm]: https://www.npmjs.com/package/posthtml-link-noreferrer
|
||||
|
||||
[lazyload]: https://github.com/webistomin/posthtml-lazyload
|
||||
[lazyload-badge]: https://img.shields.io/npm/v/posthtml-link-noreferrer.svg
|
||||
[lazyload-npm]: https://www.npmjs.com/package/posthtml-lazyload
|
||||
|
||||
#### Workflow
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:-----|:----------|
|
||||
|[posthtml-load-plugins][plugins]|[![npm][plugins-badge]][plugins-npm]|Autoload Plugins
|
||||
|[posthtml-load-options][options]|[![npm][options-badge]][options-npm]|Autoload Options (Parser && Render)|
|
||||
|[posthtml-load-config][config]|[![npm][config-badge]][config-npm]|Autoload Config (Plugins && Options)|
|
||||
|[posthtml-w3c][w3c]|[![npm][w3c-badge]][w3c-npm]|Validate HTML with W3C Validation|
|
||||
|[posthtml-hint][hint]|[![npm][hint-badge]][hint-npm]|Lint HTML with HTML Hint|
|
||||
|[posthtml-tidy][tidy]|[![npm][tidy-badge]][tidy-npm]|Sanitize HTML with HTML Tidy|
|
||||
|
||||
[options]: https://github.com/posthtml/posthtml-load-options
|
||||
[options-badge]: https://img.shields.io/npm/v/posthtml-load-options.svg
|
||||
[options-npm]: https://npmjs.com/package/posthtml-load-options
|
||||
|
||||
[plugins]: https://github.com/posthtml/posthtml-load-plugins
|
||||
[plugins-badge]: https://img.shields.io/npm/v/posthtml-load-plugins.svg
|
||||
[plugins-npm]: https://npmjs.com/package/posthtml-load-plugins
|
||||
|
||||
[config]: https://github.com/posthtml/posthtml-load-config
|
||||
[config-badge]: https://img.shields.io/npm/v/posthtml-load-config.svg
|
||||
[config-npm]: https://npmjs.com/package/posthtml-load-config
|
||||
|
||||
[tidy]: https://github.com/michael-ciniawsky/posthtml-tidy
|
||||
[tidy-badge]: https://img.shields.io/npm/v/posthtml-tidy.svg
|
||||
[tidy-npm]: https://npmjs.com/package/posthtml-tidy
|
||||
|
||||
[hint]: https://github.com/posthtml/posthtml-hint
|
||||
[hint-badge]: https://img.shields.io/npm/v/posthtml-hint.svg
|
||||
[hint-npm]: https://npmjs.com/package/posthtml-hint
|
||||
|
||||
[w3c]: https://github.com/posthtml/posthtml-w3c
|
||||
[w3c-badge]: https://img.shields.io/npm/v/posthtml-w3c.svg
|
||||
[w3c-npm]: https://npmjs.com/package/posthtml-w3c
|
||||
|
||||
## Middleware
|
||||
|
||||
|Name|Status|Description|
|
||||
|:---|:-----|:----------|
|
||||
|[koa-posthtml][koa]|[![npm][koa-badge]][koa-npm]|Koa Middleware|
|
||||
|[hapi-posthtml][hapi]|[![npm][hapi-badge]][hapi-npm]|Hapi Plugin|
|
||||
|[express-posthtml][express]|[![npm][express-badge]][express-npm]|Express Middleware|
|
||||
|[electron-posthtml][electron]|[![npm][electron-badge]][electron-npm]|Electron Plugin|
|
||||
|[metalsmith-posthtml][metalsmith]|[![npm][metalsmith-badge]][metalsmith-npm]|Metalsmith Plugin|
|
||||
|
||||
|
||||
[koa]: https://github.com/posthtml/koa-posthtml
|
||||
[koa-badge]: https://img.shields.io/npm/v/koa-posthtml.svg
|
||||
[koa-npm]: https://npmjs.com/package/koa-posthtml
|
||||
|
||||
[hapi]: https://github.com/posthtml/hapi-posthtml
|
||||
[hapi-badge]: https://img.shields.io/npm/v/hapi-posthtml.svg
|
||||
[hapi-npm]: https://npmjs.com/package/hapi-posthtml
|
||||
|
||||
[express]: https://github.com/posthtml/express-posthtml
|
||||
[express-badge]: https://img.shields.io/npm/v/express-posthtml.svg
|
||||
[express-npm]: https://npmjs.com/package/express-posthtml
|
||||
|
||||
[electron]: https://github.com/posthtml/electron-posthtml
|
||||
[electron-badge]: https://img.shields.io/npm/v/electron-posthtml.svg
|
||||
[electron-npm]: https://npmjs.com/package/electron-posthtml
|
||||
|
||||
[metalsmith]: https://github.com/posthtml/metalsmith-posthtml
|
||||
[metalsmith-badge]: https://img.shields.io/npm/v/metalsmith-posthtml.svg
|
||||
[metalsmith-npm]: https://npmjs.com/package/metalsmith-posthtml
|
||||
|
||||
## Maintainers
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img width="150 height="150"
|
||||
src="https://avatars0.githubusercontent.com/u/2789192?s=460&v=4">
|
||||
<br />
|
||||
<a href="https://github.com/scrum">Ivan Demidov</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img width="150 height="150"
|
||||
src="https://avatars.githubusercontent.com/u/1510217?v=3&s=150">
|
||||
<br />
|
||||
<a href="https://github.com/voischev">Ivan Voischev</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img width="150 height="150"
|
||||
src="https://avatars.githubusercontent.com/u/982072?v=3&s=150">
|
||||
<br />
|
||||
<a href="https://github.com/awinogradov">Anton Winogradov</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img width="150 height="150"
|
||||
src="https://avatars.githubusercontent.com/u/677518?v=3&s=150">
|
||||
<br />
|
||||
<a href="https://github.com/zxqfox">Alexej Yaroshevich</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img width="150 height="150"
|
||||
src="https://avatars.githubusercontent.com/u/1813468?v=3&s=150">
|
||||
<br />
|
||||
<a href="https://github.com/Yeti-or">Vasiliy</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tbody>
|
||||
</table>
|
||||
|
||||
## Contributing
|
||||
|
||||
See [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs) and [CONTRIBUTING](CONTRIBUTING.md).
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
|
||||
[npm]: https://img.shields.io/npm/v/posthtml.svg
|
||||
[npm-url]: https://npmjs.com/package/posthtml
|
||||
|
||||
[deps]: https://david-dm.org/posthtml/posthtml.svg
|
||||
[deps-url]: https://david-dm.org/posthtml/posthtml
|
||||
|
||||
[build]: https://travis-ci.org/posthtml/posthtml.svg?branch=master
|
||||
[build-url]: https://travis-ci.org/posthtml/posthtml?branch=master
|
||||
|
||||
[cover]: https://coveralls.io/repos/posthtml/posthtml/badge.svg?branch=master
|
||||
[cover-url]: https://coveralls.io/r/posthtml/posthtml?branch=master
|
||||
|
||||
[code-style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
|
||||
[code-style-url]: http://standardjs.com/
|
||||
|
||||
[chat]: https://badges.gitter.im/posthtml/posthtml.svg
|
||||
[chat-url]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"
|
||||
149
BACK_BACK/node_modules/posthtml/lib/api.js
generated
vendored
Executable file
149
BACK_BACK/node_modules/posthtml/lib/api.js
generated
vendored
Executable file
|
|
@ -0,0 +1,149 @@
|
|||
'use strict'
|
||||
|
||||
/**
|
||||
* # API
|
||||
*
|
||||
* @author Ivan Voischev (@voischev),
|
||||
* Anton Winogradov (@awinogradov),
|
||||
* Alexej Yaroshevich (@zxqfox),
|
||||
* Vasiliy (@Yeti-or)
|
||||
*
|
||||
* @namespace tree
|
||||
*/
|
||||
function Api () {
|
||||
this.walk = walk
|
||||
this.match = match
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks the tree and passes all nodes via a callback
|
||||
*
|
||||
* @memberof tree
|
||||
*
|
||||
* @param {Function} cb Callback
|
||||
* @return {Function} Callback(node)
|
||||
*
|
||||
*@example
|
||||
* ```js
|
||||
* export const walk = (tree) => {
|
||||
* tree.walk((node) => {
|
||||
* let classes = node.attrs && node.attrs.class.split(' ') || []
|
||||
*
|
||||
* if (classes.includes(className)) return cb(node)
|
||||
* return node
|
||||
* })
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function walk (cb) {
|
||||
return traverse(this, cb)
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches an expression to search for nodes in the tree
|
||||
*
|
||||
* @memberof tree
|
||||
*
|
||||
* @param {String|RegExp|Object|Array} expression - Matcher(s) to search
|
||||
* @param {Function} cb Callback
|
||||
*
|
||||
* @return {Function} Callback(node)
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* export const match = (tree) => {
|
||||
* // Single matcher
|
||||
* tree.match({ tag: 'custom-tag' }, (node) => {
|
||||
* let tag = node.tag
|
||||
*
|
||||
* Object.assign(node, { tag: 'div', attrs: {class: tag} })
|
||||
*
|
||||
* return node
|
||||
* })
|
||||
* // Multiple matchers
|
||||
* tree.match([{ tag: 'b' }, { tag: 'strong' }], (node) => {
|
||||
* let style = 'font-weight: bold;'
|
||||
*
|
||||
* node.tag = 'span'
|
||||
*
|
||||
* node.attrs
|
||||
* ? ( node.attrs.style
|
||||
* ? ( node.attrs.style += style )
|
||||
* : node.attrs.style = style
|
||||
* )
|
||||
* : node.attrs = { style: style }
|
||||
*
|
||||
* return node
|
||||
* })
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function match (expression, cb) {
|
||||
return Array.isArray(expression)
|
||||
? traverse(this, function (node) {
|
||||
for (var i = 0; i < expression.length; i++) {
|
||||
if (compare(expression[i], node)) return cb(node)
|
||||
}
|
||||
|
||||
return node
|
||||
})
|
||||
: traverse(this, function (node) {
|
||||
if (compare(expression, node)) return cb(node)
|
||||
|
||||
return node
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = Api
|
||||
module.exports.match = match
|
||||
module.exports.walk = walk
|
||||
|
||||
/** @private */
|
||||
function traverse (tree, cb) {
|
||||
if (Array.isArray(tree)) {
|
||||
for (var i = 0; i < tree.length; i++) {
|
||||
tree[i] = traverse(cb(tree[i]), cb)
|
||||
}
|
||||
} else if (
|
||||
tree &&
|
||||
typeof tree === 'object' &&
|
||||
Object.prototype.hasOwnProperty.call(tree, 'content')
|
||||
) traverse(tree.content, cb)
|
||||
|
||||
return tree
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function compare (expected, actual) {
|
||||
if (expected instanceof RegExp) {
|
||||
if (typeof actual === 'object') return false
|
||||
if (typeof actual === 'string') return expected.test(actual)
|
||||
}
|
||||
|
||||
if (typeof expected !== typeof actual) return false
|
||||
if (typeof expected !== 'object' || expected === null) {
|
||||
return expected === actual
|
||||
}
|
||||
|
||||
if (Array.isArray(expected)) {
|
||||
return expected.every(function (exp) {
|
||||
return [].some.call(actual, function (act) {
|
||||
return compare(exp, act)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return Object.keys(expected).every(function (key) {
|
||||
var ao = actual[key]
|
||||
var eo = expected[key]
|
||||
|
||||
if (typeof eo === 'object' && eo !== null && ao !== null) {
|
||||
return compare(eo, ao)
|
||||
}
|
||||
if (typeof eo === 'boolean') {
|
||||
return eo !== (ao == null)
|
||||
}
|
||||
|
||||
return ao === eo
|
||||
})
|
||||
}
|
||||
294
BACK_BACK/node_modules/posthtml/lib/index.js
generated
vendored
Executable file
294
BACK_BACK/node_modules/posthtml/lib/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,294 @@
|
|||
var pkg = require('../package.json')
|
||||
var Api = require('./api.js')
|
||||
|
||||
var parser = require('posthtml-parser')
|
||||
var render = require('posthtml-render')
|
||||
|
||||
/**
|
||||
* @author Ivan Voischev (@voischev),
|
||||
* Anton Winogradov (@awinogradov),
|
||||
* Alexej Yaroshevich (@zxqfox),
|
||||
* Vasiliy (@Yeti-or)
|
||||
*
|
||||
* @requires api
|
||||
* @requires posthtml-parser
|
||||
* @requires posthtml-render
|
||||
*
|
||||
* @constructor PostHTML
|
||||
* @param {Array} plugins - An array of PostHTML plugins
|
||||
*/
|
||||
function PostHTML (plugins) {
|
||||
/**
|
||||
* PostHTML Instance
|
||||
*
|
||||
* @prop plugins
|
||||
* @prop options
|
||||
*/
|
||||
this.version = pkg.version
|
||||
this.name = pkg.name
|
||||
this.plugins = typeof plugins === 'function' ? [plugins] : plugins || []
|
||||
|
||||
/**
|
||||
* Tree messages to store and pass metadata between plugins
|
||||
*
|
||||
* @memberof tree
|
||||
* @type {Array} messages
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* export default function plugin (options = {}) {
|
||||
* return function (tree) {
|
||||
* tree.messages.push({
|
||||
* type: 'dependency',
|
||||
* file: 'path/to/dependency.html',
|
||||
* from: tree.options.from
|
||||
* })
|
||||
*
|
||||
* return tree
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
this.messages = []
|
||||
|
||||
// extend api methods
|
||||
Api.call(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires posthtml-parser
|
||||
*
|
||||
* @param {String} html - Input (HTML)
|
||||
* @returns {Array} tree - PostHTMLTree (JSON)
|
||||
*/
|
||||
PostHTML.parser = parser
|
||||
/**
|
||||
* @requires posthtml-render
|
||||
*
|
||||
* @param {Array} tree - PostHTMLTree (JSON)
|
||||
* @returns {String} html - HTML
|
||||
*/
|
||||
PostHTML.render = render
|
||||
|
||||
/**
|
||||
* @this posthtml
|
||||
* @param {Function} plugin - A PostHTML plugin
|
||||
* @returns {Constructor} - this(PostHTML)
|
||||
*
|
||||
* **Usage**
|
||||
* ```js
|
||||
* ph.use((tree) => { tag: 'div', content: tree })
|
||||
* .process('<html>..</html>', {})
|
||||
* .then((result) => result))
|
||||
* ```
|
||||
*/
|
||||
PostHTML.prototype.use = function () {
|
||||
[].push.apply(this.plugins, arguments)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} html - Input (HTML)
|
||||
* @param {?Object} options - PostHTML Options
|
||||
* @returns {Object<{html: String, tree: PostHTMLTree}>} - Sync Mode
|
||||
* @returns {Promise<{html: String, tree: PostHTMLTree}>} - Async Mode (default)
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
* **Sync**
|
||||
* ```js
|
||||
* ph.process('<html>..</html>', { sync: true }).html
|
||||
* ```
|
||||
*
|
||||
* **Async**
|
||||
* ```js
|
||||
* ph.process('<html>..</html>', {}).then((result) => result))
|
||||
* ```
|
||||
*/
|
||||
PostHTML.prototype.process = function (tree, options) {
|
||||
/**
|
||||
* ## PostHTML Options
|
||||
*
|
||||
* @type {Object}
|
||||
* @prop {?Boolean} options.sync - enables sync mode, plugins will run synchronously, throws an error when used with async plugins
|
||||
* @prop {?Function} options.parser - use custom parser, replaces default (posthtml-parser)
|
||||
* @prop {?Function} options.render - use custom render, replaces default (posthtml-render)
|
||||
* @prop {?Boolean} options.skipParse - disable parsing
|
||||
*/
|
||||
options = this.options = options || {}
|
||||
|
||||
if (options.parser) parser = options.parser
|
||||
if (options.render) render = options.render
|
||||
|
||||
tree = options.skipParse
|
||||
? tree || []
|
||||
: parser(tree, options)
|
||||
|
||||
// sync mode
|
||||
if (options.sync === true) {
|
||||
this.plugins.forEach(function (plugin, index) {
|
||||
_treeExtendApi(tree, this)
|
||||
|
||||
var result
|
||||
|
||||
if (plugin.length === 2 || isPromise(result = plugin(tree))) {
|
||||
throw new Error(
|
||||
'Can’t process contents in sync mode because of async plugin: ' + plugin.name
|
||||
)
|
||||
}
|
||||
|
||||
// clearing the tree of options
|
||||
if (index !== this.plugins.length - 1 && !options.skipParse) {
|
||||
tree = [].concat(tree)
|
||||
}
|
||||
|
||||
// return the previous tree unless result is fulfilled
|
||||
tree = result || tree
|
||||
}.bind(this))
|
||||
|
||||
return lazyResult(render, tree)
|
||||
}
|
||||
|
||||
// async mode
|
||||
var i = 0
|
||||
|
||||
var next = function (result, cb) {
|
||||
_treeExtendApi(result, this)
|
||||
|
||||
// all plugins called
|
||||
if (this.plugins.length <= i) {
|
||||
cb(null, result)
|
||||
return
|
||||
}
|
||||
|
||||
// little helper to go to the next iteration
|
||||
function _next (res) {
|
||||
if (res && !options.skipParse) {
|
||||
res = [].concat(res)
|
||||
}
|
||||
|
||||
return next(res || result, cb)
|
||||
}
|
||||
|
||||
// call next
|
||||
var plugin = this.plugins[i++]
|
||||
|
||||
if (plugin.length === 2) {
|
||||
plugin(result, function (err, res) {
|
||||
if (err) return cb(err)
|
||||
_next(res)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// sync and promised plugins
|
||||
var err = null
|
||||
|
||||
var res = tryCatch(function () {
|
||||
return plugin(result)
|
||||
}, function (e) {
|
||||
err = e
|
||||
return e
|
||||
})
|
||||
|
||||
if (err) {
|
||||
cb(err)
|
||||
return
|
||||
}
|
||||
|
||||
if (isPromise(res)) {
|
||||
res.then(_next).catch(cb)
|
||||
return
|
||||
}
|
||||
|
||||
_next(res)
|
||||
}.bind(this)
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
next(tree, function (err, tree) {
|
||||
if (err) reject(err)
|
||||
else resolve(lazyResult(render, tree))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @exports posthtml
|
||||
*
|
||||
* @param {Array} plugins
|
||||
* @return {Function} posthtml
|
||||
*
|
||||
* **Usage**
|
||||
* ```js
|
||||
* import posthtml from 'posthtml'
|
||||
* import plugin from 'posthtml-plugin'
|
||||
*
|
||||
* const ph = posthtml([ plugin() ])
|
||||
* ```
|
||||
*/
|
||||
module.exports = function (plugins) {
|
||||
return new PostHTML(plugins)
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension of options tree
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Array} tree
|
||||
* @param {Object} PostHTML
|
||||
* @returns {?*}
|
||||
*/
|
||||
function _treeExtendApi (t, _t) {
|
||||
if (typeof t === 'object') {
|
||||
t = Object.assign(t, _t)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if parameter is a Promise (or thenable) object.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {*} promise - Target `{}` to test
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function isPromise (promise) {
|
||||
return !!promise && typeof promise.then === 'function'
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple try/catch helper, if exists, returns result
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Function} tryFn - try block
|
||||
* @param {Function} catchFn - catch block
|
||||
* @returns {?*}
|
||||
*/
|
||||
function tryCatch (tryFn, catchFn) {
|
||||
try {
|
||||
return tryFn()
|
||||
} catch (err) {
|
||||
catchFn(err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the PostHTMLTree within an object using a getter to render HTML on demand.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Function} render
|
||||
* @param {Array} tree
|
||||
* @returns {Object<{html: String, tree: Array}>}
|
||||
*/
|
||||
function lazyResult (render, tree) {
|
||||
return {
|
||||
get html () {
|
||||
return render(tree, tree.options)
|
||||
},
|
||||
tree: tree,
|
||||
messages: tree.messages
|
||||
}
|
||||
}
|
||||
67
BACK_BACK/node_modules/posthtml/package.json
generated
vendored
Executable file
67
BACK_BACK/node_modules/posthtml/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"name": "posthtml",
|
||||
"version": "0.11.6",
|
||||
"description": "HTML/XML processor",
|
||||
"keywords": [
|
||||
"html",
|
||||
"xml",
|
||||
"postproccessor",
|
||||
"parser",
|
||||
"transform",
|
||||
"transformations",
|
||||
"manipulation",
|
||||
"preprocessor",
|
||||
"processor"
|
||||
],
|
||||
"main": "lib",
|
||||
"types": "types/posthtml.d.ts",
|
||||
"files": [
|
||||
"types",
|
||||
"lib"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"posthtml-parser": "^0.4.1",
|
||||
"posthtml-render": "^1.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.0.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"coveralls": "^3.0.6",
|
||||
"jsdoc-to-markdown": "^5.0.0",
|
||||
"mocha": "^6.2.0",
|
||||
"nyc": "^14.1.1",
|
||||
"standard": "^14.1.0",
|
||||
"standard-version": "^7.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard --env mocha",
|
||||
"test": "npm run lint && nyc mocha",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"docs:api": "jsdoc2md lib/api.js > docs/api.md",
|
||||
"docs:core": "jsdoc2md lib/index.js > docs/core.md",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"author": "Anton Winogradov <winogradovaa@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Ivan Voischev",
|
||||
"email": "voischev.ivan@ya.ru"
|
||||
},
|
||||
{
|
||||
"name": "Anton Winogradov",
|
||||
"email": "winogradovaa@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Alexej Yaroshevich",
|
||||
"email": "zxqfox@gmail.com"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/posthtml/posthtml",
|
||||
"repository": "https://github.com/posthtml/posthtml.git",
|
||||
"bugs": "https://github.com/posthtml/posthtml/issues",
|
||||
"license": "MIT"
|
||||
}
|
||||
105
BACK_BACK/node_modules/posthtml/types/posthtml.d.ts
generated
vendored
Executable file
105
BACK_BACK/node_modules/posthtml/types/posthtml.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,105 @@
|
|||
type Maybe<T> = void | T;
|
||||
type MaybeArray<T> = T | T[];
|
||||
|
||||
export namespace PostHTML {
|
||||
type StringMatcher = string | RegExp;
|
||||
type AttrMatcher = Record<string, StringMatcher>;
|
||||
type ContentMatcher =
|
||||
| StringMatcher[]
|
||||
| {
|
||||
tag?: StringMatcher;
|
||||
attrs?: AttrMatcher;
|
||||
content?: ContentMatcher[];
|
||||
};
|
||||
|
||||
export type Matcher<
|
||||
TTag extends StringMatcher,
|
||||
TAttrs extends Maybe<AttrMatcher>
|
||||
> =
|
||||
| StringMatcher
|
||||
| {
|
||||
tag?: TTag;
|
||||
attrs?: TAttrs;
|
||||
content?: ContentMatcher[];
|
||||
};
|
||||
|
||||
export type Expression<
|
||||
TTag extends StringMatcher,
|
||||
TAttrs extends Maybe<AttrMatcher>
|
||||
> = MaybeArray<Matcher<TTag, TAttrs>>;
|
||||
|
||||
export type NodeCallback<
|
||||
TTag extends Maybe<string> = Maybe<string>,
|
||||
TAttrs extends Maybe<NodeAttributes> = Maybe<NodeAttributes>
|
||||
> = (node: Node<TTag, TAttrs>) => MaybeArray<Node | RawNode>;
|
||||
|
||||
export type NodeAttributes = Record<string, Maybe<string>>;
|
||||
|
||||
interface NodeAPI {
|
||||
walk: (cb: NodeCallback) => Node;
|
||||
match: <
|
||||
TTag extends StringMatcher,
|
||||
TAttrs extends Maybe<AttrMatcher>,
|
||||
TTagResult extends Maybe<string> = TTag extends string
|
||||
? TTag
|
||||
: TTag extends void
|
||||
? Maybe<string>
|
||||
: string,
|
||||
TAttrResult extends Maybe<NodeAttributes> = TAttrs extends void
|
||||
? Maybe<NodeAttributes>
|
||||
: {
|
||||
[P in keyof TAttrs]: string;
|
||||
} &
|
||||
NodeAttributes
|
||||
>(
|
||||
expression: Expression<TTag, TAttrs>,
|
||||
cb: NodeCallback<TTagResult, TAttrResult>
|
||||
) => Node<TTagResult, TAttrResult>[];
|
||||
}
|
||||
|
||||
export interface RawNode<
|
||||
TTag extends Maybe<string> = Maybe<string>,
|
||||
TAttrs extends Maybe<NodeAttributes> = Maybe<NodeAttributes>
|
||||
> {
|
||||
tag: TTag;
|
||||
attrs: TAttrs;
|
||||
content?: Array<string | RawNode>;
|
||||
}
|
||||
|
||||
export interface Node<
|
||||
TTag extends Maybe<string> = Maybe<string>,
|
||||
TAttrs extends Maybe<NodeAttributes> = Maybe<NodeAttributes>
|
||||
> extends NodeAPI, RawNode<TTag, TAttrs> {
|
||||
content?: Array<string | Node>;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
sync?: boolean;
|
||||
parser?: Function;
|
||||
render?: Function;
|
||||
skipParse?: boolean;
|
||||
}
|
||||
|
||||
export type Plugin<TThis> = (
|
||||
tree: Node
|
||||
) => void | Node | RawNode | ThisType<TThis>;
|
||||
|
||||
export interface Result<TMessage> {
|
||||
html: string;
|
||||
tree: Node;
|
||||
messages: TMessage[];
|
||||
}
|
||||
|
||||
export interface PostHTML<TThis, TMessage> {
|
||||
version: string;
|
||||
name: "";
|
||||
plugins: Plugin<TThis>[];
|
||||
messages: TMessage[];
|
||||
use<TThis>(plugins: MaybeArray<Plugin<TThis>>): this;
|
||||
process(html: string, options?: Options): Promise<Result<TMessage>>;
|
||||
}
|
||||
}
|
||||
|
||||
export default function posthtml<TThis, TMessage>(
|
||||
plugins?: PostHTML.Plugin<TThis>[]
|
||||
): PostHTML.PostHTML<TThis, TMessage>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue