Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

posthtml

Package Overview
Dependencies
Maintainers
3
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthtml - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

14

CHANGELOG.md

@@ -0,1 +1,15 @@

<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>

@@ -2,0 +16,0 @@ ### 0.4.1 (2015-10-04)

19

lib/api.js

@@ -29,3 +29,3 @@ 'use strict';

* match expression for of his search in nodes of tree
* @param {*} expression Object/String... for search. Array is an enumeration expressions
* @param {String|RegExp|Object|Array.<String|RegExp|Object>} expression - Matcher(s) to search
* @param {Function} cb Callbak function

@@ -91,2 +91,3 @@ * @return {Function} Node in callback

/** @private */
function traverse(tree, cb) {

@@ -110,15 +111,13 @@ if (Array.isArray(tree)) {

/** @private */
function compare(expected, actual) {
if (typeof actual !== typeof expected) {
return false;
if (expected instanceof RegExp) {
if (typeof actual === 'object') return false;
if (typeof actual === 'string') return expected.test(actual);
}
if (typeof expected !== 'object' || expected === null) {
return expected === actual;
}
if (typeof expected !== typeof actual) return false;
if (typeof expected !== 'object' || expected === null) return expected === actual;
if (!!expected && !actual) return false;
if (!!expected && !actual) {
return false;
}
if (Array.isArray(expected)) {

@@ -125,0 +124,0 @@ var _ret = (function () {

{
"name": "posthtml",
"version": "0.4.1",
"version": "0.5.0",
"description": "HTML/XML processor",

@@ -5,0 +5,0 @@ "keywords": [

@@ -81,5 +81,30 @@ # PostHTML

Check [project-stub](https://github.com/posthtml/project-stub) example with Gulp
## Plugins
- [posthtml-bem](https://github.com/rajdee/posthtml-bem) — Support BEM naming in html structure
- [posthtml-retext](https://github.com/voischev/posthtml-retext) — Extensible system for analysing and manipulating natural language
- [posthtml-textr](https://github.com/voischev/posthtml-textr) — Modular typographic framework
- [posthtml-custom-elements](https://github.com/posthtml/posthtml-custom-elements) — Use custom elements now
- [posthtml-style-to-file](https://github.com/posthtml/posthtml-style-to-file) — Save HTML style nodes and attributes to CSS file
- [posthtml-doctype](https://github.com/posthtml/posthtml-doctype) — Extend html tags doctype
- [posthtml-include](https://github.com/posthtml/posthtml-include) — Include html file
- [posthtml-to-svg-tags](https://github.com/theprotein/posthtml-to-svg-tags) — Convert html tags to svg equals
- [posthtml-extend-attrs](https://github.com/theprotein/posthtml-extend-attrs) — Extend html tags attributes with custom data and attributes
- [posthtml-modular-css](https://github.com/admdh/posthtml-modular-css) — Makes css modular
## Ideas for plugins
- [posthtml-imports](https://github.com/posthtml/posthtml-imports) — Support W3C HTML imports
- [posthtml-style](https://github.com/posthtml/posthtml-style) — Include css file in HTML. Save \<style\>, style attrs to CSS file
- [beml](https://github.com/zenwalker/node-beml) — HTML preprocessor for BEM
- [mimic](http://peterchon.github.io/mimic/)
Something more? ;)
## PostHTML JSON tree example
__input HTML__
#### input HTML
```html

@@ -91,3 +116,3 @@ <a class="animals" href="#">

__Tree in PostHTML (PostHTMLTree)__
#### Tree in PostHTML (PostHTMLTree)
```javascript

@@ -100,10 +125,14 @@ [{

},
content: [{
tag: 'span',
attrs: {
class: 'animals__cat',
style: 'background: url(cat.png)'
content: [
'\n ',
{
tag: 'span',
attrs: {
class: 'animals__cat',
style: 'background: url(cat.png)'
},
content: ['Cat']
},
content: ['Cat']
}]
'\n'
]
}]

@@ -183,6 +212,8 @@ ```

### .parse ({String} html): {PostHTMLTree}
### .parse({String} html)
Parses HTML string into a PostHTMLTree object.
### .use ({Function} plugin): {PostHTML}
__Returns__: `{PostHTMLTree}`
### .use({Function} plugin)
Adds a plugin into the flow.

@@ -200,7 +231,10 @@

### .process ({String|PostHTMLTree} html, {Object} options): {{tree: PostHTMLTree, html: String}}
### .process({String|PostHTMLTree} html[, {Object} options])
Applies all plugins to the incoming `html` object.
Returns (eventually) an Object with modified html and/or tree.
__Returns__: `{{tree: PostHTMLTree, html: String}}`
(eventually) an Object with modified html and/or tree.
#### Example

@@ -303,3 +337,3 @@

### .match ({Object|String}, {function(PostHTMLNode): PostHTMLNode|String})
### .match ({Object|String|RegExp}, {function(PostHTMLNode): PostHTMLNode|String})
Find subtree in tree, run callback.

@@ -348,23 +382,4 @@

## License
## Plugins
- [posthtml-textr](https://npmjs.com/package/posthtml-textr) — Modular typographic framework
- [posthtml-custom-elements](https://npmjs.com/package/posthtml-custom-elements) — Use custom elements now
- [posthtml-style-to-file](https://npmjs.com/package/posthtml-style-to-file) — Save HTML style nodes and attributes to CSS file
- [posthtml-doctype](https://npmjs.com/package/posthtml-doctype) — Extend html tags doctype
- [posthtml-to-svg-tags](https://github.com/theprotein/posthtml-to-svg-tags) — Convert html tags to svg equals
- [posthtml-extend-attrs](https://github.com/theprotein/posthtml-extend-attrs) — Extend html tags attributes with custom data and attributes
- [posthtml-modular-css](https://github.com/admdh/posthtml-modular-css) — Makes css modular
## Ideas for plugins
- [retext](https://github.com/wooorm/retext) — Extensible system for analysing and manipulating natural language
- [posthtml-include](https://github.com/posthtml/posthtml-include) — Include html file
- [posthtml-imports](https://github.com/posthtml/posthtml-imports) — Support W3C HTML imports
- [posthtml-style](https://github.com/posthtml/posthtml-style) — Include css file in HTML. Save \<style\>, style attrs to CSS file
- [posthtml-classes](https://github.com/posthtml/posthtml-classes) — Configure node in classes
- [beml](https://github.com/zenwalker/node-beml) — HTML preprocessor for BEM
- [mimic](http://peterchon.github.io/mimic/)
Something more? ;)
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc