https://github.com/frameable/html-text-weaver
Encode html to its component plain-text and meta style parts
https://github.com/frameable/html-text-weaver
Last synced: 11 months ago
JSON representation
Encode html to its component plain-text and meta style parts
- Host: GitHub
- URL: https://github.com/frameable/html-text-weaver
- Owner: frameable
- License: mit
- Created: 2019-05-26T16:15:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-06T01:54:13.000Z (about 4 years ago)
- Last Synced: 2023-03-05T11:22:11.977Z (over 3 years ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 4
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# html-text-weaver
Encode html to its component plain-text and meta style parts
```javascript
{ encode, decode } = require('html-text-weaver');
const html = '
Hey, you! Get out of there!
';
encode(html);
// {
// text: 'Hey, you! Get out of there!',
// meta: [ [ 'h1', 0, 27 ], [ 'b', 10, 27 ], [ 'i', 10, 27 ] ] }
// }
decode(encode(html))
// '
Hey, you! Get out of there!
'
```
## Functions
### { text, meta } = encode(html)
Encode html into its component plain-text and meta style parts. Meta is an array of arrays of tag names, start, and end offests.
### html = decode({ text, meta })
Decode text and meta parts back into html.