• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

readmeio/markdown: ReadMe's flavored Markdown parser and React-based renderi ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

readmeio/markdown

开源软件地址(OpenSource Url):

https://github.com/readmeio/markdown

开源编程语言(OpenSource Language):

JavaScript 83.1%

开源软件介绍(OpenSource 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 is to run the local development server. Clone the repo, cd in to it, npm install, and npm run start!

Credits




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap