Nanoprogrammed Penultimate Musicianship
Wondering what’s next for npm?Check out our public roadmap! »

hive-content-renderer

1.0.3 • Public • Published

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:

$ npm install --save hive-content-renderer

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 **

        <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>

Keywords

none

Install

npm i hive-content-renderer

DownloadsWeekly Downloads

10

Version

1.0.3

License

GPL-3.0

Unpacked Size

360 kB

Total Files

21

Last publish

Collaborators

  • avatar