Skip to content

Commit

Permalink
feat: demo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhomie committed Nov 28, 2024
1 parent 3cc4be0 commit 7806bb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .dumi/theme/builtins/SourceCode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -55,8 +60,12 @@ const SourceCode: FC<ISourceCodeProps> = (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<number>();
const [isCopied, setIsCopied] = useState(false);
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ $ npm run dev:doc

```xml
<view>
<!-- #if ALIPAY -->
<!-- #comments if ALIPAY -->
<text a:if="{{a}}">a</text>
<text a:if="{{a && b}}">a & b</text>
<!-- #endif -->
<!-- #comments endif -->
<text a:if="{{a}}">a</text>
<text a:else>!a</text>
<text class="{{a ? '1' : '2'}}"></text>
Expand Down

0 comments on commit 7806bb4

Please sign in to comment.