From 712cf2a8680675c8477e20b100b1237968970ee2 Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Mon, 4 Nov 2024 12:48:59 +0800
Subject: [PATCH] :tada: Feat: add more type marked text support
---
assets/css/_page/_single.scss | 14 ++++++++++++++
layouts/partials/function/content.html | 2 +-
layouts/partials/function/marked-text.html | 10 ++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 layouts/partials/function/marked-text.html
diff --git a/assets/css/_page/_single.scss b/assets/css/_page/_single.scss
index c9c02e29..05f59d44 100644
--- a/assets/css/_page/_single.scss
+++ b/assets/css/_page/_single.scss
@@ -289,6 +289,20 @@
}
}
+ mark {
+ padding: 0.14em 0.28em;
+ background-color: var(--#{$prefix}mark-background-color, mark);
+ color: var(--#{$prefix}mark-color, marktext);
+ @include border-radius($global-border-radius);
+
+ @each $color, $value in $theme-colors {
+ &.mark-#{$color} {
+ --#{$prefix}mark-color: #fff;
+ --#{$prefix}mark-background-color: var(--#{$prefix}#{$color});
+ }
+ }
+ }
+
.table-wrapper {
overflow-x: auto;
--#{$prefix}scrollbar-thumb-color: #{$table-background-color};
diff --git a/layouts/partials/function/content.html b/layouts/partials/function/content.html
index 426b653c..5a5362ce 100644
--- a/layouts/partials/function/content.html
+++ b/layouts/partials/function/content.html
@@ -15,7 +15,7 @@
{{- end -}}
{{- $content = partial "function/task-lists.html" $content -}}
-
+ {{- $content = partial "function/marked-text.html" $content -}}
{{- $content = partial "function/escape.html" $content -}}
{{- end -}}
diff --git a/layouts/partials/function/marked-text.html b/layouts/partials/function/marked-text.html
new file mode 100644
index 00000000..f7de73d4
--- /dev/null
+++ b/layouts/partials/function/marked-text.html
@@ -0,0 +1,10 @@
+{{- /*
+ Marked texts rendering
+ This is an experimental syntax highlighting for the marked texts.
+ Embed types: default, primary, secondary, success, warning, danger
+*/ -}}
+
+{{- $content := replaceRE `(.+?)\[(.+?)\]` `$1` . -}}
+{{- $content = replaceRE `(.+?)` `$1` $content -}}
+
+{{- return $content -}}