Skip to content

Commit 78c691b

Browse files
authored
doc(Pre): add ignoreUnescapedHTML config (#4489)
* refactor: 更新加载逻辑 * doc: 增加高亮配置 * test: 更新单元测试
1 parent c45180a commit 78c691b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/BootstrapBlazor.Server/Components/Components/Pre.razor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function highlight(id) {
5555

5656
if (el) {
5757
const invoke = () => {
58-
hljs.highlightElement(el.querySelector('code'))
58+
hljs.highlightElement(el.querySelector('code'));
5959
el.querySelector('.loading').classList.add('d-none')
6060
el.classList.remove('loaded')
6161
}
@@ -64,6 +64,9 @@ export async function highlight(id) {
6464
const handler = setInterval(() => {
6565
const done = window.hljs !== void 0;
6666
if (done) {
67+
hljs.configure({
68+
ignoreUnescapedHTML: true
69+
});
6770
clearInterval(handler)
6871
resolve()
6972
}

src/BootstrapBlazor/Services/Serial/DefaultSerialService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public DefaultSerialService(IJSRuntime jsRuntime)
2727

2828
private async Task<JSModule> LoadModule()
2929
{
30-
var module = await _runtime.LoadModule("./_content/BootstrapBlazor/modules/serial.js")
31-
?? throw new InvalidOperationException("Load serial module failed");
30+
var module = await _runtime.LoadModule("./_content/BootstrapBlazor/modules/serial.js");
3231

3332
IsSupport = await module.InvokeAsync<bool>("init", _serialPortId);
3433
return module;

test/UnitTest/Services/SerialServiceTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class SerialServiceTest : BootstrapBlazorTestBase
99
[Fact]
1010
public async Task GetPort_Ok()
1111
{
12+
// https://itldg.github.io/web-serial-debug/?wt.mc_id=DT-MVP-5004174 网页串口调试工具
1213
Context.JSInterop.Setup<bool>("init", matcher => matcher.Arguments.Count == 1 && (matcher.Arguments[0]?.ToString()?.StartsWith("bb_serial_") ?? false)).SetResult(true);
1314
Context.JSInterop.Setup<bool>("getPort", matcher => matcher.Arguments.Count == 1 && (matcher.Arguments[0]?.ToString()?.StartsWith("bb_serial_") ?? false)).SetResult(true);
1415
Context.JSInterop.Setup<bool>("open", matcher => matcher.Arguments.Count == 4 && (matcher.Arguments[0]?.ToString()?.StartsWith("bb_serial_") ?? false)).SetResult(true);

0 commit comments

Comments
 (0)