Skip to content

Commit 61ee415

Browse files
author
vhtmui
committed
feat(docs): 更新PowerShell文档语法高亮配置
修复PowerShell文档中的代码块语法标识,将Plain类型改为txt类型, 并修正powershell拼写错误为powershell。同时更新Svelte页面组件中 的语法高亮插件配置,添加eslint禁用注释,优化语言检测逻辑并 支持fallthrough语法。
1 parent 5629236 commit 61ee415

2 files changed

Lines changed: 29 additions & 24 deletions

File tree

docs/PowerShell.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Import-Module PSFTP
2828

2929
抛出错误默认显示powershell自动构建的位置和信息,如
3030

31-
```Plain
31+
```txt
3232
CheckMaterial:
3333
Line |
3434
3 | CheckMaterial 'hhhh'
@@ -38,13 +38,13 @@ Line |
3838

3939
通过传参可以显示其他消息,但前面的位置信息不会改变,如如下代码:
4040

41-
```Plain
41+
```txt
4242
Write-Error -Message "`n{InvocationPosition}:`n$($_.InvocationInfo.PositionMessage)`n{Message}:`n$($_.Exception.Message)`n{ErrorId}:`n$($_.FullyQualifiedErrorId)" -ErrorAction Stop
4343
```
4444

4545
显示的错误如下:
4646

47-
```Plain
47+
```txt
4848
CheckMaterial:
4949
Line |
5050
3 | CheckMaterial 'hhhh'
@@ -164,7 +164,7 @@ $thread.Start()
164164

165165
1. 创建FTP请求
166166

167-
```powerhsell
167+
```powershell
168168
[System.Net.FtpWebRequest]$Request = [System.Net.WebRequest]::Create($FTP_Uri)
169169
```
170170

src/routes/docs/[...docs]/+page.svelte

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
/* eslint-disable no-fallthrough */
23
import Markdown from 'svelte-exmarkdown';
34
import { gfmPlugin } from 'svelte-exmarkdown/gfm';
45
@@ -16,36 +17,40 @@
1617
const docName = $derived(data.docName);
1718
1819
function getLangs() {
20+
let langs = [];
1921
switch (true) {
2022
case docName.match(/powershell/i) && true:
21-
return [import('shiki/langs/powershell.mjs')];
23+
console.log('powershell');
24+
langs.push(import('shiki/langs/powershell.mjs'));
2225
case docName.match(/rust/i) && true:
23-
return [import('shiki/langs/rust.mjs')];
26+
langs.push(import('shiki/langs/rust.mjs'));
2427
case docName.match(/web/i) && true:
25-
return [
28+
langs.push(
2629
import('shiki/langs/javascript.mjs'),
2730
import('shiki/langs/html.mjs'),
2831
import('shiki/langs/css.mjs')
29-
];
32+
);
3033
default:
31-
return [];
34+
// langs.push('text');
3235
}
36+
return langs;
3337
}
34-
35-
36-
const shikiPluginPromise = $derived(createHighlighterCore({
37-
themes: [import('shiki/themes/slack-dark.mjs'), import('shiki/themes/slack-ochin.mjs')],
38-
langs: [...getLangs()],
39-
engine: createOnigurumaEngine(import('shiki/wasm'))
40-
}).then((highlighter) => {
41-
return {
42-
rehypePlugin: [
43-
rehypeShikiFromHighlighter,
44-
highlighter,
45-
{ themes: { light: 'slack-ochin', dark: 'slack-dark' } }
46-
]
47-
};
48-
}));
38+
39+
const shikiPluginPromise = $derived(
40+
createHighlighterCore({
41+
themes: [import('shiki/themes/slack-dark.mjs'), import('shiki/themes/slack-ochin.mjs')],
42+
langs: [...getLangs()],
43+
engine: createOnigurumaEngine(import('shiki/wasm'))
44+
}).then((highlighter) => {
45+
return {
46+
rehypePlugin: [
47+
rehypeShikiFromHighlighter,
48+
highlighter,
49+
{ themes: { light: 'slack-ochin', dark: 'slack-dark' } }
50+
]
51+
};
52+
})
53+
);
4954
5055
/** @type {import('svelte-exmarkdown').Plugin} */
5156
const csPlugin = {

0 commit comments

Comments
 (0)