优化:调整MD样式,替换高亮插件提高兼容性

This commit is contained in:
Cyan
2024-12-29 22:46:28 +08:00
parent 37cb1d5a55
commit fa8ee159ab
4 changed files with 76 additions and 394 deletions

View File

@@ -1,169 +1,4 @@
.markdown-body {
pre {
margin: 15px 0;
code.hljs {
border-radius: 10px;
font-weight: 400;
}
}
h1,
h2,
h3,
h4,
h5,
h6 {
@apply text-black dark:text-gray transition-colors;
}
h1 {
@apply text-2xl my-6 pb-3 border-b border-[#eee];
// &::before {
// content: "✨️";
// @apply pr-3;
// }
}
h2 {
@apply relative text-lg my-6;
// &::before {
// content: "";
// @apply absolute left-0 top-[50%] -translate-y-1/2 w-2 h-full bg-primary;
// }
}
h3 {
@apply relative text-lg my-5;
// &::before {
// content: "#";
// @apply absolute left-0 top-[50%] -translate-y-1/2 text-primary;
// }
}
h4,
h5,
h6 {
@apply relative text-lg my-3;
}
hr {
@apply my-5 border-[#eee] transition-colors;
}
p code,
ul code {
@apply bg-[rgba(13,110,253,0.1)] dark:bg-[#334052] text-[#0d6efd] rounded-md py-1 px-2 text-sm transition-colors;
}
// 任务列表
li.task-list-item {
@apply my-2.5;
};
li:not(.task-list-item) {
@apply my-2.5;
}
// 无序列表
ul:not(.contains-task-list) {
@apply list-disc ml-6;
}
// 有序列表
ol:not([start]) {
counter-reset: counter;
}
ol > li:not([id^="user-content-"]) {
&::before {
@apply inline-block w-4 h-4 mt-1 mr-1 leading-none rounded-full text-center text-sm border border-[#11181C] dark:border-gray;
counter-increment: counter;
content: counter(counter);
}
& ol > li::before {
@apply inline-block ml-5 border-0 text-base mt-0 leading-normal;
content: counter(counter) ".";
}
}
// 引用
blockquote {
@apply my-5 pl-4 bg-[rgba(246,248,250)] border-l-[4px] border-[#11181C] dark:bg-[rgba(246,248,250,0.1)];
}
// 脚注
.sr-only {
@apply text-[#EAB308] w-full overflow-visible my-10 before:content-[''];
&::before {
@apply block w-full h-[1px] bg-gray mb-2;
}
}
ol > li[id^="user-content-"] {
@apply list-decimal ml-3;
}
// 提示块
.callout-content {
@apply pt-1;
& > p {
@apply mb-0;
}
}
// 数学公式
.katex {
@apply text-base;
}
a {
@apply text-primary
}
p {
@apply leading-9 mb-2;
}
img {
@apply rounded-xl cursor-pointer transition-all mt-2;
}
strong {
@apply text-base;
}
table {
@apply w-full;
th {
@apply bg-[#f1f7fd] dark:bg-[#334052];
}
tr,
th,
td {
@apply border p-[10px_20px];
}
}
input[type="checkbox"] {
width: 16px;
height: 16px;
border-radius: 4px;
position: relative;
cursor: not-allowed;
}
}.markdown-body {
pre {
margin: 15px 0;
@@ -227,7 +62,7 @@
// 任务列表
li.task-list-item {
@apply my-2.5;
};
}
li:not(.task-list-item) {
@apply my-2.5;
@@ -243,7 +78,7 @@
counter-reset: counter;
}
ol > li:not([id^="user-content-"]) {
ol>li:not([id^="user-content-"]) {
&::before {
@apply inline-block w-4 h-4 mt-1 mr-1 leading-none rounded-full text-center text-sm border border-[#11181C] dark:border-gray;
@@ -252,7 +87,7 @@
content: counter(counter);
}
& ol > li::before {
& ol>li::before {
@apply inline-block ml-5 border-0 text-base mt-0 leading-normal;
content: counter(counter) ".";
@@ -273,10 +108,15 @@
}
}
ol > li[id^="user-content-"] {
ol>li[id^="user-content-"] {
@apply list-decimal ml-3;
}
// 高亮标记
mark {
@apply bg-[#dbfdad] dark:bg-[#9db47e];
}
// 提示块
.callout-content {
@apply pt-1;
@@ -289,7 +129,6 @@
// 数学公式
.katex {
@apply text-base;
// font-family: ;
}
a {

View File

@@ -15,11 +15,11 @@ import 'highlight.js/styles/vs2015.css';
import 'katex/dist/katex.css';
import rehypeCallouts from 'rehype-callouts';
import 'rehype-callouts/theme/obsidian';
import remarkFlexibleMarkers from "remark-flexible-markers";
import { remarkMark } from 'remark-mark-highlight';
const markers = (): BytemdPlugin => {
return {
remark: (processor) => processor.use(remarkFlexibleMarkers),
remark: (processor) => processor.use(remarkMark),
actions: [
{
title: '标记',