@jet-w/astro-blog 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/chunk-FXPGR372.js +0 -0
  2. package/dist/chunk-GYLSY3OJ.js +173 -0
  3. package/dist/config/index.d.ts +166 -0
  4. package/dist/config/index.js +38 -0
  5. package/dist/index.d.ts +34 -0
  6. package/dist/index.js +59 -0
  7. package/dist/types/index.d.ts +75 -0
  8. package/dist/types/index.js +1 -0
  9. package/package.json +84 -0
  10. package/src/components/EChartsCard.vue +118 -0
  11. package/src/components/Mermaid.vue +73 -0
  12. package/src/components/about/ContentCard.astro +27 -0
  13. package/src/components/about/IconCard.astro +77 -0
  14. package/src/components/about/SocialLinks.astro +54 -0
  15. package/src/components/about/TagCard.astro +65 -0
  16. package/src/components/about/TagGroup.astro +33 -0
  17. package/src/components/about/TimelineCard.astro +52 -0
  18. package/src/components/blog/FloatingToc.vue +198 -0
  19. package/src/components/blog/Hero.astro +147 -0
  20. package/src/components/blog/NavigationTabs.vue +245 -0
  21. package/src/components/blog/PostCard.astro +161 -0
  22. package/src/components/blog/PostNavigation.astro +106 -0
  23. package/src/components/blog/RelatedPosts.astro +175 -0
  24. package/src/components/blog/TableOfContents.astro +153 -0
  25. package/src/components/blog/TagCloud.astro +91 -0
  26. package/src/components/home/FeaturedPostsSection.astro +54 -0
  27. package/src/components/home/QuickNavSection.astro +81 -0
  28. package/src/components/home/RecentPostsSection.astro +52 -0
  29. package/src/components/home/StatsSection.astro +44 -0
  30. package/src/components/layout/Footer.astro +103 -0
  31. package/src/components/layout/Header.astro +68 -0
  32. package/src/components/layout/Sidebar.astro +594 -0
  33. package/src/components/media/Bilibili.astro +114 -0
  34. package/src/components/media/Slides.astro +313 -0
  35. package/src/components/media/Video.astro +111 -0
  36. package/src/components/media/VideoPlayer.astro +89 -0
  37. package/src/components/media/YouTube.astro +92 -0
  38. package/src/components/pte/StudyCalendar.vue +1348 -0
  39. package/src/components/ui/Icon.astro +187 -0
  40. package/src/components/ui/MobileMenu.vue +201 -0
  41. package/src/components/ui/Pagination.astro +143 -0
  42. package/src/components/ui/SearchBox.vue +179 -0
  43. package/src/components/ui/SearchInterface.vue +409 -0
  44. package/src/components/ui/SidebarToggle.vue +57 -0
  45. package/src/components/ui/ThemeToggle.vue +90 -0
  46. package/src/layouts/AboutLayout.astro +18 -0
  47. package/src/layouts/BaseLayout.astro +362 -0
  48. package/src/layouts/PageLayout.astro +217 -0
  49. package/src/layouts/SlidesLayout.astro +320 -0
  50. package/src/plugins/rehype-clean-containers.mjs +24 -0
  51. package/src/plugins/rehype-relative-links.mjs +43 -0
  52. package/src/plugins/rehype-tabs.mjs +116 -0
  53. package/src/plugins/remark-containers.mjs +407 -0
  54. package/src/plugins/remark-mermaid.mjs +46 -0
  55. package/src/styles/global.css +870 -0
  56. package/src/styles/slides.css +220 -0
  57. package/src/utils/sidebar.ts +492 -0
  58. package/templates/default/astro.config.mjs +51 -0
  59. package/templates/default/content/pages/about.mdx +93 -0
  60. package/templates/default/content/pages/index.mdx +20 -0
  61. package/templates/default/content/posts/blog_docs/01-quick-start.md +162 -0
  62. package/templates/default/content/posts/blog_docs/02-frontmatter.md +277 -0
  63. package/templates/default/content/posts/blog_docs/03-markdown-basic.md +350 -0
  64. package/templates/default/content/posts/blog_docs/04-containers.md +331 -0
  65. package/templates/default/content/posts/blog_docs/05-code-blocks.md +388 -0
  66. package/templates/default/content/posts/blog_docs/06-mermaid.md +431 -0
  67. package/templates/default/content/posts/blog_docs/07-video.md +243 -0
  68. package/templates/default/content/posts/blog_docs/08-latex.md +382 -0
  69. package/templates/default/content/posts/blog_docs/09-icons.md +326 -0
  70. package/templates/default/content/posts/blog_docs/10-sidebar.md +445 -0
  71. package/templates/default/content/posts/blog_docs/11-config.md +334 -0
  72. package/templates/default/content/posts/blog_docs/12-slides.mdx +552 -0
  73. package/templates/default/content/posts/blog_docs/README.md +151 -0
  74. package/templates/default/content/slides/demo.md +146 -0
  75. package/templates/default/content/slides/docs/basic-demo.md +35 -0
  76. package/templates/default/content/slides/docs/code-demo.md +62 -0
  77. package/templates/default/content/slides/docs/echarts-demo.md +139 -0
  78. package/templates/default/content/slides/docs/fragment-demo.md +35 -0
  79. package/templates/default/content/slides/docs/math-demo.md +48 -0
  80. package/templates/default/content/slides/docs/mermaid-demo.md +105 -0
  81. package/templates/default/content/slides/docs/theme-demo.md +38 -0
  82. package/templates/default/content/slides/docs/vertical-demo.md +50 -0
  83. package/templates/default/package.json +31 -0
  84. package/templates/default/public/favicon-bak.svg +4 -0
  85. package/templates/default/public/images/avatar.jpg +0 -0
  86. package/templates/default/public/images/avatar.svg +142 -0
  87. package/templates/default/public/js/mermaid-container.js +402 -0
  88. package/templates/default/public/js/mermaid-init.js +131 -0
  89. package/templates/default/public/js/mermaid-render.js +98 -0
  90. package/templates/default/public/js/mermaid-simple.js +95 -0
  91. package/templates/default/public/js/tabs-init.js +86 -0
  92. package/templates/default/public/media/individual_portfolio/INDIVIDUAL PORTFOLIO.png +0 -0
  93. package/templates/default/public/slides/plugin/highlight/highlight.js +5 -0
  94. package/templates/default/public/slides/plugin/highlight/monokai.css +71 -0
  95. package/templates/default/public/slides/plugin/markdown/markdown.js +7 -0
  96. package/templates/default/public/slides/plugin/math/math.js +1 -0
  97. package/templates/default/public/slides/plugin/notes/notes.js +1 -0
  98. package/templates/default/public/slides/reveal.css +9 -0
  99. package/templates/default/public/slides/reveal.js +9 -0
  100. package/templates/default/public/slides/theme/beige.css +366 -0
  101. package/templates/default/public/slides/theme/black-contrast.css +362 -0
  102. package/templates/default/public/slides/theme/black.css +359 -0
  103. package/templates/default/public/slides/theme/blood.css +392 -0
  104. package/templates/default/public/slides/theme/dracula.css +385 -0
  105. package/templates/default/public/slides/theme/league.css +368 -0
  106. package/templates/default/public/slides/theme/moon.css +362 -0
  107. package/templates/default/public/slides/theme/night.css +360 -0
  108. package/templates/default/public/slides/theme/serif.css +363 -0
  109. package/templates/default/public/slides/theme/simple.css +362 -0
  110. package/templates/default/public/slides/theme/sky.css +370 -0
  111. package/templates/default/public/slides/theme/solarized.css +363 -0
  112. package/templates/default/public/slides/theme/white-contrast.css +362 -0
  113. package/templates/default/public/slides/theme/white.css +359 -0
  114. package/templates/default/public/slides/theme/white_contrast_compact_verbatim_headers.css +360 -0
  115. package/templates/default/public/test-complete.html +43 -0
  116. package/templates/default/public/test-mermaid.html +124 -0
  117. package/templates/default/src/config/index.ts +114 -0
  118. package/templates/default/src/content.config.ts +96 -0
  119. package/templates/default/src/pages/[...slug].astro +27 -0
  120. package/templates/default/src/pages/archives/[year]/[month]/page/[page].astro +176 -0
  121. package/templates/default/src/pages/archives/[year]/[month].astro +158 -0
  122. package/templates/default/src/pages/archives/index.astro +210 -0
  123. package/templates/default/src/pages/categories/[category]/page/[page].astro +218 -0
  124. package/templates/default/src/pages/categories/[category].astro +198 -0
  125. package/templates/default/src/pages/categories/index.astro +190 -0
  126. package/templates/default/src/pages/container-test.astro +79 -0
  127. package/templates/default/src/pages/mermaid-direct.html +78 -0
  128. package/templates/default/src/pages/posts/[...slug].astro +335 -0
  129. package/templates/default/src/pages/posts/index.astro +541 -0
  130. package/templates/default/src/pages/posts/page/[page].astro +146 -0
  131. package/templates/default/src/pages/rss.xml.ts +28 -0
  132. package/templates/default/src/pages/search-index.json.ts +21 -0
  133. package/templates/default/src/pages/search.astro +50 -0
  134. package/templates/default/src/pages/slides/[...slug].astro +54 -0
  135. package/templates/default/src/pages/slides/index.astro +135 -0
  136. package/templates/default/src/pages/tags/[tag]/page/[page].astro +211 -0
  137. package/templates/default/src/pages/tags/[tag].astro +191 -0
  138. package/templates/default/src/pages/tags/index.astro +167 -0
  139. package/templates/default/tailwind.config.mjs +78 -0
  140. package/templates/default/tsconfig.json +9 -0
