Giter Club home page Giter Club logo

markdown's Introduction

@readme/markdown

ReadMe's flavored Markdown parser and MDX rendering engine. RDMD CI Status

npm install --save @readme/markdown

Usage

By default, the updated markdown package exports a function which takes a string of ReadMe-flavored markdown and returns a tree of React components:

import React from 'react';
import rdmd from '@readme/markdown';

export default ({ body }) => <div className="markdown-body">{rdmd(body)}</div>;

Export Methods

In addition to the default React processor, the package exports some other methods for transforming ReadMe-flavored markdown:

Export Description Arguments
react (default) returns a VDOM tree object text, options
md transform mdast in to ReadMe-flavored markdown tree, options
html transform markdown in to HTML text, options
mdast transform markdown to an mdast object text, options
hast transform markdown to HAST object text, options
plain transform markdown to plain text text, options
utils contexts, defaults, helpers, etc. N/A

Settings & Options

Each processor method takes an options object which you can use to adjust the output HTML or React tree. These options include:

  • compatibilityMode — Enable compatibility features from our old markdown engine.
  • copyButtons — Automatically insert a button to copy a block of text to the clipboard. Currently used on <code> elements.
  • correctnewlines — Render new line delimeters as <br> tags.
  • markdownOptions — Remark parser options.
  • safeMode — Render html blocks as <pre> elements. We normally allow all manner of html attributes that could potentially execute JavaScript.

Flavored Syntax

Our old editor rendered "Magic Block" components from a custom, JSON-based syntax. To provide seamless backwards-compatibility, our new processor ships with built in support for parsing this old format, and transpiles it straight in to our new, flavored Markdown.

We've also sprinkled a bit of our own syntactic sugar on top to let you supercharge your docs. Learn more about ReadMe's flavored syntax!

Local Development

To make changes to the RDMD engine locally, run the local development server. Clone the repo, cd in to it, npm install, and npm run start!

Environment setup

Running the browser tests requires docker. Follow the docker install instructions for mac. You may want to increase the memory usage. If you have not already, you'll need to create an account for docker hub and sign-in locally.

Running visual regression tests

If you make changes to the docs or how the markdown is rendered, you may need to update the visual regression snapshots. You can run the visual regression tests in a docker container with:

make updateSnapshot

Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.