# hive-content-renderer

> Hive content renderer

Latest version **1.0.3** (published 2020-07-10) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install hive-content-renderer
pnpm add hive-content-renderer
yarn add hive-content-renderer
bun add hive-content-renderer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-07-10 |
| First published | 2020-05-04 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 352 KB |
| Known vulnerabilities | 0 (+17 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Mahdi Yari |
| Maintainers | mahdiyari |

## Links

- npm: https://www.npmjs.com/package/hive-content-renderer
- Repository: https://github.com/mahdiyari/hive-content-renderer
- Homepage: https://github.com/mahdiyari/hive-content-renderer#readme
- Issues: https://github.com/mahdiyari/hive-content-renderer/issues
- npm.io page: https://npm.io/package/hive-content-renderer

## Dependencies (4)

- [xmldom](https://npm.io/package/xmldom.md) ^0.3.0
- [url-parse](https://npm.io/package/url-parse.md) ^1.4.7
- [remarkable](https://npm.io/package/remarkable.md) ^2.0.0
- [sanitize-html-2](https://npm.io/package/sanitize-html-2.md) ^2.0.0

## Recent versions

- 1.0.3 (latest) — 2020-07-10
- 1.0.2 — 2020-05-21
- 1.0.1 — 2020-05-21
- 1.0.0 — 2020-05-21
- 0.0.4 — 2020-05-05
- 0.0.3 — 2020-05-05
- 0.0.2 — 2020-05-05
- 0.0.1 — 2020-05-05
- 0.0.0-development — 2020-05-04

## README

# hive-content-renderer

**CAUTION:** We don't suggest using this library in production without complete review of codes. You may compromise your website.

## Server side usage

Installation:

```bash
$ npm install --save hive-content-renderer
```

**Typescript:**

```typescript
import DefaultRenderer from 'hive-content-renderer'

const renderer = new DefaultRenderer({
  baseUrl: 'https://hive.blog/',
  breaks: true,
  skipSanitization: false,
  allowInsecureScriptTags: false,
  addNofollowToLinks: true,
  doNotShowImages: false,
  ipfsPrefix: '',
  assetsWidth: 640,
  assetsHeight: 480,
  imageProxyFn: (url: string) => url,
  usertagUrlFn: (account: string) => '/@' + account,
  hashtagUrlFn: (hashtag: string) => '/trending/' + hashtag,
  isLinkSafeFn: (url: string) => true
})

const safeHtmlStr = renderer.render(postContent)
```

## Browser usage:

** NOT WORKING RIGHT NOW **

```html
        <script src="https://unpkg.com/hive-content-renderer"></script>
        <script>
            const renderer = new HiveContentRenderer({
                baseUrl: "https://hive.blog/",
                breaks: true,
                skipSanitization: false,
                allowInsecureScriptTags: false,
                addNofollowToLinks: true,
                doNotShowImages: false,
                ipfsPrefix: "",
                assetsWidth: 640,
                assetsHeight: 480,
                imageProxyFn: (url) => url,
                usertagUrlFn: (account) => "/@" + account,
                hashtagUrlFn: (hashtag) => "/trending/" + hashtag,
                isLinkSafeFn: (url) => true,
            });

            $(document).ready(() => {
                const renderMarkdownBtnElem = $("#render-button");
                const inputElem = $("#input");
                const outputElem = $("#output");
                const outputMarkupElem = $("#output-markup");

                renderMarkdownBtnElem.on("click", () => {
                    const input = inputElem.val();
                    const output = renderer.render(input);

                    console.log("Rendered", output);
                    outputElem.html(output);
                    outputMarkupElem.text(output);
                });
            });
        </script>
    </body>
</html>
```

---
_Source: https://npm.io/package/hive-content-renderer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