@@ -0,0 +1,142 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
3
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
5
+ width="200.000000pt" height="200.000000pt" viewBox="0 0 200.000000 200.000000"
6
+ preserveAspectRatio="xMidYMid meet">
7
+ <metadata>
8
+ Created by potrace 1.10, written by Peter Selinger 2001-2011
9
+ </metadata>
10
+ <g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)"
11
+ fill="#d08a03" stroke="none">
12
+ <path d="M905 1780 c-87 -22 -160 -75 -187 -137 -17 -39 -19 -57 -13 -121 8
13
+ -89 19 -121 45 -139 11 -8 20 -24 20 -36 -1 -22 -1 -22 -15 -3 -15 19 -15 19
14
+ -15 -1 0 -12 8 -24 19 -28 13 -4 17 -12 14 -25 -3 -11 0 -20 6 -20 6 0 11 -13
15
+ 11 -30 0 -23 -4 -30 -20 -30 -14 0 -29 20 -56 76 -31 66 -35 79 -25 101 13 29
16
+ 9 40 -7 20 -14 -17 -26 -101 -13 -93 5 3 12 -1 15 -10 9 -23 8 -26 -6 -18 -7
17
+ 4 -2 -7 11 -24 12 -18 27 -32 33 -32 5 0 8 -7 4 -15 -3 -8 -2 -14 2 -14 18 4
18
+ 71 -14 75 -25 2 -6 2 1 0 17 -5 30 20 39 31 11 4 -9 9 -14 13 -11 3 4 -9 36
19
+ -27 73 -28 57 -32 73 -27 118 3 28 9 61 12 74 6 17 4 22 -6 20 -9 -2 -13 4
20
+ -11 19 2 12 -2 24 -8 28 -6 4 -10 -8 -10 -32 0 -38 -14 -72 -25 -62 -3 4 -10
21
+ 42 -15 85 -8 71 -6 83 13 122 32 65 152 132 237 132 37 0 172 -59 185 -81 6
22
+ -9 3 -10 -10 -6 -9 4 -24 2 -31 -4 -9 -7 -14 -7 -14 -1 0 16 -34 20 -48 6 -7
23
+ -7 -12 -17 -12 -23 0 -5 -7 -12 -16 -15 -11 -4 -18 1 -21 14 -4 13 -9 17 -17
24
+ 12 -6 -5 -26 -10 -44 -10 -17 0 -39 -8 -47 -16 -9 -8 -22 -13 -29 -10 -8 3
25
+ -31 -4 -52 -15 -21 -12 -35 -21 -31 -21 5 0 1 -7 -7 -16 -9 -8 -16 -21 -16
26
+ -28 0 -20 29 -15 36 6 7 23 29 35 84 43 25 4 57 14 73 23 24 15 29 15 37 2 13
27
+ -22 64 -1 68 28 4 28 15 28 27 0 6 -12 24 -26 40 -30 17 -4 43 -18 59 -31 24
28
+ -20 30 -33 34 -80 7 -82 26 -86 20 -5 -5 80 -52 184 -101 220 -60 46 -166 67
29
+ -242 48z"/>
30
+ <path d="M1145 1464 c-48 -23 -67 -46 -57 -72 3 -8 12 -5 30 13 24 25 41 31
31
+ 90 37 24 3 24 3 5 25 l-19 21 -49 -24z"/>
32
+ <path d="M881 1435 c-30 -29 -24 -39 13 -25 42 16 114 13 118 -5 2 -9 8 -11
33
+ 16 -6 15 9 7 37 -14 45 -7 3 -35 8 -61 11 -42 4 -51 2 -72 -20z"/>
34
+ <path d="M1170 1402 c-55 -5 -60 -21 -6 -20 25 0 49 4 51 9 8 11 -6 15 -45 11z"/>
35
+ <path d="M1249 1405 c-1 -6 -1 -33 0 -60 2 -54 -22 -174 -37 -184 -4 -3 -14
36
+ -22 -22 -41 -8 -19 -18 -39 -22 -45 -5 -5 -15 -19 -22 -29 -10 -15 -27 -20
37
+ -79 -22 -58 -2 -68 0 -88 22 -12 13 -31 24 -42 24 -10 0 -28 11 -38 25 -11 13
38
+ -26 22 -33 19 -9 -3 -13 1 -13 12 1 9 -4 19 -11 21 -7 3 -12 -1 -11 -8 2 -8
39
+ -7 -32 -18 -55 -17 -32 -33 -45 -71 -61 -27 -11 -108 -49 -179 -84 -144 -70
40
+ -140 -67 -178 -192 -19 -61 -18 -104 5 -332 11 -111 44 -263 80 -365 22 -65
41
+ 25 -48 5 30 -46 180 -64 264 -70 324 -3 38 -7 71 -9 75 -2 3 -5 58 -7 121 -3
42
+ 115 10 192 37 215 6 6 14 22 18 38 6 24 10 26 34 21 21 -4 24 -3 12 5 -13 10
43
+ -13 11 0 11 8 0 66 25 128 55 133 65 160 73 174 54 6 -10 7 -7 3 11 -6 23 -5
44
+ 24 7 5 14 -23 19 -85 6 -85 -4 0 -8 -4 -8 -10 0 -17 30 1 30 19 1 11 5 8 15
45
+ -9 19 -33 18 -38 -2 -43 -11 -3 -7 -5 10 -6 18 -1 27 -6 27 -18 0 -10 7 -27
46
+ 15 -37 8 -11 15 -27 15 -35 0 -14 -2 -14 -11 -1 -7 11 -8 6 -3 -20 8 -44 13
47
+ -52 26 -44 8 5 9 -8 6 -41 -3 -27 -2 -42 2 -34 6 9 16 -3 34 -42 l26 -54 -6
48
+ 40 c-10 68 -74 266 -110 344 -32 67 -55 161 -41 161 4 0 20 -13 37 -30 50 -49
49
+ 147 -110 175 -110 37 0 68 -18 61 -36 -3 -9 -1 -12 4 -9 6 3 10 1 10 -5 0 -14
50
+ -82 -3 -91 12 -11 17 -39 -34 -39 -70 0 -18 7 -44 16 -57 14 -21 14 -37 6
51
+ -107 -11 -101 -9 -192 5 -210 6 -7 13 -24 16 -38 3 -14 3 -7 1 15 -9 71 -8
52
+ 105 5 118 10 9 11 9 6 -4 -5 -13 2 -18 30 -23 19 -4 40 -4 45 -1 6 3 10 0 10
53
+ -7 0 -10 3 -9 11 2 8 11 9 5 5 -25 -3 -25 -2 -35 3 -26 7 10 11 0 16 -35 17
54
+ -125 24 -137 19 -34 -6 114 -27 258 -48 330 -13 45 -6 100 16 127 12 15 -13
55
+ 60 -38 70 -11 4 -8 13 15 42 15 20 35 49 43 65 l16 30 5 -30 c14 -67 6 -138
56
+ -19 -176 -26 -41 -33 -66 -8 -30 18 26 34 29 32 5 -3 -42 2 -416 6 -412 3 3 8
57
+ 29 11 59 4 30 11 57 16 58 13 5 11 46 -3 61 -8 8 -9 15 -3 17 6 2 10 46 10
58
+ 102 0 78 -4 104 -19 126 -17 28 -17 28 3 21 19 -6 20 -4 12 17 -10 28 -3 78
59
+ 11 78 6 0 8 7 4 15 -3 9 0 15 10 15 8 0 13 -4 10 -9 -3 -5 1 -14 9 -21 13 -11
60
+ 14 -10 8 5 -5 15 -3 17 13 11 10 -5 37 -12 59 -17 63 -13 106 -27 121 -40 8
61
+ -6 14 -8 14 -5 0 18 37 -17 55 -51 10 -21 28 -51 38 -66 18 -26 18 -29 3 -52
62
+ -19 -28 -15 -32 8 -10 13 14 17 10 30 -36 9 -28 13 -55 10 -60 -2 -4 0 -16 5
63
+ -26 12 -24 37 -107 33 -112 -2 -2 2 -7 8 -11 9 -6 8 -14 -3 -36 -14 -26 -15
64
+ -27 -21 -7 -5 15 -18 23 -49 27 -74 11 -90 9 -109 -16 -14 -18 -18 -20 -18 -6
65
+ 0 9 5 29 11 45 6 15 12 58 14 94 2 62 1 65 -15 50 -12 -11 -14 -21 -8 -33 15
66
+ -30 -2 -120 -32 -174 -16 -29 -26 -55 -22 -59 4 -3 -1 -3 -10 0 -12 5 -15 2
67
+ -12 -12 3 -10 -3 -27 -14 -38 -10 -11 -16 -27 -14 -34 3 -8 0 -11 -6 -7 -5 3
68
+ -13 -1 -16 -10 -4 -10 -2 -13 7 -9 6 4 1 -3 -13 -14 -14 -11 -29 -21 -35 -21
69
+ -25 -1 -36 -17 -26 -41 l10 -24 0 28 c1 24 5 27 34 27 35 0 55 24 94 110 22
70
+ 48 97 130 120 130 23 0 14 -24 -18 -53 -18 -15 -29 -30 -26 -33 5 -5 28 11 61
71
+ 42 24 23 63 44 69 37 14 -14 6 -42 -13 -48 -32 -10 -130 -109 -130 -131 0 -15
72
+ 5 -12 20 12 21 33 131 124 149 124 27 0 8 -41 -31 -69 -47 -32 -107 -91 -93
73
+ -91 5 0 30 18 56 40 26 22 52 40 58 40 19 0 11 -24 -17 -56 -23 -28 -37 -34
74
+ -102 -43 -41 -7 -97 -15 -125 -20 l-50 -8 55 -7 c70 -9 241 21 247 44 4 13 3
75
+ 13 -6 0 -9 -13 -11 -13 -11 1 0 9 7 22 15 29 8 7 15 23 15 35 0 13 8 42 19 65
76
+ l19 42 13 -51 c7 -28 16 -51 20 -51 5 0 7 -16 5 -36 -2 -25 3 -39 14 -47 17
77
+ -10 16 -47 0 -47 -5 0 -8 -20 -8 -45 0 -25 -5 -51 -10 -58 -5 -7 -12 -23 -14
78
+ -37 -3 -14 -9 -33 -13 -43 -4 -9 -3 -17 3 -17 14 0 42 79 49 139 3 28 9 51 13
79
+ 51 16 0 18 29 3 56 -8 16 -17 40 -19 54 -7 36 -45 162 -55 182 -5 10 -9 29 -9
80
+ 43 0 13 -8 39 -18 57 -10 18 -19 40 -19 48 -1 37 -57 208 -73 220 -4 3 -10 12
81
+ -14 20 -14 30 -32 57 -46 71 -15 14 -155 59 -184 59 -27 0 -143 58 -149 74 -4
82
+ 10 5 32 22 57 48 65 74 240 41 273 -6 6 -10 6 -11 1z m-260 -386 c26 -16 42
83
+ -19 75 -13 37 6 39 5 27 -10 -7 -9 -23 -16 -35 -16 -20 0 -131 60 -111 60 6 0
84
+ 25 -9 44 -21z m131 -138 c11 -1 11 -4 2 -13 -7 -7 -12 -20 -12 -30 0 -9 -8
85
+ -22 -17 -27 -10 -6 -13 -11 -6 -11 6 0 11 -13 11 -28 -1 -15 4 -43 10 -62 6
86
+ -19 10 -60 10 -91 0 -55 -1 -56 -30 -57 -20 0 -28 3 -25 12 3 7 -4 18 -14 25
87
+ -11 6 -17 17 -13 22 8 13 16 78 17 132 1 20 6 37 12 38 5 0 0 4 -12 9 -14 6
88
+ -23 18 -23 30 0 12 -4 18 -10 15 -5 -3 -10 -1 -10 4 0 6 8 11 18 12 10 0 12 3
89
+ 4 6 -6 2 -10 8 -8 11 4 6 20 7 96 3z"/>
90
+ <path d="M890 1370 c-22 -6 -23 -8 -7 -15 10 -4 35 -3 54 3 19 6 41 8 49 5 8
91
+ -3 14 0 14 6 0 12 -71 13 -110 1z"/>
92
+ <path d="M1010 1259 c0 -32 19 -44 65 -43 52 2 76 17 58 35 -7 7 -17 8 -25 3
93
+ -24 -15 -78 -14 -78 2 0 8 -4 14 -10 14 -5 0 -10 -5 -10 -11z"/>
94
+ <path d="M1105 1175 c-5 -1 -36 -10 -67 -20 -32 -9 -58 -21 -58 -25 0 -5 30 0
95
+ 66 10 37 11 71 17 75 14 4 -2 20 -2 34 2 20 5 23 9 13 15 -13 9 -43 10 -63 4z"/>
96
+ <path d="M1095 1123 c-11 -3 -29 -12 -40 -19 -19 -13 -19 -14 6 -14 28 0 79
97
+ 21 79 33 0 8 -13 8 -45 0z"/>
98
+ <path d="M1351 903 c8 -10 18 -21 22 -24 4 -3 21 -32 38 -65 19 -40 29 -52 29
99
+ -36 0 12 -4 22 -10 22 -5 0 -10 7 -10 15 0 18 -60 105 -73 105 -5 0 -3 -8 4
100
+ -17z"/>
101
+ <path d="M710 900 c0 -9 15 -21 33 -28 40 -14 47 -15 47 -3 0 5 -15 13 -32 16
102
+ -18 4 -36 13 -40 19 -5 7 -8 6 -8 -4z"/>
103
+ <path d="M920 884 c0 -4 11 -17 25 -30 15 -14 25 -18 25 -10 0 7 -8 20 -18 29
104
+ -19 18 -32 22 -32 11z"/>
105
+ <path d="M1462 810 c0 -56 14 -155 18 -120 3 27 2 39 -10 115 l-8 50 0 -45z"/>
106
+ <path d="M697 817 c4 -7 11 -16 16 -22 4 -5 16 -26 26 -44 30 -58 44 -47 15
107
+ 12 -15 31 -36 58 -46 60 -12 3 -16 1 -11 -6z"/>
108
+ <path d="M465 720 c6 -10 78 -50 90 -50 16 0 -11 22 -48 40 -47 23 -51 24 -42
109
+ 10z"/>
110
+ <path d="M1568 710 c-20 -11 -40 -24 -43 -30 -10 -16 1 -12 42 16 60 40 60 45
111
+ 1 14z"/>
112
+ <path d="M726 683 c-2 -10 -8 -29 -12 -43 -6 -22 -5 -23 10 -8 9 10 13 24 9
113
+ 34 -4 12 -3 15 5 10 7 -4 12 -1 12 8 0 22 -17 20 -24 -1z"/>
114
+ <path d="M652 630 c-1 -33 2 -60 7 -60 4 0 9 27 10 60 1 33 -2 60 -7 60 -5 0
115
+ -9 -27 -10 -60z"/>
116
+ <path d="M780 684 c0 -12 31 -95 60 -159 12 -27 26 -61 30 -75 5 -16 9 -19 9
117
+ -8 1 9 -20 68 -45 130 -46 113 -54 129 -54 112z"/>
118
+ <path d="M470 666 c97 -38 121 -50 116 -62 -3 -8 0 -11 10 -7 7 3 14 8 14 12
119
+ 0 13 -125 71 -151 71 -21 -1 -19 -3 11 -14z"/>
120
+ <path d="M1341 586 c-1 -28 -1 -28 47 -21 53 8 91 24 57 24 -11 0 -37 -3 -57
121
+ -8 -33 -8 -37 -6 -41 13 -3 16 -5 14 -6 -8z"/>
122
+ <path d="M600 580 c0 -5 6 -13 14 -17 17 -10 47 -69 39 -77 -4 -3 -2 -6 4 -6
123
+ 14 0 63 -111 63 -143 0 -14 4 -28 9 -32 5 -3 7 -18 4 -33 -7 -34 -7 -38 2 -88
124
+ 7 -39 6 -41 -21 -47 -33 -7 -99 -45 -91 -53 2 -3 20 4 38 15 19 12 51 21 72
125
+ 21 36 0 50 -13 25 -23 -9 -4 -8 -6 2 -6 9 -1 22 -7 28 -13 7 -7 20 -13 30 -13
126
+ 11 0 16 -7 14 -18 -3 -18 -2 -18 24 0 27 18 28 18 22 -5 -4 -15 -2 -22 5 -19
127
+ 7 3 11 10 9 16 -1 6 7 11 18 11 11 0 20 -7 20 -15 0 -12 4 -13 19 -5 28 14 31
128
+ 13 31 -12 0 -17 3 -19 12 -10 14 14 58 16 58 4 0 -12 32 -11 48 1 6 5 12 18
129
+ 12 29 0 10 4 16 10 13 5 -3 10 4 10 17 -1 13 -1 56 0 96 0 41 -3 78 -6 84 -10
130
+ 15 18 28 45 21 20 -5 23 -3 18 11 -4 10 -7 19 -7 21 0 2 -16 -3 -35 -11 -30
131
+ -12 -34 -12 -29 1 5 11 2 13 -12 8 -13 -5 -15 -3 -9 7 6 10 4 12 -7 7 -9 -3
132
+ -20 -1 -26 5 -9 9 -47 -5 -62 -23 -11 -13 -60 -19 -60 -8 0 8 -4 8 -12 2 -21
133
+ -16 -61 -24 -49 -10 7 9 -5 13 -46 15 -86 5 -103 15 -103 60 0 22 -11 59 -24
134
+ 85 -14 25 -28 62 -32 82 -5 29 -9 33 -20 24 -11 -9 -14 -9 -14 0 0 13 -24 41
135
+ -34 41 -3 0 -6 -4 -6 -10z m500 -427 c0 -137 0 -136 -66 -108 -40 17 -189 46
136
+ -218 42 -14 -2 -21 9 -32 53 -8 30 -21 68 -29 84 -8 16 -13 31 -11 33 2 3 63
137
+ 1 136 -3 l132 -7 -6 -41 c-4 -23 -11 -42 -15 -44 -5 -2 -6 -13 -3 -25 4 -17 8
138
+ -12 19 28 7 28 13 68 13 91 l0 41 40 -10 40 -11 0 -123z"/>
139
+ <path d="M525 461 l-40 -7 34 -5 c19 -3 52 0 75 7 l41 13 -35 -1 c-19 -1 -53
140
+ -4 -75 -7z"/>
141
+ </g>
142
+ </svg>
@@ -0,0 +1,402 @@
1
+ // 简化的 Mermaid 容器渲染脚本
2
+ console.log('🎯 Mermaid Container Script loaded');
3
+
4
+ // UTF-8 安全的 base64 解码函数
5
+ function base64ToUtf8(base64) {
6
+ try {
7
+ // 使用 TextDecoder 处理 UTF-8 字符
8
+ const binaryString = atob(base64);
9
+ const bytes = new Uint8Array(binaryString.length);
10
+ for (let i = 0; i < binaryString.length; i++) {
11
+ bytes[i] = binaryString.charCodeAt(i);
12
+ }
13
+ const decoder = new TextDecoder('utf-8');
14
+ return decoder.decode(bytes);
15
+ } catch (error) {
16
+ console.error('Base64 解码失败:', error);
17
+ // 回退到原始方法
18
+ return atob(base64);
19
+ }
20
+ }
21
+
22
+ // 创建全屏预览模态框
23
+ function createFullscreenModal() {
24
+ // 如果已存在则返回
25
+ if (document.getElementById('mermaid-fullscreen-modal')) {
26
+ return document.getElementById('mermaid-fullscreen-modal');
27
+ }
28
+
29
+ const modal = document.createElement('div');
30
+ modal.id = 'mermaid-fullscreen-modal';
31
+ modal.className = 'mermaid-fullscreen-modal';
32
+ modal.innerHTML = `
33
+ <div class="mermaid-fullscreen-backdrop"></div>
34
+ <div class="mermaid-fullscreen-container">
35
+ <div class="mermaid-fullscreen-header">
36
+ <span class="mermaid-fullscreen-title">Mermaid 图表预览</span>
37
+ <div class="mermaid-fullscreen-controls">
38
+ <button class="mermaid-zoom-btn" data-action="zoom-out" title="缩小">
39
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
40
+ <circle cx="11" cy="11" r="8"/>
41
+ <line x1="21" y1="21" x2="16.65" y2="16.65"/>
42
+ <line x1="8" y1="11" x2="14" y2="11"/>
43
+ </svg>
44
+ </button>
45
+ <span class="mermaid-zoom-level">100%</span>
46
+ <button class="mermaid-zoom-btn" data-action="zoom-in" title="放大">
47
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
48
+ <circle cx="11" cy="11" r="8"/>
49
+ <line x1="21" y1="21" x2="16.65" y2="16.65"/>
50
+ <line x1="11" y1="8" x2="11" y2="14"/>
51
+ <line x1="8" y1="11" x2="14" y2="11"/>
52
+ </svg>
53
+ </button>
54
+ <button class="mermaid-zoom-btn" data-action="zoom-fit" title="适配屏幕">
55
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
56
+ <rect x="3" y="3" width="18" height="18" rx="2"/>
57
+ <path d="M9 3v18M15 3v18M3 9h18M3 15h18"/>
58
+ </svg>
59
+ </button>
60
+ <button class="mermaid-zoom-btn" data-action="zoom-reset" title="重置为100%">
61
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
62
+ <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/>
63
+ <path d="M3 3v5h5"/>
64
+ </svg>
65
+ </button>
66
+ <button class="mermaid-close-btn" title="关闭 (Esc)">
67
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
68
+ <line x1="18" y1="6" x2="6" y2="18"/>
69
+ <line x1="6" y1="6" x2="18" y2="18"/>
70
+ </svg>
71
+ </button>
72
+ </div>
73
+ </div>
74
+ <div class="mermaid-fullscreen-content">
75
+ <div class="mermaid-fullscreen-svg-wrapper"></div>
76
+ </div>
77
+ </div>
78
+ `;
79
+
80
+ document.body.appendChild(modal);
81
+
82
+ // 绑定事件
83
+ let currentZoom = 1;
84
+ const zoomStep = 0.25;
85
+ const minZoom = 0.25;
86
+ const maxZoom = 4;
87
+
88
+ // 拖动相关状态
89
+ let isDragging = false;
90
+ let startX = 0;
91
+ let startY = 0;
92
+ let translateX = 0;
93
+ let translateY = 0;
94
+
95
+ const backdrop = modal.querySelector('.mermaid-fullscreen-backdrop');
96
+ const closeBtn = modal.querySelector('.mermaid-close-btn');
97
+ const zoomLevelSpan = modal.querySelector('.mermaid-zoom-level');
98
+ const svgWrapper = modal.querySelector('.mermaid-fullscreen-svg-wrapper');
99
+ const contentArea = modal.querySelector('.mermaid-fullscreen-content');
100
+
101
+ function updateTransform() {
102
+ zoomLevelSpan.textContent = Math.round(currentZoom * 100) + '%';
103
+ svgWrapper.style.transform = `translate(${translateX}px, ${translateY}px) scale(${currentZoom})`;
104
+ }
105
+
106
+ function resetPosition() {
107
+ translateX = 0;
108
+ translateY = 0;
109
+ }
110
+
111
+ function closeModal() {
112
+ modal.classList.remove('active');
113
+ document.body.style.overflow = '';
114
+ currentZoom = 1;
115
+ resetPosition();
116
+ updateTransform();
117
+ isDragging = false;
118
+ }
119
+
120
+ backdrop.addEventListener('click', closeModal);
121
+ closeBtn.addEventListener('click', closeModal);
122
+
123
+ // 鼠标拖动事件
124
+ svgWrapper.addEventListener('mousedown', (e) => {
125
+ if (e.button !== 0) return; // 只响应左键
126
+ isDragging = true;
127
+ startX = e.clientX - translateX;
128
+ startY = e.clientY - translateY;
129
+ svgWrapper.style.cursor = 'grabbing';
130
+ e.preventDefault();
131
+ });
132
+
133
+ document.addEventListener('mousemove', (e) => {
134
+ if (!isDragging || !modal.classList.contains('active')) return;
135
+ translateX = e.clientX - startX;
136
+ translateY = e.clientY - startY;
137
+ updateTransform();
138
+ });
139
+
140
+ document.addEventListener('mouseup', () => {
141
+ if (isDragging) {
142
+ isDragging = false;
143
+ svgWrapper.style.cursor = 'grab';
144
+ }
145
+ });
146
+
147
+ // 触摸拖动支持(移动设备)
148
+ let touchStartX = 0;
149
+ let touchStartY = 0;
150
+
151
+ svgWrapper.addEventListener('touchstart', (e) => {
152
+ if (e.touches.length === 1) {
153
+ isDragging = true;
154
+ touchStartX = e.touches[0].clientX - translateX;
155
+ touchStartY = e.touches[0].clientY - translateY;
156
+ }
157
+ }, { passive: true });
158
+
159
+ svgWrapper.addEventListener('touchmove', (e) => {
160
+ if (!isDragging || e.touches.length !== 1) return;
161
+ translateX = e.touches[0].clientX - touchStartX;
162
+ translateY = e.touches[0].clientY - touchStartY;
163
+ updateTransform();
164
+ }, { passive: true });
165
+
166
+ svgWrapper.addEventListener('touchend', () => {
167
+ isDragging = false;
168
+ });
169
+
170
+ // 计算适配屏幕的缩放比例
171
+ function calculateFitScale() {
172
+ const svg = svgWrapper.querySelector('svg');
173
+ if (!svg) return 1;
174
+
175
+ // 先重置变换以获取原始尺寸
176
+ const originalTransform = svgWrapper.style.transform;
177
+ svgWrapper.style.transform = 'translate(0px, 0px) scale(1)';
178
+
179
+ const svgRect = svg.getBoundingClientRect();
180
+ const contentRect = contentArea.getBoundingClientRect();
181
+
182
+ // 恢复变换
183
+ svgWrapper.style.transform = originalTransform;
184
+
185
+ const availableWidth = contentRect.width - 80;
186
+ const availableHeight = contentRect.height - 80;
187
+
188
+ const scaleX = availableWidth / svgRect.width;
189
+ const scaleY = availableHeight / svgRect.height;
190
+ return Math.min(scaleX, scaleY, 3); // 最大不超过 300%
191
+ }
192
+
193
+ modal.querySelectorAll('.mermaid-zoom-btn').forEach(btn => {
194
+ btn.addEventListener('click', (e) => {
195
+ const action = btn.dataset.action;
196
+ if (action === 'zoom-in' && currentZoom < maxZoom) {
197
+ currentZoom = Math.min(currentZoom + zoomStep, maxZoom);
198
+ } else if (action === 'zoom-out' && currentZoom > minZoom) {
199
+ currentZoom = Math.max(currentZoom - zoomStep, minZoom);
200
+ } else if (action === 'zoom-reset') {
201
+ currentZoom = 1;
202
+ resetPosition();
203
+ } else if (action === 'zoom-fit') {
204
+ currentZoom = calculateFitScale();
205
+ resetPosition();
206
+ }
207
+ updateTransform();
208
+ });
209
+ });
210
+
211
+ // 键盘事件
212
+ document.addEventListener('keydown', (e) => {
213
+ if (!modal.classList.contains('active')) return;
214
+
215
+ if (e.key === 'Escape') {
216
+ closeModal();
217
+ } else if (e.key === '+' || e.key === '=') {
218
+ if (currentZoom < maxZoom) {
219
+ currentZoom = Math.min(currentZoom + zoomStep, maxZoom);
220
+ updateTransform();
221
+ }
222
+ } else if (e.key === '-') {
223
+ if (currentZoom > minZoom) {
224
+ currentZoom = Math.max(currentZoom - zoomStep, minZoom);
225
+ updateTransform();
226
+ }
227
+ } else if (e.key === '0') {
228
+ currentZoom = 1;
229
+ resetPosition();
230
+ updateTransform();
231
+ }
232
+ });
233
+
234
+ // 鼠标滚轮缩放
235
+ modal.querySelector('.mermaid-fullscreen-content').addEventListener('wheel', (e) => {
236
+ if (!modal.classList.contains('active')) return;
237
+ e.preventDefault();
238
+
239
+ if (e.deltaY < 0 && currentZoom < maxZoom) {
240
+ currentZoom = Math.min(currentZoom + zoomStep * 0.5, maxZoom);
241
+ } else if (e.deltaY > 0 && currentZoom > minZoom) {
242
+ currentZoom = Math.max(currentZoom - zoomStep * 0.5, minZoom);
243
+ }
244
+ updateTransform();
245
+ }, { passive: false });
246
+
247
+ // 暴露适配屏幕的方法供外部调用
248
+ modal._fitToScreen = function() {
249
+ currentZoom = calculateFitScale();
250
+ resetPosition();
251
+ updateTransform();
252
+ };
253
+
254
+ return modal;
255
+ }
256
+
257
+ // 打开全屏预览
258
+ function openFullscreen(svgContent) {
259
+ const modal = createFullscreenModal();
260
+ const svgWrapper = modal.querySelector('.mermaid-fullscreen-svg-wrapper');
261
+
262
+ svgWrapper.innerHTML = svgContent;
263
+ svgWrapper.style.transform = 'translate(0px, 0px) scale(1)';
264
+ svgWrapper.style.cursor = 'grab';
265
+
266
+ modal.classList.add('active');
267
+ document.body.style.overflow = 'hidden';
268
+
269
+ // 等待 DOM 渲染完成后自动适配屏幕
270
+ requestAnimationFrame(() => {
271
+ if (modal._fitToScreen) {
272
+ modal._fitToScreen();
273
+ }
274
+ });
275
+ }
276
+
277
+ // 创建全屏按钮
278
+ function createFullscreenButton() {
279
+ const btn = document.createElement('button');
280
+ btn.className = 'mermaid-fullscreen-btn';
281
+ btn.title = '全屏预览';
282
+ btn.innerHTML = `
283
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
284
+ <path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/>
285
+ </svg>
286
+ `;
287
+ return btn;
288
+ }
289
+
290
+ function renderMermaidContainers() {
291
+ console.log('🚀 开始检查 mermaid 容器');
292
+
293
+ // 查找所有新格式的mermaid容器
294
+ const mermaidContainers = document.querySelectorAll('.mermaid-container[data-mermaid-source]');
295
+ console.log('🔍 找到 ' + mermaidContainers.length + ' 个mermaid容器');
296
+
297
+ if (mermaidContainers.length === 0) {
298
+ console.log('❌ 没有找到mermaid容器');
299
+ return;
300
+ }
301
+
302
+ // 动态加载mermaid库
303
+ const script = document.createElement('script');
304
+ script.src = 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js';
305
+ script.onload = function() {
306
+ console.log('✅ Mermaid库加载完成');
307
+
308
+ // 初始化mermaid,支持中文字符
309
+ window.mermaid.initialize({
310
+ startOnLoad: false,
311
+ theme: 'default',
312
+ securityLevel: 'loose',
313
+ fontFamily: '"Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif',
314
+ flowchart: {
315
+ useMaxWidth: true,
316
+ htmlLabels: true,
317
+ curve: 'basis'
318
+ }
319
+ });
320
+
321
+ // 处理每个容器
322
+ mermaidContainers.forEach(async function(container, index) {
323
+ try {
324
+ const base64Code = container.getAttribute('data-mermaid-source');
325
+ const id = container.getAttribute('data-id') || ('mermaid-' + index);
326
+
327
+ console.log('🎨 处理第' + (index+1) + '个容器, ID: ' + id);
328
+
329
+ // UTF-8 安全的 base64 解码
330
+ const mermaidCode = base64ToUtf8(base64Code);
331
+ console.log('📝 Mermaid代码: ' + mermaidCode.slice(0, 50) + '...');
332
+
333
+ // 渲染mermaid图表
334
+ const result = await window.mermaid.render(id, mermaidCode);
335
+
336
+ // 创建渲染后的容器
337
+ const renderedDiv = document.createElement('div');
338
+ renderedDiv.className = 'mermaid-rendered';
339
+ renderedDiv.style.cssText = [
340
+ 'margin: 1.5rem 0',
341
+ 'padding: 1rem',
342
+ 'border: 1px solid #e2e8f0',
343
+ 'border-radius: 0.5rem',
344
+ 'background: white',
345
+ 'overflow-x: auto',
346
+ 'text-align: center',
347
+ 'position: relative'
348
+ ].join('; ');
349
+ renderedDiv.innerHTML = result.svg;
350
+
351
+ // 添加全屏按钮
352
+ const fullscreenBtn = createFullscreenButton();
353
+ fullscreenBtn.addEventListener('click', () => {
354
+ openFullscreen(result.svg);
355
+ });
356
+ renderedDiv.appendChild(fullscreenBtn);
357
+
358
+ // 替换加载提示
359
+ const loadingDiv = container.querySelector('.mermaid-loading');
360
+ if (loadingDiv) {
361
+ container.replaceChild(renderedDiv, loadingDiv);
362
+ } else {
363
+ container.appendChild(renderedDiv);
364
+ }
365
+
366
+ console.log('✨ 第' + (index+1) + '个图表渲染成功');
367
+
368
+ } catch (error) {
369
+ console.error('❌ 渲染第' + (index+1) + '个图表失败:', error);
370
+
371
+ // 显示错误信息
372
+ const errorDiv = document.createElement('div');
373
+ errorDiv.style.cssText = 'color: red; padding: 1rem; border: 1px solid red; margin: 1rem 0; background: #fee;';
374
+ errorDiv.innerHTML = '<strong>Mermaid渲染错误:</strong> ' + error.message;
375
+
376
+ const loadingDiv = container.querySelector('.mermaid-loading');
377
+ if (loadingDiv) {
378
+ container.replaceChild(errorDiv, loadingDiv);
379
+ }
380
+
381
+ // 显示fallback代码块
382
+ const fallback = container.querySelector('.mermaid-fallback');
383
+ if (fallback) {
384
+ fallback.style.display = 'block';
385
+ }
386
+ }
387
+ });
388
+ };
389
+
390
+ script.onerror = function() {
391
+ console.error('❌ Mermaid库加载失败');
392
+ };
393
+
394
+ document.head.appendChild(script);
395
+ }
396
+
397
+ // 启动渲染
398
+ if (document.readyState === 'loading') {
399
+ document.addEventListener('DOMContentLoaded', renderMermaidContainers);
400
+ } else {
401
+ renderMermaidContainers();
402
+ }
@@ -0,0 +1,131 @@
1
+ import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
2
+
3
+ mermaid.initialize({
4
+ startOnLoad: false,
5
+ theme: 'default',
6
+ securityLevel: 'loose',
7
+ fontFamily: 'ui-sans-serif, system-ui, sans-serif'
8
+ });
9
+
10
+ async function initMermaid() {
11
+ console.log('🎯 Mermaid init: 开始查找mermaid代码块');
12
+
13
+ // Handle plugin-generated mermaid-wrapper elements (base64 encoded)
14
+ const wrappers = document.querySelectorAll('.mermaid-wrapper');
15
+ console.log(`🎯 找到 ${wrappers.length} 个 mermaid-wrapper`);
16
+
17
+ for (const wrapper of wrappers) {
18
+ try {
19
+ const base64Data = wrapper.getAttribute('data-mermaid');
20
+ const mermaidCode = atob(base64Data);
21
+ const id = `mermaid-${Math.random().toString(36).substr(2, 9)}`;
22
+ const { svg } = await mermaid.render(id, mermaidCode);
23
+ wrapper.innerHTML = `<div class="mermaid-container">${svg}</div>`;
24
+ console.log('✅ 成功渲染mermaid-wrapper图表');
25
+ } catch (error) {
26
+ console.error('❌ Mermaid渲染错误:', error);
27
+ }
28
+ }
29
+
30
+ // Handle div.mermaid-code elements (plain text content)
31
+ const mermaidDivs = document.querySelectorAll('div.mermaid-code');
32
+ console.log(`🎯 找到 ${mermaidDivs.length} 个 mermaid-code divs`);
33
+
34
+ for (let i = 0; i < mermaidDivs.length; i++) {
35
+ const mermaidDiv = mermaidDivs[i];
36
+ try {
37
+ const mermaidCode = mermaidDiv.textContent.trim();
38
+ console.log(`🎯 处理第${i+1}个mermaid-code div:`, mermaidCode.substring(0, 50));
39
+
40
+ const id = `mermaid-div-${i}`;
41
+ const { svg } = await mermaid.render(id, mermaidCode);
42
+
43
+ // Create new container with proper styling
44
+ const container = document.createElement('div');
45
+ container.className = 'mermaid-container my-6 p-4 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700';
46
+ container.innerHTML = svg;
47
+
48
+ // Replace the mermaid-code div
49
+ mermaidDiv.parentNode.replaceChild(container, mermaidDiv);
50
+ console.log('✅ 成功替换并渲染mermaid div图表');
51
+ } catch (error) {
52
+ console.error('❌ Mermaid div渲染错误:', error);
53
+ }
54
+ }
55
+
56
+ // Handle text and plain code blocks that contain mermaid content (marked with %%mermaid)
57
+ const textBlocks = document.querySelectorAll('pre code[data-language="text"], pre code.language-text, pre code:not([data-language]):not([class*="language-"])');
58
+ console.log(`🎯 找到 ${textBlocks.length} 个 text/plain代码块`);
59
+
60
+ for (let i = 0; i < textBlocks.length; i++) {
61
+ const codeBlock = textBlocks[i];
62
+ const content = codeBlock.textContent.trim();
63
+
64
+ if (content.startsWith('%%mermaid')) {
65
+ try {
66
+ // Remove the %%mermaid marker and get the actual mermaid code
67
+ const mermaidCode = content.substring('%%mermaid'.length).trim();
68
+ console.log(`🎯 处理第${i+1}个mermaid文本块:`, mermaidCode.substring(0, 50));
69
+
70
+ const id = `mermaid-text-${i}`;
71
+ const { svg } = await mermaid.render(id, mermaidCode);
72
+
73
+ const container = document.createElement('div');
74
+ container.className = 'mermaid-container my-6 p-4 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700';
75
+ container.innerHTML = svg;
76
+
77
+ const preElement = codeBlock.closest('pre');
78
+ if (preElement) {
79
+ preElement.parentNode.replaceChild(container, preElement);
80
+ console.log('✅ 成功替换并渲染mermaid文本图表');
81
+ }
82
+ } catch (error) {
83
+ console.error('❌ Mermaid文本渲染错误:', error);
84
+ }
85
+ }
86
+ }
87
+
88
+ // Handle regular mermaid code blocks directly (including auto-detected ones)
89
+ const codeBlocks = document.querySelectorAll('pre code[data-language="mermaid"], pre code.language-mermaid, code[class*="language-mermaid"]');
90
+ console.log(`🎯 找到 ${codeBlocks.length} 个 mermaid代码块`);
91
+
92
+ for (let i = 0; i < codeBlocks.length; i++) {
93
+ const codeBlock = codeBlocks[i];
94
+ try {
95
+ let mermaidCode = codeBlock.textContent.trim();
96
+ console.log(`🎯 处理第${i+1}个代码块:`, mermaidCode.substring(0, 50));
97
+
98
+ // Check if this was originally a %%mermaid block and remove the marker
99
+ if (mermaidCode.startsWith('%%mermaid')) {
100
+ mermaidCode = mermaidCode.substring('%%mermaid'.length).trim();
101
+ console.log('🎯 检测到%%mermaid标记,移除后的代码:', mermaidCode.substring(0, 50));
102
+ }
103
+
104
+ const id = `mermaid-direct-${i}`;
105
+ const { svg } = await mermaid.render(id, mermaidCode);
106
+
107
+ const container = document.createElement('div');
108
+ container.className = 'mermaid-container my-6 p-4 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700';
109
+ container.innerHTML = svg;
110
+
111
+ const preElement = codeBlock.closest('pre');
112
+ if (preElement) {
113
+ preElement.parentNode.replaceChild(container, preElement);
114
+ console.log('✅ 成功替换并渲染mermaid图表');
115
+ }
116
+ } catch (error) {
117
+ console.error('❌ Mermaid直接渲染错误:', error);
118
+ }
119
+ }
120
+
121
+ console.log('🎯 Mermaid初始化完成');
122
+ }
123
+
124
+ // 确保在页面加载后执行
125
+ if (document.readyState === 'loading') {
126
+ document.addEventListener('DOMContentLoaded', () => {
127
+ setTimeout(initMermaid, 100);
128
+ });
129
+ } else {
130
+ setTimeout(initMermaid, 100);
131
+ }