File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,23 @@ import select from 'unist-util-select'
44import findBefore from 'unist-util-find-before'
55import htmlToReact from 'html-to-react'
66import parsePairs from 'parse-pairs'
7+ import React from 'react'
8+ import ReactDOMServer from 'react-dom/server'
9+ import { Octicon } from '../Octicon'
710
811const htmlParser = new htmlToReact . Parser ( )
912
13+ const railsOcticonToReact = ( html ) => {
14+ // <%= octicon "tools" %> to <Octicon name="tools" />
15+ const octre = / < % = o c t i c o n [ " ' ] ( [ a - z \- ] + ) [ " ' ] % > / gi
16+ html = html . replace ( octre , ( match , name ) => {
17+ return ReactDOMServer . renderToStaticMarkup ( < Octicon name = { name } /> )
18+ } )
19+ return html
20+ }
21+
1022const nodeToStory = ( node , file ) => {
11- const html = node . value
23+ let html = railsOcticonToReact ( node . value )
1224 const element = htmlParser . parse ( html )
1325 const pairs = node . lang . replace ( / ^ h t m l \s * / , '' )
1426 const attrs = pairs . length ? parsePairs ( pairs ) : { }
You can’t perform that action at this time.
0 commit comments