From 7806bb426ccd3697efe2a9d11c58e5434fc03204 Mon Sep 17 00:00:00 2001 From: rayhomie <1572801584@qq.com> Date: Thu, 28 Nov 2024 13:02:16 +0800 Subject: [PATCH] feat: demo fix --- .dumi/theme/builtins/SourceCode/index.tsx | 11 ++++++++++- docs/guide/contribute.md | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.dumi/theme/builtins/SourceCode/index.tsx b/.dumi/theme/builtins/SourceCode/index.tsx index ada6966da..54918b2e5 100644 --- a/.dumi/theme/builtins/SourceCode/index.tsx +++ b/.dumi/theme/builtins/SourceCode/index.tsx @@ -25,6 +25,11 @@ const MARKUP_REGEX = { wechat: /[\n]*?#if ALIPAY[\s\S]*?#endif[\n]*?/g, // 微信平台时,需要去掉支付宝标记的内容 }; +const COMMENTS_MARKUP_REGEX = { + if: /#comments\s+if/g, + endif: /#comments\s+endif/g, +}; + /** * define DSL which can be highlighted as similar language */ @@ -55,8 +60,12 @@ const SourceCode: FC = (props) => { // 去掉所有的 #if ALIPAY, #endif 等标记 result = result.replace(MARKUP_REGEX.all, ''); + + // 如果comments if 或 comments endif 需要处理一下 + result = result.replace(COMMENTS_MARKUP_REGEX.if, '#if'); + result = result.replace(COMMENTS_MARKUP_REGEX.endif, '#endif'); return result; - }, [pChildren, platform, MARKUP_REGEX]); + }, [pChildren, platform, MARKUP_REGEX, COMMENTS_MARKUP_REGEX]); const timer = useRef(); const [isCopied, setIsCopied] = useState(false); diff --git a/docs/guide/contribute.md b/docs/guide/contribute.md index 0d09b8a2b..535ee74b0 100644 --- a/docs/guide/contribute.md +++ b/docs/guide/contribute.md @@ -77,10 +77,10 @@ $ npm run dev:doc ```xml - + a a & b - + a !a