@bytechain.cn/colamd 1.5.0 → 1.5.1

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 (196) hide show
  1. package/.trae/specs/optimize-theme-loading/checklist.md +20 -0
  2. package/.trae/specs/optimize-theme-loading/spec.md +103 -0
  3. package/.trae/specs/optimize-theme-loading/tasks.md +40 -0
  4. package/CHANGELOG.md +320 -0
  5. package/CLAUDE.md +56 -0
  6. package/README.md +498 -26
  7. package/README_CN.md +554 -27
  8. package/android/app/build/.npmkeep +0 -0
  9. package/android/app/build.gradle +76 -0
  10. package/android/app/capacitor.build.gradle +24 -0
  11. package/android/app/proguard-rules.pro +21 -0
  12. package/android/app/release.keystore +0 -0
  13. package/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +26 -0
  14. package/android/app/src/main/AndroidManifest.xml +64 -0
  15. package/android/app/src/main/java/cn/bytechain/colamd/MainActivity.java +180 -0
  16. package/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  17. package/android/app/src/main/res/drawable/splash.png +0 -0
  18. package/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
  19. package/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
  20. package/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
  21. package/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
  22. package/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
  23. package/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
  24. package/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
  25. package/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
  26. package/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
  27. package/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
  28. package/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  29. package/android/app/src/main/res/layout/activity_main.xml +12 -0
  30. package/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  31. package/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  32. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  33. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
  34. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  35. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  36. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
  37. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  38. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  39. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
  40. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  41. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  42. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
  43. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  44. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  45. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
  46. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  47. package/android/app/src/main/res/values/ic_launcher_background.xml +4 -0
  48. package/android/app/src/main/res/values/strings.xml +7 -0
  49. package/android/app/src/main/res/values/styles.xml +22 -0
  50. package/android/app/src/main/res/xml/file_paths.xml +5 -0
  51. package/android/app/src/main/res/xml/network_security_config.xml +8 -0
  52. package/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +18 -0
  53. package/android/build.gradle +29 -0
  54. package/android/capacitor.settings.gradle +21 -0
  55. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  56. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  57. package/android/gradle.properties +22 -0
  58. package/android/gradlew +248 -0
  59. package/android/gradlew.bat +92 -0
  60. package/android/settings.gradle +5 -0
  61. package/android/variables.gradle +16 -0
  62. package/capacitor.config.js +29 -0
  63. package/capacitor.config.ts +30 -0
  64. package/demo.md +191 -484
  65. package/dist/main/index.js +91 -51
  66. package/dist/preload/index.js +1 -1
  67. package/dist/renderer/assets/{arc-tTbbM8LO.js → arc-_lugyDzx.js} +1 -1
  68. package/dist/renderer/assets/{architectureDiagram-3BPJPVTR-CEgYow6c.js → architectureDiagram-3BPJPVTR-DDfP-F9D.js} +4 -3
  69. package/dist/renderer/assets/{blockDiagram-GPEHLZMM-LHyVtPwW.js → blockDiagram-GPEHLZMM-DOETUKma.js} +5 -4
  70. package/dist/renderer/assets/{c4Diagram-AAUBKEIU-C1P1eJrf.js → c4Diagram-AAUBKEIU-kAmLfVtk.js} +3 -2
  71. package/dist/renderer/assets/{channel-upve91Tq.js → channel-CD4vJFwr.js} +1 -1
  72. package/dist/renderer/assets/{chunk-2J33WTMH-lag2vhq9.js → chunk-2J33WTMH-DkVrgw4l.js} +1 -1
  73. package/dist/renderer/assets/{chunk-4BX2VUAB-BXJ8Ggh-.js → chunk-4BX2VUAB-JTZ-VKNX.js} +1 -1
  74. package/dist/renderer/assets/{chunk-55IACEB6-CiBpxRa1.js → chunk-55IACEB6-Di_O5box.js} +1 -1
  75. package/dist/renderer/assets/{chunk-727SXJPM-ODeKQFXC.js → chunk-727SXJPM-BgKvwR8w.js} +5 -5
  76. package/dist/renderer/assets/{chunk-AQP2D5EJ-BK7xJolB.js → chunk-AQP2D5EJ-DonSXCCQ.js} +3 -3
  77. package/dist/renderer/assets/{chunk-FMBD7UC4-BxpCZPtz.js → chunk-FMBD7UC4-CsV8Lmy6.js} +1 -1
  78. package/dist/renderer/assets/{chunk-ND2GUHAM-CqqaU9Ue.js → chunk-ND2GUHAM-C_-_dlq7.js} +1 -1
  79. package/dist/renderer/assets/{chunk-QZHKN3VN-Biq_K124.js → chunk-QZHKN3VN-aCmcDsfu.js} +1 -1
  80. package/dist/renderer/assets/{classDiagram-v2-Q7XG4LA2-Cq95X99o.js → classDiagram-4FO5ZUOK-nuHQLjzM.js} +7 -6
  81. package/dist/renderer/assets/{classDiagram-4FO5ZUOK-Cq95X99o.js → classDiagram-v2-Q7XG4LA2-nuHQLjzM.js} +7 -6
  82. package/dist/renderer/assets/{cose-bilkent-S5V4N54A-XasiD0bu.js → cose-bilkent-S5V4N54A-Di1_SXt9.js} +2 -1
  83. package/dist/renderer/assets/{dagre-BM42HDAG-Nq84Gfx4.js → dagre-BM42HDAG-CqOUIYsL.js} +4 -3
  84. package/dist/renderer/assets/{diagram-2AECGRRQ-DwuB1GWt.js → diagram-2AECGRRQ-F-fP19TC.js} +4 -3
  85. package/dist/renderer/assets/{diagram-5GNKFQAL-C2tgeI1h.js → diagram-5GNKFQAL-BD5XZc8G.js} +5 -4
  86. package/dist/renderer/assets/{diagram-KO2AKTUF-D5KzjNBc.js → diagram-KO2AKTUF-Qa3ZxA67.js} +4 -3
  87. package/dist/renderer/assets/{diagram-LMA3HP47-C12xHS1c.js → diagram-LMA3HP47-DqDnw2RA.js} +4 -3
  88. package/dist/renderer/assets/{diagram-OG6HWLK6-CnxI9oEa.js → diagram-OG6HWLK6-BH4Elzby.js} +5 -4
  89. package/dist/renderer/assets/{erDiagram-TEJ5UH35-D_uPaKwn.js → erDiagram-TEJ5UH35-CaKZCewa.js} +5 -4
  90. package/dist/renderer/assets/{flowDiagram-I6XJVG4X-B6q_1-tE.js → flowDiagram-I6XJVG4X-C8znUgyL.js} +7 -6
  91. package/dist/renderer/assets/{ganttDiagram-6RSMTGT7-CFo7ifF9.js → ganttDiagram-6RSMTGT7-DnRvbMnU.js} +3 -2
  92. package/dist/renderer/assets/{gitGraphDiagram-PVQCEYII-WSexHTnq.js → gitGraphDiagram-PVQCEYII-CZuRZzk4.js} +5 -4
  93. package/dist/renderer/assets/{graph-DyX_9f6d.js → graph-CYiEKt0j.js} +1 -1
  94. package/dist/renderer/assets/index-B4uDgADr.js +530 -0
  95. package/dist/renderer/assets/{index-DW7LS8C1.js → index-BX6JHKv6.js} +1430 -408
  96. package/dist/renderer/assets/index-CBcVpA3d.js +30 -0
  97. package/dist/renderer/assets/index-CGj1spkU.js +27 -0
  98. package/dist/renderer/assets/{index-dyHEFYvY.css → index-CcwAgVRi.css} +442 -400
  99. package/dist/renderer/assets/index-D4CPFkph.js +9 -0
  100. package/dist/renderer/assets/index-DxOzbfR-.js +110 -0
  101. package/dist/renderer/assets/index-Y89U1ptl.js +9 -0
  102. package/dist/renderer/assets/{infoDiagram-5YYISTIA-DaeJdLRq.js → infoDiagram-5YYISTIA-BlBUdqMb.js} +3 -2
  103. package/dist/renderer/assets/{ishikawaDiagram-YF4QCWOH-DDCZc35f.js → ishikawaDiagram-YF4QCWOH-TeVytCrP.js} +2 -1
  104. package/dist/renderer/assets/{journeyDiagram-JHISSGLW-BEdmpAgl.js → journeyDiagram-JHISSGLW-BLZa3jnX.js} +5 -4
  105. package/dist/renderer/assets/{kanban-definition-UN3LZRKU-BEFtQcFb.js → kanban-definition-UN3LZRKU-foVxWrJn.js} +3 -2
  106. package/dist/renderer/assets/{layout-CAJgQHdw.js → layout-DOAlFUVb.js} +2 -2
  107. package/dist/renderer/assets/{linear-B2ggJ8Am.js → linear-BMBn6kVq.js} +1 -1
  108. package/dist/renderer/assets/{mindmap-definition-RKZ34NQL-DSxVgHB5.js → mindmap-definition-RKZ34NQL-5pGeNCcp.js} +4 -3
  109. package/dist/renderer/assets/{pieDiagram-4H26LBE5-CwYoJBuL.js → pieDiagram-4H26LBE5-N9aAUxfr.js} +5 -4
  110. package/dist/renderer/assets/preload-helper-tXtZnHb0.js +88 -0
  111. package/dist/renderer/assets/{quadrantDiagram-W4KKPZXB-CST9Fvg9.js → quadrantDiagram-W4KKPZXB-BPxbtjga.js} +3 -2
  112. package/dist/renderer/assets/{requirementDiagram-4Y6WPE33-DtrH52jS.js → requirementDiagram-4Y6WPE33-CK1LrJyG.js} +4 -3
  113. package/dist/renderer/assets/{sankeyDiagram-5OEKKPKP-ca1tPzJ_.js → sankeyDiagram-5OEKKPKP-BNj7Sqii.js} +2 -1
  114. package/dist/renderer/assets/{sequenceDiagram-3UESZ5HK-Dfp1EJZ7.js → sequenceDiagram-3UESZ5HK-B-r7lNhI.js} +4 -3
  115. package/dist/renderer/assets/{stateDiagram-AJRCARHV-Bha2QoNB.js → stateDiagram-AJRCARHV-wrWE0MRa.js} +7 -6
  116. package/dist/renderer/assets/{stateDiagram-v2-BHNVJYJU-DWgFUYu1.js → stateDiagram-v2-BHNVJYJU-CE-Lqo2d.js} +5 -4
  117. package/dist/renderer/assets/{timeline-definition-PNZ67QCA-C3h_-OTj.js → timeline-definition-PNZ67QCA-BkeMGH4J.js} +3 -2
  118. package/dist/renderer/assets/{vennDiagram-CIIHVFJN-DFzjSrZi.js → vennDiagram-CIIHVFJN-BTxVzto3.js} +2 -1
  119. package/dist/renderer/assets/{wardley-L42UT6IY-Cx-VbqoS.js → wardley-L42UT6IY-b-_GPpqL.js} +1 -1
  120. package/dist/renderer/assets/{wardleyDiagram-YWT4CUSO-S2D9XqX6.js → wardleyDiagram-YWT4CUSO-D2r5dVGW.js} +4 -3
  121. package/dist/renderer/assets/web-BKE0SH0E.js +36 -0
  122. package/dist/renderer/assets/web-CBsFp24u.js +564 -0
  123. package/dist/renderer/assets/web-Dc8YgoHP.js +24 -0
  124. package/dist/renderer/assets/web-TfDzToU7.js +58 -0
  125. package/dist/renderer/assets/{xychartDiagram-2RQKCTM6-Cfxigbts.js → xychartDiagram-2RQKCTM6-BHQdINVc.js} +3 -2
  126. package/dist/renderer/index.html +62 -3
  127. package/docs/RELEASE_NOTES_v1.5.1.md +382 -0
  128. package/docs/academic-demo.md +567 -0
  129. package/docs/demo.html +748 -0
  130. package/docs/demo.md +546 -0
  131. package/docs/demo.pdf +0 -0
  132. package/docs/theme-paradigm.md +797 -0
  133. package/electron-builder.yml +7 -0
  134. package/electron.vite.config.js +31 -0
  135. package/electron.vite.config.ts +1 -1
  136. package/ios/App/App/AppDelegate.swift +49 -0
  137. package/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
  138. package/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  139. package/ios/App/App/Assets.xcassets/Contents.json +6 -0
  140. package/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
  141. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
  142. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
  143. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
  144. package/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
  145. package/ios/App/App/Base.lproj/Main.storyboard +19 -0
  146. package/ios/App/App/Info.plist +49 -0
  147. package/ios/App/App.xcodeproj/project.pbxproj +408 -0
  148. package/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  149. package/ios/App/Podfile +28 -0
  150. package/package.json +23 -3
  151. package/resources/templates/slides/template-forest-ink.html +540 -0
  152. package/scripts/generate-icons.js +102 -0
  153. package/src/main/index.ts +106 -68
  154. package/src/preload/index.d.ts +51 -0
  155. package/src/preload/index.js +70 -0
  156. package/src/preload/index.ts +2 -2
  157. package/src/renderer/capacitor-api.ts +713 -0
  158. package/src/renderer/editor/editor.ts +102 -19
  159. package/src/renderer/editor/plugins/index.ts +42 -32
  160. package/src/renderer/editor/plugins/math-plugin.ts +9 -1
  161. package/src/renderer/editor/plugins/mermaid-plugin-custom.css +13 -398
  162. package/src/renderer/editor/plugins/mermaid-plugin.ts +72 -71
  163. package/src/renderer/editor/plugins/themes/base/dark.css +23 -0
  164. package/src/renderer/editor/plugins/themes/base/elegant.css +32 -0
  165. package/src/renderer/editor/plugins/themes/base/light.css +20 -0
  166. package/src/renderer/editor/plugins/themes/base/newsprint.css +27 -0
  167. package/src/renderer/editor/plugins/themes/components/mermaid/academic.css +43 -0
  168. package/src/renderer/editor/plugins/themes/components/mermaid/dark.css +20 -0
  169. package/src/renderer/editor/plugins/themes/components/mermaid/elegant.css +24 -0
  170. package/src/renderer/editor/plugins/themes/components/mermaid/light.css +21 -0
  171. package/src/renderer/editor/plugins/themes/components/mermaid/newsprint.css +26 -0
  172. package/src/renderer/editor/plugins/themes/components/mermaid/variables.css +592 -0
  173. package/src/renderer/editor/plugins/themes/foundation.css +143 -0
  174. package/src/renderer/editor/plugins/themes/theme-manager.ts +133 -0
  175. package/src/renderer/env.d.ts +4 -1
  176. package/src/renderer/index.html +59 -1
  177. package/src/renderer/main.ts +581 -109
  178. package/src/renderer/mobile.css +428 -0
  179. package/themes/README.md +20 -0
  180. package/themes/academic-paper-pt.css +1321 -0
  181. package/themes/academic-paper.css +1416 -0
  182. package/themes/elegant.css +14 -7
  183. package/themes/forest-ink.css +664 -0
  184. package/themes/pixso-design.css +1261 -0
  185. package/themes/swiss-design.css +596 -0
  186. package/themes/template.css +498 -0
  187. package/tsconfig.main.json +1 -0
  188. package/tsconfig.main.tsbuildinfo +1 -0
  189. package/tsconfig.preload.json +1 -0
  190. package/tsconfig.preload.tsbuildinfo +1 -0
  191. package/tsconfig.renderer.json +1 -0
  192. package/tsconfig.renderer.tsbuildinfo +1 -0
  193. package/tsconfig.tsbuildinfo +1 -0
  194. package/.trae/documents/fix-mermaid-colors-and-sankey.md +0 -50
  195. package/src/renderer/themes/theme-manager.ts +0 -40
  196. /package/src/renderer/{themes → editor/plugins/themes}/base.css +0 -0
