1.0.2 • Published 4 years ago

@jnbelo/react-marked v1.0.2

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

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)

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-rc.2

4 years ago

1.0.0-rc.1

4 years ago

1.0.0-rc.0

4 years ago