markdown-in-js

inline markdown for react/jsx

  • 所有者: threepointone/markdown-in-js
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

markdown-in-js

zero-overhead markdown in your react components

usage

add 'markdown-in-js/babel' to the plugins field of your babel config

import markdown from 'markdown-in-js'

const App = () => markdown`
## This is some content.
You can write _markdown_ as you'd like.

${ <span> interpolate more <Content/> </span> }

you can <i>inline *html*</i> or even <OtherComponents/>, wow

<div style=${{ fontWeight: 'bold' }}
    className=${'some more styles'}
    onClick=${handler}>
  interpolate attributes as expected
</div>
`
  • gets compiled to react elements via a babel plugin
  • preserves interpolations
  • built with commonmark
  • optionally add prismjs for syntax highlighting of code blocks

custom components

You can use custom components for markdown primitives like so -

import md from 'markdown-in-js'
import { MyHeading, MyLink } from './path/to/components'

const App = () => md({ h1: MyHeading, a: MyLink })`
# this will be a custom header
[custom link component](/url/to/link)
`

todo

  • optionally no-wrap paragraphs
  • optionally return array of elements
  • instructions for in-editor syntax highlighting
  • add gotchas to docs
  • precompile code blocks
  • commonmark options
  • tests!

主要指標

概覽
名稱與所有者threepointone/markdown-in-js
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證
所有者活动
創建於2016-11-19 14:33:23
推送於2022-12-06 21:00:48
最后一次提交2018-12-15 08:04:09
發布數10
最新版本名稱v1.1.4 (發布於 2018-04-02 20:44:06)
第一版名稱v1.0.1 (發布於 2016-11-19 20:11:03)
用户参与
星數786
關注者數11
派生數20
提交數37
已啟用問題?
問題數13
打開的問題數7
拉請求數4
打開的拉請求數12
關閉的拉請求數6
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?