How laobubu/hypermd works
Project type and purpose
• HyperMD is a JavaScript/TypeScript front-end library that extends CodeMirror into a live Markdown editor.
• It’s not a full-stack application but a modular, front-end plugin framework with a build & demo environment, documentation, and tests.
File structure
• src/: the heart of the library
• core.ts + core/… – the central engine integrating with CodeMirror’s API
• addon/… – incremental extensions (“click,” “fold,” “hover,” etc.)
• mode/… – Markdown mode definitions for CodeMirror
• keymap/… – custom keyboard bindings
• mode/, theme/: SCSS and styling for the editor look & feel
• dev/: build pipelines (pre-build, post-build), doc generators, utility scripts
• docs/: user manual, quick-start, multilingual guides, example pages
• test/: unit/integration tests, bootstrap, dummy editors
• Root configs: package.json, tsconfig.json, rollup.config.js, .travis.yml
README insights
• Core purpose: “Breaks the wall between writing and preview”
• Extensible via addons & powerpacks
• Supports multiple module loaders: CommonJS, AMD (RequireJS), bundlers (webpack, Parcel)
1. External CodeMirror Core (external dependency)
2. HyperMD Core Engine (src/core)
3. Addon Modules (src/addon/*)
4. Mode Modules (src/mode/*)
5. KeyMap Module (src/keymap)
6. PowerPacks (src/powerpack/*)
7. Theme & Styles (mode/*.scss, theme/*.scss)
8. Build & Tooling (dev/*, rollup.config.js)
9. Demo Site (demo/*)
10. Documentation (docs/*)
11. Test Suite (test/*)
• HyperMD Core ↔ CodeMirror API (initialize editor, listen events)
• Addons → HyperMD Core (extend behaviors)
• Modes → Core (tokenize/render Markdown syntax)
• KeyMap → Core (bind shortcuts)
• PowerPacks → Core (on-the-fly third-party integration)
• Styles → Core/UI (SCSS compiled into CSS)
• Build Tools → src → bundle outputs (dist/… as npm package or demo assets)
• Demo Site ← Bundled library + vendor libs
• Tests → src (validate each module)
• Docs (static site) ← markdown ≔ docgen scripts in dev/docgen
c. Architectural patterns & principles
• Modular design: each feature in its own folder, published as a unified package
• Plugin/extension pattern: core provides hooks, addons & powerpacks register themselves
• Build pipeline: pre-build → TypeScript transpile → rollup bundling → post-build (docs, examples)
• Multi-target packaging: UMD for browser, CommonJS for Node/npm, AMD support
d. Key technologies & frameworks
• TypeScript → transpilation APIs (tsconfig.json, dev build scripts)
• Rollup.js → bundling for npm distribution (rollup.config.js)
• CodeMirror v5 → in-browser editor core
• RequireJS / webpack / Parcel → module loading strategies in demo & users’ apps
• SCSS → theme styling