Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dbushell committed Oct 7, 2024
1 parent d76e91f commit 8e2507a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,44 @@

[![JSR](https://jsr.io/badges/@dbushell/hyperless?labelColor=98e6c8&color=333)](https://jsr.io/@dbushell/hyperless) [![NPM](https://img.shields.io/npm/v/@dbushell/hyperless?labelColor=98e6c8&color=333)](https://www.npmjs.com/package/@dbushell/hyperless)

Remove the “H” from HTML. Hyperless is a lightweight library for converting HTML to plain text quickly. It removes the “ML” too I guess... HTML to text and other useful stuff. That’s the idea.
HTML parser and various utilities.

## Functions
## `parseHTML`

### `stripTags`

Remove HTML and return text content with a few niceties.
Parse an HTML document or fragment into a traversable node tree.

```javascript
import {stripTags} from '@dbushell/hyperless';
// Pass a chunk of HTML
const text = stripTags('<p>Ceci n’est pas une paragraphe.</p>');
import {parseHTML} from '@dbushell/hyperless';
const root = parseHTML('<h1>Hello, World!</h1>');
```

Text in `<blockquote>` and `<q>` are wrapped in quotation marks.
Node API subject to change.

### `parseAttributes`
## `parseAttributes`

Parse an HTML attribute string into a case-insensitive deduplicated key/value map.

```javascript
import {parseAttributes} from '@dbushell/hyperless';
const map = parseAttributes('a="1" b="2" c d="d" D="d"');
const map = parseAttributes('a="1" b="2" c d="d" D="d" e=e');
```

HTML entity encoding is handled automatically by default.

## Utilities

### `stripTags`

Remove HTML and return text content with a few niceties.

```javascript
import {stripTags} from '@dbushell/hyperless';
// Pass a chunk of HTML
const text = stripTags('<p>Ceci n’est pas une paragraphe.</p>');
```

Text in `<blockquote>` and `<q>` are wrapped in quotation marks.

### `excerpt`

Generate a text excerpt from HTML content.
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dbushell/hyperless",
"version": "0.18.0",
"version": "0.19.0",
"exports": {
".": "./mod.ts"
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@dbushell/hyperless",
"version": "0.18.0",
"version": "0.19.0",
"repository": {
"type": "git",
"url": "git+https://github.com/dbushell/hyperless.git"
},
"description": "HTML to text and other useful stuff.",
"description": "HTML parser and various utilities.",
"keywords": [
"html",
"typescript"
Expand Down

0 comments on commit 8e2507a

Please sign in to comment.