package/README.md CHANGED
@@ -8,10 +8,49 @@ Real-time collaboration between humans and AI agents — see your agent's change
8
8
 
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
10
  [![GitHub release](https://img.shields.io/github/release/marswaveai/colamd.svg)](https://github.com/marswaveai/colamd/releases)
11
+ [![Version: 1.5.1](https://img.shields.io/badge/Version-1.5.1-blue.svg)](https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.1)
11
12
 
12
13
  **This Extended Edition**: [git@github.com:byteuser1977/ColaMD-extend.git](https://github.com/byteuser1977/ColaMD-extend)
13
14
 
14
- [Features](#features) | [Renderer Plugins](#renderer-plugin-system) | [Plug Menu](#plug-menu--plugin-render-control) | [Quick Start](#quick-start) | [Themes](#theme-system) | [Architecture](#technical-architecture) | [中文](README_CN.md)
15
+ ## 🎉 v1.5.1 Release Highlights (2026-05-23)
16
+
17
+ ### ✨ New Features
18
+
19
+ #### 🎨 Enhanced Theme System
20
+ - **Academic Paper Theme** — GB/T 7713 compliant academic paper formatting with three-line tables, SimHei/SimSun typography, and print-optimized Mermaid diagrams
21
+ - **Swiss Design Theme** 🇨🇭 — Swiss International Typographic Style with black-white-red color system, geometric sans-serif fonts, and grid-based layout
22
+ - **Pixso Design Theme** — Modern design system styling
23
+ - **Forest Ink Theme** — Forest ink aesthetic with warm paper base and forest green accents
24
+ - **Standardized Template** — Reference implementation following v3.0 theme paradigm for easy custom theme creation
25
+ - **Theme Development Framework** — Complete CSS theme development specification (v3.2) with 30+ verifiable rules, WCAG contrast formulas, and print fidelity guidelines
26
+
27
+ #### 📱 Mobile Platform Support
28
+ - **Android (.apk)** — Capacitor 6 integration with native file picker, IME optimization, and PDF export
29
+ - **iOS (.ipa)** — Full iOS support with Capacitor 6
30
+ - **Dual-platform bridge** — Runtime auto-detection of Electron/Capacitor APIs
31
+ - **Mobile-adapted styles** — Optimized touch interface and responsive design
32
+
33
+ #### 🔧 Post-release Improvements
34
+ - **Refactored PDF Export Pipeline** — Auto-extraction of current theme styles, custom print style support, plugin-injected styles
35
+ - **Unified Plugin Style Management** — Dynamic configuration for Math/Mermaid plugins (clipboard, export, rendering styles)
36
+ - **Enhanced Error Recovery** — Dynamic plugin skipping instead of hard-coded exclusions
37
+ - **Custom Theme Export Fix** — Resolved Chromium CSSOM serialization issues
38
+ - **Rendering Output Optimization** — Improved HTML structure for better compatibility
39
+
40
+ ### 🐛 Key Fixes
41
+ - Fixed 15 TypeScript type errors across the codebase
42
+ - Fixed Mermaid text offset and border issues (elegant + academic-paper themes)
43
+ - Fixed Chinese IME input on Android platform
44
+ - Fixed Intent file opening and PDF export on Android
45
+ - Fixed media query missing screen type for mobile
46
+ - Fixed theme print fidelity (@media print mirrors)
47
+ - Decoupled plugin system from main.ts dependencies
48
+
49
+ > ⚠️ **Theme Migration Notice**: Starting from v1.5.1, theme updates have been migrated to [ColaMD-themes](https://github.com/byteuser1977/ColaMD-themes) repository for faster iteration and community contributions.
50
+
51
+ ---
52
+
53
+ [Features](#features) | [Renderer Plugins](#renderer-plugin-system) | [Plug Menu](#plug-menu--plugin-render-control) | [Quick Start](#quick-start) | [Mobile Build](#mobile-build--capacitor-6) | [Themes](#theme-system) | [Architecture](#technical-architecture) | [中文](README_CN.md)
15
54
 
16
55
  ---
17
56
 
@@ -38,18 +77,39 @@ This repository extends **[marswaveai/ColaMD](https://github.com/marswaveai/cola
38
77
  | Math support | ❌ | ✅ KaTeX inline/block equations, live editing, PNG export |
39
78
  | Diagram support | ❌ | ✅ Mermaid full-type diagrams (17+ types), multi-theme adaptation, PNG export |
40
79
  | Dual-mode toggle | N/A | ✅ Each plugin supports **Rendered / Source Edit mode** one-click toggle |
80
+ | Mobile platform | ❌ Desktop only | ✅ **Android (.apk) + iOS (.ipa)** via Capacitor 6 |
41
81
 
42
82
  > All original features are fully preserved: Agent real-time sync, activity indicator, WYSIWYG editor, slide system, themes & export, etc.
43
83
 
44
- ### Demo Document
84
+ ### Demo Documents
85
+
86
+ This project includes comprehensive demo documents to showcase the plugin capabilities:
45
87
 
46
- This project includes a comprehensive demo document [`demo.md`](demo.md) that covers:
88
+ #### General Demo — [`demo.md`](docs/demo.md)
89
+
90
+ A comprehensive demo covering:
47
91
 
48
92
  - **Math Equations**: 7 inline equations + 6 block equations (including systems of equations, matrices, physics formulas)
49
93
  - **Mermaid Diagrams**: All 17 diagram types (flowchart, sequence, class, state, ER, Gantt, pie, journey, git graph, mindmap, timeline, quadrant, XY chart, C4 context, Sankey, block, complex clustered)
50
94
  - **Mixed Content**: Formulas and diagrams rendered together in the same document
51
95
 
52
- Open `demo.md` to fully test the plugin rendering, mode switching, source editing, and PNG export capabilities of the extended ColaMD.
96
+ Open `docs/demo.md` to fully test the plugin rendering, mode switching, source editing, and PNG export capabilities of the extended ColaMD.
97
+
98
+ #### Academic Paper Demo — [`academic-demo.md`](docs/academic-demo.md) 🆕
99
+
100
+ A real-world academic paper demonstrating the enhanced **Academic Paper theme** (`academic-paper.css`):
101
+
102
+ - **Full Academic Structure**: Abstract, keywords, CLC number, document identifier, introduction, methodology, tables, and references
103
+ - **GB/T 7713 Compliance**: Follows Chinese academic paper formatting standards with proper typography (SimHei headings + SimSun body text)
104
+ - **Three-Line Tables**: Academic-standard table format (top line + header bottom line + bottom line, no vertical borders)
105
+ - **Mermaid Diagrams**: Complex organizational charts with custom color schemes optimized for print
106
+ - **Mixed Content**: Mathematical formulas, Mermaid diagrams, tables, and citations in a single document
107
+
108
+ Open `docs/academic-demo.md` in ColaMD with the **Academic Paper** theme active to see the full effect. This demo showcases:
109
+ - Professional academic typography (黑体 for headings, 宋体 for body text)
110
+ - Print-optimized Mermaid diagram rendering
111
+ - Proper code block and blockquote styling for academic contexts
112
+ - Footnotes and reference section formatting
53
113
 
54
114
  ---
55
115
 
@@ -110,10 +170,19 @@ No image? The cover falls back to a clean orange-on-white design — it just wor
110
170
 
111
171
  ### 📤 Export Capabilities
112
172
 
113
- - **PDF / HTML export**
173
+ #### PDF / HTML Export (Enhanced in v1.5.1)
174
+ - **Auto Theme Style Extraction** — Automatically extracts and injects current theme styles into exported documents
175
+ - **Custom Print Style Support** — Supports passing custom print CSS for advanced use cases
176
+ - **Plugin-Injected Styles** — Math and Mermaid plugins dynamically inject their export styles (no more hardcoded style handling)
177
+ - **Smart Error Recovery** — Dynamically skips failing plugins during export instead of hard-coded exclusions
178
+ - **A4 PDF Output** — Proper pagination with 15mm margins, background color preservation, clean output without UI elements
179
+ - **HTML Export** — Standalone HTML with embedded styles, KaTeX CDN for math, inline SVG for Mermaid diagrams, zero-dependency sharing
180
+
114
181
  - **Slide export** — Single HTML file (images Base64-inlined) or folder format (with video resources)
115
182
  - **Equation / Diagram PNG export** — Right-click to export as high-definition PNG images (2x scaling)
116
183
 
184
+ > 💡 **Mobile Export**: On Android/iOS, exported files trigger system share panel for direct sending to WeChat, email, etc.
185
+
117
186
  ### 🎨 Themes & Cross-Platform (Inherited from Original)
118
187
 
119
188
  - **4 built-in themes** + [downloadable themes](themes/) + custom CSS import
@@ -240,6 +309,7 @@ graph TD
240
309
  | **Dark** | GitHub Dark | System default | `#0d1117` background, `#8b949e` border/text |
241
310
  | **Elegant** | Custom warm palette | LXGW WenKai | `#e8e2db` background, warm brown cScale |
242
311
  | **Newsprint** | Print style | PT Serif | Serif font, newsprint texture |
312
+ | **Forest Ink** (custom) | Forest green palette | Noto Serif SC | `#f5f1e8` paper base, `#3d6b4a` forest green accent, ink-green lines |
243
313
 
244
314
  ---
245
315
 
@@ -373,6 +443,218 @@ npm run dist:linux # Linux (.AppImage / .deb)
373
443
  | macOS | `.dmg` |
374
444
  | Windows | `.exe` |
375
445
  | Linux | `.AppImage` / `.deb` |
446
+ | Android | `.apk` (via Capacitor) |
447
+ | iOS | `.ipa` (via Capacitor, requires Xcode) |
448
+
449
+ ---
450
+
451
+ ## Mobile Build — Capacitor 6
452
+
453
+ > Starting from v1.5.1, ColaMD supports building native mobile apps via **[Capacitor 6](https://capacitorjs.com/)** — the cross-platform runtime by Ionic. The same codebase that powers the Electron desktop app now runs on Android and iOS devices.
454
+
455
+ ### Architecture: Dual-Platform Bridge
456
+
457
+ ColaMD uses an **auto-detection bridge layer** that seamlessly switches between Electron (desktop) and Capacitor (mobile) APIs at runtime:
458
+
459
+ ```
460
+ ┌─────────────────────────────────────┐
461
+ │ src/renderer/main.ts │
462
+ │ api = electronAPI || capacitorAPI │ ← Auto-detect platform
463
+ ├──────────────┬──────────────────────┤
464
+ │ Electron │ Capacitor 6 │
465
+ │ (Desktop) │ (Mobile) │
466
+ │ │ │
467
+ │ IPC comm │ Filesystem Plugin │
468
+ │ dialog │ Share Plugin │
469
+ │ shell.open │ App Plugin │
470
+ │ fs module │ localStorage storage │
471
+ └──────────────┴──────────────────────┘
472
+ ```
473
+
474
+ **Key files**:
475
+ - [`capacitor-api.ts`](src/renderer/capacitor-api.ts) — Full Capacitor bridge implementing the same API surface as `electronAPI`
476
+ - [`capacitor.config.ts`](capacitor.config.ts) — Capacitor configuration (appId, webDir, plugins)
477
+ - [`mobile.css`](src/renderer/mobile.css) — Touch-optimized responsive styles
478
+ - [`MainActivity.java`](android/app/src/main/java/cn/bytechain/colamd/MainActivity.java) — Android WebView IME support
479
+
480
+ ### Technology Stack for Mobile
481
+
482
+ | Component | Technology | Purpose |
483
+ |-----------|------------|---------|
484
+ | **Runtime** | Capacitor 6.x | Cross-platform native bridge |
485
+ | **WebView Engine** | Android WebView / iOS WKWebView | Renders web content |
486
+ | **File Access** | `@capacitor/filesystem` | Read/write local files |
487
+ | **File Picker** | `@capawesome/capacitor-file-picker` | Native file selection dialog |
488
+ | **Sharing** | `@capacitor/share` | System share sheet integration |
489
+ | **App Lifecycle** | `@capacitor/app` | Handle app events (pause, resume) |
490
+ | **Status Bar** | `@capacitor/status-bar` | Status bar styling |
491
+ | **Haptics** | `@capacitor/haptics` | Haptic feedback |
492
+
493
+ ### Prerequisites for Mobile Build
494
+
495
+ | Platform | Requirements |
496
+ |----------|-------------|
497
+ | **Android** | Android Studio + SDK (API 34+) + **Java 21** (`brew install openjdk@21`) |
498
+ | **iOS** | Xcode 15+ + CocoaPods + macOS |
499
+
500
+ ### Quick Start — Android
501
+
502
+ ```bash
503
+ # 1. Install dependencies (Capacitor packages included)
504
+ npm install
505
+
506
+ # 2. Build web assets
507
+ npm run build
508
+
509
+ # 3. Sync to Android platform
510
+ npx cap sync android
511
+
512
+ # 4. Open in Android Studio
513
+ npx cap open android
514
+
515
+ # 5. Or build APK directly
516
+ npm run cap:build:android
517
+ # Output: android/app/build/outputs/apk/debug/app-debug.apk
518
+ ```
519
+
520
+ ### Quick Start — iOS
521
+
522
+ ```bash
523
+ # 1. Sync to iOS platform
524
+ npx cap sync ios
525
+
526
+ # 2. Open in Xcode
527
+ npx cap open ios
528
+
529
+ # 3. Build in Xcode (⌘R) or use:
530
+ npm run cap:build:ios
531
+ ```
532
+
533
+ ### Build Commands
534
+
535
+ | Command | Description | Output |
536
+ |---------|-------------|--------|
537
+ | `npm run cap:sync` | Sync web assets to all platforms | Updated `android/` and `ios/` |
538
+ | `npm run cap:open:android` | Open Android project in Android Studio | — |
539
+ | `npm run cap:open:ios` | Open iOS project in Xcode | — |
540
+ | `npm run cap:run:android` | Build → Sync → Run on device/emulator | Live app on device |
541
+ | `npm run cap:run:ios` | Build → Sync → Run on simulator | Live app in simulator |
542
+ | `npm run cap:build:android` | Build **Debug APK** | `android/app/build/outputs/apk/debug/app-debug.apk` |
543
+ | `npm run cap:build:android:release` | Build **Release APK** (signed) | `android/app/build/outputs/apk/release/app-release.apk` |
544
+ | `npm run cap:build:ios` | Prepare iOS project for Xcode build | — |
545
+
546
+ ### Release Build — Android
547
+
548
+ For production release builds, the project includes a signing configuration:
549
+
550
+ ```bash
551
+ # Build signed release APK
552
+ npm run cap:build:android:release
553
+
554
+ # Output location
555
+ android/app/build/outputs/apk/release/app-release.apk
556
+ ```
557
+
558
+ The release keystore is located at `android/app/release.keystore` with credentials stored in `build.gradle`.
559
+
560
+ ### Release Build — iOS
561
+
562
+ 1. Open the project in Xcode:
563
+ ```bash
564
+ npx cap open ios
565
+ ```
566
+
567
+ 2. In Xcode:
568
+ - Select **Product → Archive**
569
+ - Once archived, click **Distribute App**
570
+ - Choose distribution method (App Store Connect, Ad Hoc, etc.)
571
+
572
+ 3. For App Store submission:
573
+ - Configure signing certificates in Xcode
574
+ - Upload to App Store Connect via Xcode or Transporter
575
+
576
+ ### Chinese IME Support (Android)
577
+
578
+ ColaMD includes special handling for Chinese/Japanese/Korean input methods on Android WebView:
579
+
580
+ **Implementation** ([`MainActivity.java`](android/app/src/main/java/cn/bytechain/colamd/MainActivity.java)):
581
+ - WebView focus optimization for IME connection
582
+ - Soft keyboard auto-show on focus
583
+ - Touch mode focusability enabled
584
+
585
+ **Known Limitations**:
586
+ - ProseMirror/Milkdown has known IME composition issues on Android WebView
587
+ - Some input methods may require tapping the editor area to activate
588
+ - If input seems stuck, try tapping elsewhere then back to the editor
589
+
590
+ ### File Picker Integration
591
+
592
+ Mobile platforms use `@capawesome/capacitor-file-picker` for native file selection:
593
+
594
+ ```typescript
595
+ // Example usage (internal)
596
+ const result = await FilePicker.pickFiles({
597
+ types: ['text/markdown', 'text/plain'],
598
+ multiple: false,
599
+ readData: true,
600
+ })
601
+ ```
602
+
603
+ **Supported file types**: `.md`, `.markdown`, `.txt`, `.css` (for themes)
604
+
605
+ ### Mobile Features & Limitations
606
+
607
+ | Feature | Status | Notes |
608
+ |---------|--------|-------|
609
+ | Markdown editing ✏️ | ✅ Fully supported | Milkdown editor runs in WebView |
610
+ | Math rendering (KaTeX) 📐 | ✅ Fully supported | Same as desktop |
611
+ | Mermaid diagrams 🔀 | ✅ Fully supported | SVG renders in WebView |
612
+ | Plugin system | ✅ Fully supported | Toggle via UI, state in localStorage |
613
+ | Themes | ✅ Fully supported | All themes work on mobile |
614
+ | File open/save | ✅ Supported | Native file picker via FilePicker plugin |
615
+ | Chinese/Japanese/Korean input | ⚠️ Partial | IME support implemented, may have edge cases |
616
+ | Export HTML/PDF | ⚠️ Partial | HTML export works; PDF uses `window.print()` |
617
+ | Agent file watch | ⚠️ Polling mode | Uses 2s interval instead of `fs.watch` |
618
+ | Slides preview | ⚠️ Limited | Opens new browser window on desktop; basic on mobile |
619
+ | External links | ✅ Supported | Opens in system browser via `_system` target |
620
+
621
+ ### Responsive Design
622
+
623
+ The mobile CSS ([`mobile.css`](src/renderer/mobile.css)) provides:
624
+
625
+ - **Touch optimization**: Disabled tap highlight, proper touch-action
626
+ - **Safe area support**: Automatic padding for notched devices (iPhone X+, modern Android)
627
+ - **Responsive breakpoints**:
628
+ - ≤768px: Tablet layout adjustments
629
+ - ≤480px: Phone layout with smaller fonts
630
+ - **Editor adaptation**: Fixed-position editor filling viewport below header
631
+ - **Scroll behavior**: `-webkit-overflow-scrolling: touch` for smooth scrolling
632
+ - **Context menu**: Touch-friendly with larger tap targets (12px padding, 15px font)
633
+
634
+ ### Troubleshooting Mobile Issues
635
+
636
+ **Chinese input not working**:
637
+ - Tap the editor area to ensure focus
638
+ - Try switching to another app and back
639
+ - Check that the soft keyboard is visible
640
+
641
+ **File picker not opening**:
642
+ - Ensure storage permissions are granted
643
+ - On Android 11+, check "Allow all the time" for storage permission
644
+
645
+ **App crashes on launch**:
646
+ - Run `npx cap sync android` to ensure latest web assets
647
+ - Check Android Studio logcat for errors
648
+ - Ensure Java 21 is correctly configured
649
+
650
+ **Build fails**:
651
+ ```bash
652
+ # Clean and rebuild
653
+ cd android
654
+ ./gradlew clean
655
+ cd ..
656
+ npm run cap:build:android
657
+ ```
376
658
 
377
659
  ---
378
660
 
@@ -387,32 +669,85 @@ ColaMD includes **4 built-in themes**, and all renderer plugins automatically ad
387
669
  | **Elegant** | `theme-elegant` | Elegant theme, warm serif style (**default theme**) |
388
670
  | **Newsprint** | `theme-newsprint` | Newsprint style |
389
671
 
672
+ Downloadable external themes (located in [`themes/`](themes/) directory):
673
+
674
+ | Theme File | Style Description |
675
+ |------------|-------------------|
676
+ | [elegant.css](themes/elegant.css) | Warm serif with terracotta accents, LXGW WenKai font |
677
+ | [guizang.css](themes/guizang.css) | Ancient Guizang style, ochre accents, ink-black code blocks |
678
+ | [forest-ink.css](themes/forest-ink.css) | 🌲 Forest Ink, warm paper base + forest green ink text + forest green accent |
679
+ | [academic-paper.css](themes/academic-paper.css) | 📄 **Academic Paper** — GB/T 7713 compliant, SimHei headings + SimSun body text, three-line tables, print-optimized Mermaid diagrams (10.5pt font). See [`academic-demo.md`](docs/academic-demo.md) for a complete example |
680
+ | [academic-paper-pt.css](themes/academic-paper-pt.css) | 📄 **Academic Paper (PT units)** — Same GB/T 7713 design as academic-paper.css but using pt units for specific print scenarios |
681
+ | [pixso-design.css](themes/pixso-design.css) | 🎨 Pixso Design, modern design system style |
682
+ | [swiss-design.css](themes/swiss-design.css) | 🇨🇭 **Swiss Design (International Typographic Style)** — Pure black-white-red color system, geometric sans-serif fonts (Helvetica/Inter), grid-based layout with generous whitespace, form follows function. Complete Mermaid diagram integration with monochrome + accent red styling |
683
+ | [template.css](themes/template.css) | 📝 **Standardized Template** — Reference implementation following v3.0 paradigm. Includes complete design tokens, editor styles, code blocks, blockquotes, tables, Mermaid variables, and print styles. Ready-to-use template for creating custom themes |
684
+
685
+ > ⚠️ **Theme Migration Notice**
686
+ >
687
+ > Starting from v1.5.1, **theme updates and maintenance have been migrated to the dedicated repository**:
688
+ >
689
+ > 🔗 **[https://github.com/byteuser1977/ColaMD-themes](https://github.com/byteuser1977/ColaMD-themes)**
690
+ >
691
+ > Future theme enhancements, bug fixes, and new theme submissions will be handled in the ColaMD-themes repository. This allows for:
692
+ > - Faster iteration and release cycles for theme-specific changes
693
+ > - Community contributions and theme submissions
694
+ > - Independent versioning from the core ColaMD application
695
+ > - Focused issue tracking for theme-related problems
696
+ >
697
+ > The themes included in this release will remain available for backward compatibility, but we recommend checking the dedicated repository for the latest versions and new themes.
698
+
390
699
  Custom theme support: Place CSS files in `~/.colamd/themes/` directory, then import via **Theme > Import Theme**. Imported themes persist across sessions.
391
700
 
392
- Community-contributed themes can be downloaded from the [`themes/`](themes/) folder.
701
+ ### Theme Development
702
+
703
+ For developers who want to create custom themes, refer to:
704
+
705
+ - **Theme Paradigm Document**: [`docs/theme-paradigm.md`](docs/theme-paradigm.md) — Complete CSS theme development specification (v3.2)
706
+ - Design principles: variable-driven, modular, semantic naming, AI-agent derivable
707
+ - 30+ verifiable rules (MUST / MUST NOT / SHOULD) including WCAG contrast formulas
708
+ - Print fidelity requirements: variable re-declaration, required element coverage (12 categories)
709
+ - px unit unification standard: prohibits pt/rem mixing for consistent PDF export
710
+ - **Theme Template**: [`themes/template.css`](themes/template.css) — Copy this file as a starting point for your custom theme
711
+ - **Mermaid Variable Reference**: See [`themes/README.md`](themes/README.md) for complete Mermaid CSS variable documentation
393
712
 
394
713
  ---
395
714
 
396
715
  ## Technical Architecture
397
716
 
398
717
  ```
399
- ┌─────────────────────────────────────────────┐
400
- │ Electron Shell │
401
- │ ┌──────────┐ ┌───────────┐ ┌───────────┐ │
402
- │ │ Main │ │ Preload │ │ Renderer │ │
403
- │ │ Process │──│ IPC Bridge│──│ Process │ │
404
- │ └──────────┘ └───────────┘ └─────┬─────┘ │
405
- │ │ │
406
- │ ┌──────────▼────────┐ │
407
- │ │ Milkdown Editor │ │
408
- │ │ (ProseMirror) │ │
409
- │ │ ┌──────────────┐ │ │
410
- │ │ │ Plugin System │ │ │
411
- │ │ │ ├─ 📐 Math │ │ │
412
- │ │ │ └─ 🔀 Mermaid │ │ │
413
- │ │ └──────────────┘ │ │
414
- │ └───────────────────┘ │
415
- └─────────────────────────────────────────────┘
718
+ ┌─────────────────────────────────────────────────────────────┐
719
+ │ ColaMD — Dual Platform │
720
+ │ │
721
+ │ ┌──────────────────────┐ ┌────────────────────────────┐ │
722
+ │ │ Desktop (Electron) │ │ Mobile (Capacitor 6) │ │
723
+ │ │ │ │ │ │
724
+ │ │ ┌─────────┐ ┌──────┐ │ │ ┌──────────────────────┐ │ │
725
+ │ │ │ Main │ │Preload│ │ │ │ Capacitor Runtime │ │ │
726
+ │ │ │Process │ │Bridge │ │ │ │ (WebView / WKWebView)│ │ │
727
+ │ │ └────┬────┘ └──┬───┘ │ │ └──────────┬───────────┘ │ │
728
+ │ │ │ IPC │ │ │ │ Plugins │ │
729
+ │ │ └────┬────┘ │ │ ├─ Filesystem │ │
730
+ │ │ ▼ │ │ ├─ Share │ │
731
+ │ │ ┌─────────────────┐ │ │ ├─ App │ │
732
+ │ │ │ Renderer │ │ │ ├─ StatusBar │ │
733
+ │ │ │ Process │◄─┼───┼─────────────┤ │ │
734
+ │ │ └────────┬────────┘ │ │ └─ Haptics │ │
735
+ │ │ ▼ │ └──────────────┬───────────────┘ │
736
+ │ │ ┌──────────────────┐ │ │ │
737
+ │ │ │ Milkdown Editor │◄┘ │ │
738
+ │ │ │ (ProseMirror) │ │ │
739
+ │ │ │ ┌────────────┐ │ │ │
740
+ │ │ │ │Plugin Syst.│ │ │ │
741
+ │ │ │ │├─ 📐 Math │ │ │ │
742
+ │ │ │ │└─ 🔀Mermaid│ │ │ │
743
+ │ │ │ └────────────┘ │ │ │
744
+ │ │ └──────────────────┘ │ │
745
+ │ └──────────────────────┘ │ │
746
+ │ ┌──────────────────────────┘ │
747
+ │ ▼ │
748
+ │ Auto-detection: │
749
+ │ api = electronAPI || capacitorAPI │
750
+ └─────────────────────────────────────────────────────────────┘
416
751
  ```
417
752
 
418
753
  ### Tech Stack
@@ -420,6 +755,7 @@ Community-contributed themes can be downloaded from the [`themes/`](themes/) fol
420
755
  | Technology | Purpose | Version | Documentation |
421
756
  |------------|---------|---------|---------------|
422
757
  | [Electron](https://www.electronjs.org/) | Cross-platform desktop framework | ^34.0.0 | [📖 Docs](https://www.electronjs.org/docs/latest/) |
758
+ | [Capacitor](https://capacitorjs.com/) | Cross-platform mobile runtime (Android/iOS) | ^6.2.1 | [📖 Docs](https://capacitorjs.com/docs/) |
423
759
  | [Milkdown](https://milkdown.dev/) | WYSIWYG Markdown editor core (ProseMirror-based) | ^7.19.2 | [📖 Docs](https://milkdown.dev/docs) |
424
760
  | [ProseMirror](https://prosemirror.net/) | Underlying rich text editing engine | — | [📖 Docs](https://prosemirror.net/docs/) |
425
761
  | [KaTeX](https://katex.org/) | Math equation rendering engine | ^0.16.46 | [📖 Docs](https://katex.org/docs/) |
@@ -428,7 +764,7 @@ Community-contributed themes can be downloaded from the [`themes/`](themes/) fol
428
764
  | [electron-vite](https://electron-vite.org/) | Electron build toolchain | ^3.0.0 | [📖 Docs](https://electron-vite.org/guide/) |
429
765
  | [Vite](https://vitejs.dev/) | Underlying build engine | ^6.0.0 | [📖 Docs](https://vitejs.dev/guide/) |
430
766
 
431
- > 💡 **Dev Tip**: The official documentation of each library is the best reference for developing new plugins and custom features. In particular, the [KaTeX supported syntax](https://katex.org/docs/supported.html) and [Mermaid diagram syntax](https://mermaid.js.org/intro/syntax-reference.html) are essential for extending plugin capabilities.
767
+ > 💡 **Dev Tip**: The official documentation of each library is the best reference for developing new plugins and custom features. In particular, the [KaTeX supported syntax](https://katex.org/docs/supported.html), [Mermaid diagram syntax](https://mermaid.js.org/intro/syntax-reference.html), and [Capacitor plugins API](https://capacitorjs.com/docs/apis) are essential for extending capabilities across platforms.
432
768
 
433
769
  ### Project Structure
434
770
 
@@ -437,12 +773,15 @@ src/
437
773
  ├── main/
438
774
  │ └── index.ts # Main process: window management, file I/O, menus, file watching
439
775
  ├── preload/
440
- │ └── index.ts # Secure IPC bridge layer
776
+ │ └── index.ts # Secure IPC bridge layer (Electron)
441
777
  └── renderer/
442
778
  ├── index.html # Entry HTML
443
- ├── main.ts # Renderer process entry, connects editor and IPC
779
+ ├── main.ts # Renderer entry: auto-detects Electron or Capacitor
780
+ ├── capacitor-api.ts # ★ Capacitor bridge layer (replaces Electron APIs on mobile)
781
+ ├── mobile.css # ★ Touch-optimized responsive styles
444
782
  ├── editor/
445
783
  │ ├── editor.ts # Editor orchestration core (plugin integration)
784
+ │ └── plugins/ # ★ Renderer plugin system
446
785
  │ ├── html-view.ts # HTML inline node view
447
786
  │ └── plugins/ # ★ Renderer plugin system
448
787
  │ ├── index.ts # Plugin manager (register/query/toggle)
@@ -465,6 +804,139 @@ The entire project has only **5 runtime dependencies** + **6 dev dependencies**,
465
804
 
466
805
  ---
467
806
 
807
+ ## Inline SVG Guide
808
+
809
+ > ⚠️ **Important**: ColaMD uses remark/rehype to parse Markdown, where **blank lines act as paragraph separators**. For inline SVG to render correctly, the entire HTML block (including `<div>`, `<svg>`, `<p>` tags) **must be on a single line without any line breaks**.
810
+
811
+ ### Why Single-Line Format?
812
+
813
+ ColaMD's parsing pipeline:
814
+
815
+ ```
816
+ Markdown Source
817
+ ↓
818
+ remark-parse (Markdown → MDAST)
819
+ ↓
820
+ remark plugins processing
821
+ ↓
822
+ Blank line detection: encountering blank line → creates new paragraph node
823
+ ↓
824
+ rehype (MDAST → HAST)
825
+ ↓
826
+ ProseMirror serialization
827
+ ↓ Each paragraph → independent htmlSchema.node
828
+ ↓
829
+ html-view.ts injects into DOM
830
+ ↓
831
+ Final output: <span class="milkdown-html-inline">single block</span>
832
+ ```
833
+
834
+ **Multi-line format consequence**:
835
+
836
+ ```html
837
+ <!-- If SVG is split across multiple lines (with blank lines) -->
838
+
839
+ Markdown:
840
+ <div>
841
+ <svg>
842
+ <defs>...</defs>
843
+
844
+ <rect/>
845
+
846
+ <circle/>
847
+ </svg>
848
+ </div>
849
+
850
+ Exported HTML:
851
+ <p><span>...<svg><defs>...</defs></svg></span></p> ← Block 1
852
+ <p><span> <rect/></span></p> ← Block 2 (independent!)
853
+ <p><span> <circle/></span></p> ← Block 3 (independent!)
854
+
855
+ Result: ❌ SVG fragmented, cannot render correctly
856
+ ```
857
+
858
+ **Single-line format effect**:
859
+
860
+ ```html
861
+ <!-- Entire content on one line (no blank lines) -->
862
+
863
+ Markdown:
864
+ <div><svg><defs>...</defs><rect/><circle/></svg><p>Caption</p></div>
865
+
866
+ Exported HTML:
867
+ <p><span>
868
+ <div><svg>complete content</svg><p>Caption</p></div>
869
+ </span></p>
870
+
871
+ Result: ✅ Complete SVG renders correctly
872
+ ```
873
+
874
+ ### SVG Specification Requirements
875
+
876
+ | # | Rule | Importance | Description |
877
+ |---|------|------------|-------------|
878
+ | 1 | 🔴 **Single-line compression** | **Required** | Entire `<div>` block must not contain line breaks |
879
+ | 2 | ✅ **Tag closure** | Required | All tags must be properly closed or self-closing |
880
+ | 3 | ✅ **Namespace** | Required | Must include `xmlns="http://www.w3.org/2000/svg"` |
881
+ | 4 | **Size matching** | Required | `width`/`height` must match `viewBox` |
882
+ | 5 | **Double quotes** | Recommended | All attribute values should use double quotes |
883
+ | 6 | **ASCII characters** | Recommended | Avoid special symbols; use `-` instead of `→` |
884
+
885
+ ### Example: Complex Inline SVG
886
+
887
+ ```html
888
+ <div style="text-align: center; margin: 20px 0;"><svg width="600" height="400" viewBox="0 0 600 400" xmlns="http://www.w3.org/2000/svg" style="display: block; margin: 0 auto; background: #f5f5f5; border-radius: 12px;"><defs><linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color:#4A90E2;stop-opacity:1"/><stop offset="100%" style="stop-color:#357ABD;stop-opacity:1"/></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" style="stop-color:#7ED321;stop-opacity:1"/><stop offset="100%" style="stop-color:#5DB80D;stop-opacity:1"/></linearGradient></defs><rect width="600" height="400" fill="#f5f5f5" rx="12"/><rect x="40" y="40" width="520" height="60" rx="8" fill="url(#grad1)"/><text x="300" y="78" fill="white" text-anchor="middle" font-size="22" font-weight="bold">Inline SVG Example</text><circle cx="150" cy="180" r="50" fill="url(#grad1)"/><text x="150" y="188" fill="white" text-anchor="middle" font-size="16" font-weight="bold">Node A</text><rect x="250" y="130" width="100" height="100" rx="10" fill="url(#grad2)"/><text x="300" y="185" fill="white" text-anchor="middle" font-size="16" font-weight="bold">Node B</text><polygon points="450,130 500,180 450,230 400,180" fill="#E74C3C"/><text x="450" y="188" fill="white" text-anchor="middle" font-size="14" font-weight="bold">Node C</text><line x1="200" y1="180" x2="250" y2="180" stroke="#666" stroke-width="2" stroke-dasharray="5,5"/><line x1="350" y1="180" x2="400" y2="180" stroke="#666" stroke-width="2" stroke-dasharray="5,5"/><rect x="100" y="280" width="400" height="80" rx="8" fill="white" stroke="#ddd" stroke-width="1"/><text x="300" y="310" fill="#333" text-anchor="middle" font-size="14" font-weight="bold">Three-Layer Rocket Model</text><text x="300" y="335" fill="#666" text-anchor="middle" font-size="12">Material - Manufacturing - Platform</text></svg><p style="font-size: 10pt; color: #666; margin-top: 12px;">Figure: Complex inline SVG example (single-line compressed format)</p></div>
889
+ ```
890
+
891
+ ### Comparison: Inline vs External SVG
892
+
893
+ | Feature | Inline SVG | External SVG |
894
+ |---------|-----------|--------------|
895
+ | **Use case** | Demo, learning, simple icons | Production environment, complex graphics |
896
+ | **Code location** | Inside Markdown file | Independent `.svg` file |
897
+ | **Format requirement** | 🔴 **Must be single-line compressed** | No special requirements |
898
+ | **Maintainability** | ⚠️ Difficult (long lines hard to read) | ✅ Excellent (independent files) |
899
+ | **Complexity limit** | Limited by single-line length | Unlimited |
900
+ | **Browser cache** | ❌ Cannot be cached | ✅ Auto-cached |
901
+
902
+ ### Best Practices
903
+
904
+ #### When to Use Inline SVG:
905
+ - ✅ Demonstrations and learning purposes
906
+ - ✅ Simple icons (< 10 elements)
907
+ - ✅ Need single-file delivery
908
+ - ✅ Quick prototype development
909
+
910
+ #### When to Use External SVG:
911
+ - ✅ Production documents
912
+ - ✅ Complex graphics (> 20 elements)
913
+ - ✅ Need frequent editing and maintenance
914
+ - ✅ Team collaboration projects
915
+
916
+ ### Maintenance Tips
917
+
918
+ 1. **Use temporary line breaks during editing**
919
+ ```html
920
+ <!-- Development phase: readable format -->
921
+ <svg ...>
922
+ <rect .../>
923
+ <circle .../>
924
+ </svg>
925
+
926
+ <!-- Before saving: compress to one line -->
927
+ <svg ...><rect .../><circle .../></svg>
928
+ ```
929
+
930
+ 2. **Use editor's "Join Lines" feature**
931
+ - VS Code: `Ctrl+J` (Windows) / `Cmd+J` (Mac)
932
+ - WebStorm: `Ctrl+Shift+J`
933
+
934
+ 3. **Version control friendly**
935
+ - Git diff shows entire line changes
936
+ - Consider using `.gitattributes` for long-line handling
937
+
938
+ ---
939
+
468
940
  ## Acknowledgments & Copyright
469
941
 
470
942
  ### Original Project