@jnbelo/react-marked
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

React Marked

tests coverage npm (scoped)

A simple React component that wraps the Marked markdown parsing library.

Installation

npm

npm install @jnbelo/react-marked

yarn

yarn add @jnbelo/react-marked

Usage

import React from 'react';
import MarkedViewer from 'react-marked';
import { MarkedOptions } from 'marked';

const App = () => {
    const content = '# Heading \n Lorem Ipsum [link](https://github.com)';

    const options: MarkedOptions = {
        gfm: true
    };

    const overrides = {
        renderer: {
            link(href: string | null, title: string | null, text: string): string {
                return `<a href=${href} title=${title} target="_blank">${text}</a>`;
            }
        }
    } as MarkedOptions;

    return <MarkedViewer content={content} options={options} overrides={overrides} />;
};

Note: Currently, due to the way the options typings were created, when adding overrides (See Marked's extensibility documentation, we need to use type assertion as opposed to type annotation)

Further Documentation

Check out Marked's documentation pages for further options and extensibility.

License

Copyright (c) 2020 José Belo. (MIT License)

Readme

Keywords

Package Sidebar

Install

npm i @jnbelo/react-marked

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

8.99 kB

Total Files

11

Last publish

Collaborators

  • jnbelo