From fb300f2b161e9fcc54b51f7231241476ad98a9fc Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Mon, 5 Jan 2026 14:58:52 +0800 Subject: [PATCH] fix(code): code highlighting not styled for typeit shortcode (#681) --- apps/test/content/posts/codeblock-test.md | 10 +++++++++- assets/css/_partials/_single/_code.scss | 2 +- layouts/_partials/init/index.html | 2 +- layouts/_shortcodes/typeit.html | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/test/content/posts/codeblock-test.md b/apps/test/content/posts/codeblock-test.md index ce0367ec..ba4a9a94 100644 --- a/apps/test/content/posts/codeblock-test.md +++ b/apps/test/content/posts/codeblock-test.md @@ -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"} diff --git a/assets/css/_partials/_single/_code.scss b/assets/css/_partials/_single/_code.scss index 79524f12..325093a9 100644 --- a/assets/css/_partials/_single/_code.scss +++ b/assets/css/_partials/_single/_code.scss @@ -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); diff --git a/layouts/_partials/init/index.html b/layouts/_partials/init/index.html index f0162e68..3f93b75c 100644 --- a/layouts/_partials/init/index.html +++ b/layouts/_partials/init/index.html @@ -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" . -}} diff --git a/layouts/_shortcodes/typeit.html b/layouts/_shortcodes/typeit.html index c15f09cd..e5e1e0de 100644 --- a/layouts/_shortcodes/typeit.html +++ b/layouts/_shortcodes/typeit.html @@ -11,7 +11,7 @@ {{- /* highlight code content without line number */ -}} {{- $content = highlight $content (.Get "code") "lineNos=false, noClasses=false" -}} {{- /* delete outer label */ -}} - {{- $content = replaceRE `.*]*>(?s)(.*).*` "$1" $content -}} + {{- $content = replaceRE `.*]*>(?s)(.*).*` "$1" $content -}} {{- if .Get "code-link" -}} {{- /* parsing code links */ -}} {{- $content = replaceRE `(]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)()` "$1$2$6$3$1$5$6" $content -}}