Skip to content

Commit 21b00f5

Browse files
committed
chore: release v1.0.0
Bump @create-markdown/preview to 1.0.0, updating dependencies and introducing new features such as CSS custom property theming and improved sanitization options. Removed the deploy script and updated README for clarity on new functionalities.
1 parent 2ec918e commit 21b00f5

20 files changed

Lines changed: 1663 additions & 173 deletions

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: changesets/action@v1
4545
with:
4646
version: bun run version-packages
47-
publish: bun run release
47+
publish: bun run release:ci
4848
title: 'chore: release packages'
4949
commit: 'chore: release packages'
5050
env:

README.md

Lines changed: 103 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@ Lightweight, block-based markdown solution (_zero dependencies_). Parse, create,
88
## Packages
99
| Package | Version | Description |
1010
|---------|---------|-------------|
11-
| [@create-markdown/core](./packages/core) | 0.1.0 | Zero-dependency parsing and serialization |
12-
| [@create-markdown/react](./packages/react) | 0.1.0 | React components and hooks |
13-
| [@create-markdown/preview](./packages/preview) | 0.1.0 | HTML rendering with Shiki and Mermaid |
14-
| [create-markdown](./packages/create-markdown) | 0.1.0 | Convenience bundle |
11+
| [@create-markdown/core](./packages/core) | 0.2.0 | Zero-dependency parsing and serialization |
12+
| [@create-markdown/react](./packages/react) | 0.2.0 | React components and hooks |
13+
| [@create-markdown/preview](./packages/preview) | 1.0.0 | HTML rendering with themes, plugins, and BYO-parser support |
14+
| [@create-markdown/mdx](./packages/mdx) | 0.2.0 | MDX conversion |
15+
| [create-markdown](./packages/create-markdown) | 0.4.0 | Convenience bundle |
1516

1617
## Key Features
1718
- **Block-based architecture**: Work with structured blocks instead of raw strings
18-
- **Bidirectional conversion**: Parse markdown to blocks, serialize blocks to markdown
19-
- **Rich inline styles**: Bold, italic, code, links, strikethrough, highlights
20-
- **React components**: Optional React bindings for rendering and editing
21-
- **HTML preview**: Framework-agnostic HTML rendering with themes
22-
- **Syntax highlighting**: Shiki plugin for code blocks
23-
- **Diagrams**: Mermaid plugin for flowcharts, sequence diagrams, etc.
24-
- **Web Component**: `<markdown-preview>` custom element
25-
- **Zero dependencies**: Core package has no runtime dependencies
26-
- **Full TypeScript**: Complete type definitions with generics
19+
- **Bidirectional conversion**: Parse markdown to blocks, serialize blocks to markdown
20+
- **Rich inline styles**: Bold, italic, code, links, strikethrough, highlights
21+
- **React components**: Optional React bindings for rendering and editing
22+
- **HTML preview**: Framework-agnostic HTML rendering with themes
23+
- **BYO parser**: Use `applyPreviewTheme()` with `marked`, `markdown-it`, `remark`, or any parser -- no lock-in to `@create-markdown/core`
24+
- **CSS custom property theming**: `system.css` theme integrates with any design system via `--cm-*` variables
25+
- **Syntax highlighting**: Shiki plugin for code blocks
26+
- **Diagrams**: Mermaid plugin for flowcharts, sequence diagrams, etc.
27+
- **Web Component**: `<markdown-preview>` custom element with optional light DOM mode
28+
- **BYO sanitizer**: Plug in DOMPurify or any sanitizer function
29+
- **Theme CSS as strings**: Import theme CSS as string constants for CSS-in-JS or web components
30+
- **Zero dependencies**: Core package has no runtime dependencies
31+
- **Full TypeScript**: Complete type definitions with generics
2732

2833
## Installation
2934
```bash
@@ -37,6 +42,7 @@ bun add create-markdown
3742
```
3843

3944
## Quick Start
45+
4046
### Parse and Serialize Markdown
4147
```typescript
4248
import { parse, stringify, h1, paragraph } from '@create-markdown/core';
@@ -54,6 +60,20 @@ const doc = [
5460
const markdown = stringify(doc);
5561
```
5662

63+
### Use with Any Markdown Parser
64+
65+
`@create-markdown/preview` works with any parser's HTML output -- no need to switch to `@create-markdown/core`:
66+
67+
```typescript
68+
import { applyPreviewTheme } from '@create-markdown/preview';
69+
import { marked } from 'marked';
70+
71+
const raw = marked.parse('# Hello\n\nSome **bold** text.');
72+
const themed = applyPreviewTheme(raw); // wraps elements with cm-* classes
73+
```
74+
75+
Pair with any theme CSS (`github.css`, `github-dark.css`, `minimal.css`, or `system.css`) and the styled output just works.
76+
5777
### React Components
5878

5979
```tsx
@@ -97,6 +117,61 @@ const html = await renderAsync(blocks, {
97117
});
98118
```
99119

