fix(code): code highlighting not styled for typeit shortcode (#681)

This commit is contained in:
Cell
2026-01-05 14:58:52 +08:00
committed by GitHub
parent 43ecb1bdd0
commit fb300f2b16
4 changed files with 12 additions and 4 deletions
+9 -1
View File
@@ -150,7 +150,7 @@ function add(a, b) {
## Code block inside other blocks
> [!NOTE]-
> [!NOTE]+
>
> ```js {mode="classic"}
> function add(a, b) {
@@ -158,6 +158,14 @@ function add(a, b) {
> }
> ```
{{< typeit code=java >}}
public class HelloWorld {
public static void main(String []args) {
System.out.println("Hello World");
}
}
{{< /typeit >}}
{{< details "Code Block inside Details" >}}
```js {mode="classic"}
+1 -1
View File
@@ -69,7 +69,7 @@ pre {
@include border-radius($global-border-radius);
// lineNumbersInTable=true
> .chroma {
> div.chroma {
position: relative;
background-color: var(#{$rootPrefix}code-block-background-color);
@include border-radius($global-border-radius);
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v0.4.0" -}}
{{- hugo.Store.Set "version" "v0.4.1-20260105065156-43ecb1bd" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}
+1 -1
View File
@@ -11,7 +11,7 @@
{{- /* highlight code content without line number */ -}}
{{- $content = highlight $content (.Get "code") "lineNos=false, noClasses=false" -}}
{{- /* delete outer label */ -}}
{{- $content = replaceRE `.*<code[^<>]*>(?s)(.*)</code>.*` "$1" $content -}}
{{- $content = replaceRE `.*<code[^<>]*>(?s)(.*)</code>.*` "<span class=\"chroma\">$1</span>" $content -}}
{{- if .Get "code-link" -}}
{{- /* parsing code links */ -}}
{{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=\"$4\">$3</a>$1$5$6" $content -}}