Skip to content

Commit

Permalink
fix(rehype-docz): allow ticks and backticks inside playground (#203)
Browse files Browse the repository at this point in the history
* fix: allow code inside playground to contain ticks and backticks
* chore: remove empty line
  • Loading branch information
rakannimer authored and pedronauck committed Aug 9, 2018
1 parent 781c2bf commit fa4ff40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"clean": "lerna clean",
"bs": "lerna bootstrap",
"packages": "run-s packages:*",
"packages:fix": "lerna run fix",
"packages:fix": "lerna run fix && echo",
"packages:lint": "lerna run tslint",
"packages:build": "lerna run build --ignore docz-example-*",
"prerelease": "yarn run packages",
Expand Down
8 changes: 6 additions & 2 deletions packages/rehype-docz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ const removePlayground = (code: string) => {
const addCodeProp = async (node: any, idx: number) => {
const name = componentName(node.value)
const tagOpen = new RegExp(`^\\<${name}`)

if (isPlayground(name)) {
const formatted = await format(nodeToString(node))
const code = formatted.slice(1, Infinity)
const child = strip(removePlayground(code)).trim()
const child = strip(removePlayground(code))
.trim()
.split(`'`)
.join(`\\'`)
.split('`')
.join('\\`')

node.value = node.value.replace(
tagOpen,
Expand Down

0 comments on commit fa4ff40

Please sign in to comment.