Skip to content

Commit

Permalink
Fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
edazpotato authored Dec 26, 2021
1 parent 5e0b053 commit 7f119f3
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions packages/marked-renderer-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ markdown to plain text. Can be useful for when you want to show a preview
snippet of an article (or anything written in markdown) without any rich
formatting.

Includes Typescript types.

## Usage

```bash
Expand All @@ -31,30 +33,15 @@ things
*/
```

### Typescript

In my testing this works fine with typescript out of the box - you can import it
like this

```ts
import { renderToText } from "marked-renderer-text";
```

and use it like normal. Because it's a really simple package, Typescript seems
to magically infer all of the types.

If you run into any problems using this with typescript, open an issue and I'll
add proper type definitions.

## Options

You can enable fancy mode by passing `true` to the `renderToText()` function.
You can enable fancy mode by passing `true` as the first argument when initialising the class.

```js
const { marked } = require("marked");
const RenderToText = require("marked-renderer-text");
const testText = `# Title\n**bold text**\n- A\n- List\n- *of*\n- ~~things~~`;
marked.use({ renderer: new RenderToText() });
marked.use({ renderer: new RenderToText(true) });
/*
Title
Expand All @@ -67,3 +54,6 @@ BOLD TEXT
*/
```

You can pass any normal marked renderer options as the second paramater (if you don't want to enable fancy mode, you should pass `false` as the first parameter when doing this).

0 comments on commit 7f119f3

Please sign in to comment.