• Stars
    star
    119
  • Rank 297,013 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Render React components within markdown and markdown as React components!

react-showdown Build status Test coverage Dependency Status

Render React components within markdown and markdown as React components!

Features

  • Render markdown as React components.
  • Render React components within the markdown!
  • Full TypeScript Support.
  • Fully tested.
  • Supports all Showdown extensions, like the Twitter Extension and the Youtube Extension.
  • New in 2.0: Supports Showdown Flavors!
  • New in 2.1:
    • Fixes #54: Missing content after a self-closing component. This was fixed by setting the default value of showdown config recognizeSelfClosing to true. Thanks @n1ru4l
    • New feature: add new optional sanitizeHtml prop for sanitizing html before it was rendered. Thanks @n1ru4l aswell.

Installation

npm install --save react-showdown

or

yarn add react-showdown

Use as React component

Example with ES6/JSX:

import React from 'react';
import MarkdownView from 'react-showdown';

export default function App() {
  const markdown = `
# Welcome to React Showdown :+1:

To get started, edit the markdown in \`example/src/App.tsx\`.

| Column 1 | Column 2 |
|----------|----------|
| A1       | B1       |
| A2       | B2       |
`;

  return (
    <MarkdownView
      markdown={markdown}
      options={{ tables: true, emoji: true }}
    />
  );
};

Use a React component and use it within the markdown with ES6 / TypeScript:

import MarkdownView from 'react-showdown';

function CustomComponent({ name }: { name: string }) {
  return <span>Hello {name}!</span>;
}

const markdown = `
# A custom component:

<CustomComponent name="world" />`;

<MarkdownView markdown={markdown} components={{ CustomComponent }} />

Available props

  • markdown, string, required
  • flavor, Flavor, optional
  • options, ConverterOptions, optional
  • extensions, showdown extensions, optional
  • components, components, optional

Converter options will be pushed forward to the showdown converter, please checkout the valid options section.

Credits

Project is based on the markdown parser Showdown and the html parser htmlparser2.

Alternatives

More Repositories

1

NSHash

NSHash adds hashing methods to NSString and NSData
Objective-C
351
star
2

react-native-layout

Semantic layout components for React Native
JavaScript
57
star
3

EventEmitter

Node.js inspired EventEmitter for Objective C
Objective-C
51
star
4

react-native-showdown

React-native component which renders markdown into a webview!
TypeScript
49
star
5

react-native-sidebar

JavaScript
27
star
6

AFCalendarRequestOperation

AFNetworking extension for downloading and parsing calendars.
Objective-C
24
star
7

react-native-cosmos

DX tool to test react-native components with defined props/state fixtures.
JavaScript
20
star
8

react-native-autopilot

Automatically push and pop navigator routes/scenes/screens if the navigator props was changed.
JavaScript
15
star
9

app_icon_template

Sketch template to create Android and iOS app icons
11
star
10

awesome-links

A collection of awesome-* projects as submodules to grep them...
HTML
10
star
11

pixelfed-app

🌈 Pixelfed app for Android and iOS
TypeScript
10
star
12

react-native-examples

A bunch of small and (hopefully) readable react-native examples
JavaScript
8
star
13

reset_simulators

Reset your Xcode simulators to a opinionated mix of iOS devices and versions
Shell
6
star
14

atom-show-in-system

atom.io extension which show and open files within your system
CoffeeScript
6
star
15

react-native-init-history

react-native init history to compare different version
Java
5
star
16

flutter_alert

A Flutter package to simplify alert messages on Android (Material) and iOS (Cupertino).
Dart
4
star
17

linux

Save some finding and configurations
Shell
3
star
18

react-native-with-eslint

react-native example project with ESLint configuration
Objective-C
2
star
19

usepromises

React and React Native hook to consume a Promise (similar to useEffect) with full TypeScript support
TypeScript
2
star
20

talks

JavaScript
2
star
21

comprise

Add layout and partial support to consolidate.js!
JavaScript
2
star
22

tcpproxy

TCPproxy: Throttle your TCP connections now!
JavaScript
2
star
23

java-hardener

Makes java fault tolerant against NPEs!
Java
1
star
24

bo-swag

A lightweight solution to create swagger documentation with ExpressJS
JavaScript
1
star
25

container

TypeScript
1
star
26

kajitsu

Java 8 middleware web application framework.
Java
1
star
27

octopus

🐙 Octopus app
TypeScript
1
star
28

operators

1
star
29

wait-until

a tiny wait-until tool
Go
1
star
30

react-native-openurl

C#
1
star
31

react-native-tutorial

Objective-C
1
star
32

majorityreports

✨ majority reports 🔮
TypeScript
1
star