From fa4ff40773487badd3bed5486a609346ef96cee0 Mon Sep 17 00:00:00 2001 From: Rakan Nimer Date: Thu, 9 Aug 2018 23:43:55 +0300 Subject: [PATCH] fix(rehype-docz): allow ticks and backticks inside playground (#203) * fix: allow code inside playground to contain ticks and backticks * chore: remove empty line --- package.json | 2 +- packages/rehype-docz/src/index.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index efe7923d3..1bed111d1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/rehype-docz/src/index.ts b/packages/rehype-docz/src/index.ts index e0ea72153..e22b5929d 100644 --- a/packages/rehype-docz/src/index.ts +++ b/packages/rehype-docz/src/index.ts @@ -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,