1.4.0 • Published 10 months ago
github-style-markdown v1.4.0
github-style-markdown
- An NPM library that handles GitHub markdown-style text.
- Remember that you have to write your own CSS stylesheet to imitate the below screenshot's aesthetics.
- A replacement for react-markdown package.
Installing
- Using NPM:
npm install github-style-markdown
- Using Yarn:
yarn install github-style-markdown
Usage
- In React, you can call it by
import React from 'react';
import parseMarkdown from 'github-style-markdown';
const MyComponent = () => {
const markdownText = `
# Hello, world!
This is **bold** and this is *italic*.
> This is a quote.
`;
const htmlText = parseMarkdown(markdownText);
return (
<div dangerouslySetInnerHTML={{ __html: htmlText }} />
);
};
export default MyComponent;
- In Vanilla JS, call it by
const parseMarkdown = require('github-style-markdown');
const markdownText = `
# Hello, world!
This is **bold** and this is *italic*.
> This is a quote.
`;
const htmlText = parseMarkdown(markdownText);
console.log(htmlText);