120+
### CSS Custom Property Theming
121+
122+
The `system.css` theme uses CSS custom properties so it adapts to any design system:
123+
124+
```css
125+
/* Set once -- the theme adapts to light and dark mode automatically */
126+
:root {
127+
--cm-text: #1f2328;
128+
--cm-bg: #ffffff;
129+
--cm-border: #d1d9e0;
130+
--cm-code-bg: #f6f8fa;
131+
--cm-link: #0969da;
132+
}
133+
134+
@media (prefers-color-scheme: dark) {
135+
:root {
136+
--cm-text: #e6edf3;
137+
--cm-bg: #0d1117;
138+
--cm-border: #30363d;
139+
--cm-code-bg: #161b22;
140+
--cm-link: #58a6ff;
141+
}
142+
}
143+
```
144+
145+
```typescript
146+
import '@create-markdown/preview/themes/system.css';
147+
```
148+
149+
### BYO Sanitizer
150+
151+
Pass any sanitizer function instead of relying on a built-in implementation:
152+
153+
```typescript
154+
import { blocksToHTML } from '@create-markdown/preview';
155+
import DOMPurify from 'dompurify';
156+
157+
const html = blocksToHTML(blocks, {
158+
sanitize: (html) => DOMPurify.sanitize(html, { USE_PROFILES: { html: true } }),
159+
});
160+
```
161+
162+
### Theme CSS as Strings
163+
164+
Import theme CSS as string constants for CSS-in-JS, bundlers that struggle with CSS imports, or web components:
165+
166+
```typescript
167+
import { themes } from '@create-markdown/preview/themes';
168+
169+
// themes.github, themes.githubDark, themes.minimal, themes.system
170+
const style = document.createElement('style');
171+
style.textContent = themes.githubDark;
172+
document.head.appendChild(style);
173+
```
174+
100175
### Web Component
101176

102177
```html
@@ -112,6 +187,12 @@ This renders automatically!
112187
</markdown-preview>
113188
```
114189

190+
Use `shadowMode: 'none'` to render in the light DOM and inherit page styles:
191+
192+
```typescript
193+
registerPreviewElement({ shadowMode: 'none' });
194+
```
195+
115196
## Documentation
116197

117198
| Document | Description |
@@ -147,12 +228,15 @@ bun run playground
147228
```
148229
create-markdown/
149230
├── packages/
150-
│ ├── core/ # @create-markdown/core
151-
│ ├── react/ # @create-markdown/react
152-
│ ├── preview/ # @create-markdown/preview
153-
│ └── create-markdown/ # Convenience bundle
154-
├── playground/ # Demo application
155-
└── .github/ # CI/CD workflows
231+
│ ├── core/ # @create-markdown/core
232+
│ ├── react/ # @create-markdown/react
233+
│ ├── preview/ # @create-markdown/preview
234+
│ ├── mdx/ # @create-markdown/mdx
235+
│ ├── create-markdown/ # Convenience bundle
236+
│ └── docs/ # Documentation site
237+
├── playground/ # Demo application
238+
├── scripts/ # Release and utility scripts
239+
└── .github/ # CI/CD workflows
156240
```
157241

158242
## Contributing

bun.lock

Lines changed: 11 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"docs:convert": "bun packages/docs/scripts/convert.ts",
3131
"changeset": "changeset",
3232
"version-packages": "changeset version",
33-
"release": "turbo run build && changeset publish",
33+
"security-audit": "bash scripts/security-audit.sh",
34+
"release": "bash scripts/release.sh",
35+
"release:ci": "turbo run build && changeset publish",
3436
"prepare": "turbo run build"
3537
},
3638
"devDependencies": {

packages/create-markdown/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"dependencies": {
7777
"@create-markdown/core": "^0.2.0",
7878
"@create-markdown/react": "^0.2.0",
79-
"@create-markdown/preview": "^0.2.0"
79+
"@create-markdown/preview": "^1.0.0"
8080
},
8181
"devDependencies": {
8282
"@types/react": "^18.2.0",

packages/preview/package.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@create-markdown/preview",
3-
"version": "0.2.0",
3+
"version": "1.0.0",
44
"description": "Framework-agnostic HTML rendering for @create-markdown with syntax highlighting and diagrams",
55
"author": "Val Alexander <val@viewdue.ai>",
66
"license": "MIT",
@@ -45,13 +45,25 @@
4545
},
4646
"./themes/github.css": "./dist/themes/github.css",
4747
"./themes/github-dark.css": "./dist/themes/github-dark.css",
48-
"./themes/minimal.css": "./dist/themes/minimal.css"
48+
"./themes/minimal.css": "./dist/themes/minimal.css",
49+
"./themes/system.css": "./dist/themes/system.css",
50+
"./themes": {
51+
"import": {
52+
"types": "./dist/themes/css-strings.d.ts",
53+
"default": "./dist/themes/css-strings.js"
54+
},
55+
"require": {
56+
"types": "./dist/themes/css-strings.d.ts",
57+
"default": "./dist/themes/css-strings.cjs"
58+
}
59+
}
4960
},
5061
"files": [
5162
"dist"
5263
],
5364
"scripts": {
54-
"build": "bun run build:esm && bun run build:cjs && bun run build:types && bun run build:css",
65+
"build": "bun run build:theme-strings && bun run build:esm && bun run build:cjs && bun run build:types && bun run build:css",
66+
"build:theme-strings": "bun scripts/generate-css-strings.ts",
5567
"build:esm": "bun build ./src/index.ts --outfile ./dist/index.js --format esm --external @create-markdown/core --external shiki --external mermaid",
5668
"build:cjs": "bun build ./src/index.ts --outfile ./dist/index.cjs --format cjs --external @create-markdown/core --external shiki --external mermaid",
5769
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
@@ -72,6 +84,9 @@
7284
"mermaid": ">=10.0.0"
7385
},
7486
"peerDependenciesMeta": {
87+
"@create-markdown/core": {
88+
"optional": true
89+
},
7590
"shiki": {
7691
"optional": true
7792
},

0 commit comments

Comments
 (0)