# html-pipe **Repository Path**: mirrors_Automattic/html-pipe ## Basic Information - **Project Name**: html-pipe - **Description**: Pluggable HTML Pipeline - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-07-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # html-pipe Pluggable HTML Pipeline ## Installation Install with [component(1)](http://component.io): $ component install automattic/html-pipe ## Example ```html
this is a wonderful example of our html pipeline!
``` ```js var p = document.getElementsByTagName('p')[0]; var out = htmlpipe(p) .pipe(sanitize) .pipe(highlight) .run() // unwrap spans with inline styles function sanitize(el) { if ('SPAN' == el.nodeName && el.getAttribute('style')) { return false; } } // turn em's into mark's function highlight(el) { if ('EM' == el.nodeName) { var mark = document.createElement('mark'); mark.innerHTML = el.innerHTML; return mark; } } console.log(out.innerHTML); // this is a wonderful example of our html pipeline! ``` ## API ### HTMLPipe(el) Initialize the pipeline with `el`. ### htmlpipe#pipe(fn) Add a transform to the pipeline. The pipeline changes it's action based on the return value of `fn`. Here's a list of possible values: - `undefined`: skip the transform and move to the next one - `null`: remove the node from the transform. skip remaining transforms for the node. - `false`: unwrap the node, so it's contents are at the same level as the original node. skip remaining transforms on unwrapped node, moving on to the first child. - `node (self)`: returning the current node will skip over the rest of its children and skip the remaining transforms for the node. - `node`: replace the current node with a new node. pass the new node through the rest of the transforms - `string` or `number`: replace the current node with a textnode containing the string or number. pass the textnode through the rest of the transforms Check out the tests to see each of these transforms in action. ### htmlpipe#run() Run the pipeline, returning the transformed `el`. ## Testing ```js npm install component-test make test ``` ## License The MIT License (MIT) Copyright (c) 2014