1.0.0 • Published 1 year ago

html-sed v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

html-sed: HTML stream editor as Transform stream for Node.js

The html-sed is the transform stream implementation that edits HTML like UNIX's sed tool.

This tool executes edit processes such as text replacement on a per HTML element (HTML tag) basis. So it does not require a large amount of memory and can avoid unintentional editing.

Example

substitute HTML tag

import fs from 'fs';
import { HtmlSed } from 'html-sed';

const hsed = new HtmlSed();

// create input and output stream
const inputStream = fs.createReadStream('input.html',
                                        { encoding: 'utf8', });
const outputStream = fs.createWriteStream('output.html');

// substitute `<body>` tag to `<body class="test">` tag
hsed.substitute(/<body>/, '<body class="test">');


// execute replace and output
inputStream.pipe(hsed).pipe(outputStream);

License

MIT