Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run security audit
run: pnpm run security-audit --strict

- name: Build packages
run: pnpm run build
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const themed = applyPreviewTheme(raw); // wraps elements with cm-* classes
```

Pair with any theme CSS (`github.css`, `github-dark.css`, `minimal.css`, or `system.css`) and the styled output just works.
Sanitize untrusted HTML before assigning the themed output to the DOM.

### React Components

Expand Down Expand Up @@ -117,6 +118,8 @@ const html = await renderAsync(blocks, {
});
```

Preview output is intended for trusted content by default. If the markdown or generated HTML can come from users, sanitize it before rendering.

### CSS Custom Property Theming

The `system.css` theme uses CSS custom properties so it adapts to any design system:
Expand Down Expand Up @@ -148,7 +151,7 @@ import '@create-markdown/preview/themes/system.css';

### BYO Sanitizer

Pass any sanitizer function instead of relying on a built-in implementation:
Pass any sanitizer function when rendering untrusted content:

```typescript
import { blocksToHTML } from '@create-markdown/preview';
Expand Down Expand Up @@ -193,6 +196,8 @@ Use `shadowMode: 'none'` to render in the light DOM and inherit page styles:
registerPreviewElement({ shadowMode: 'none' });
```

The web component also assumes trusted markdown by default, so sanitize user-provided content before passing it in.

## Documentation

| Document | Description |
Expand Down
15 changes: 8 additions & 7 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ We release patches for security vulnerabilities in the following versions:

| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
| < 1.0 | :x: |
| 2.x.x | :white_check_mark: |
| < 2.0 | :x: |

## Reporting a Vulnerability

Expand All @@ -16,7 +16,7 @@ We take the security of create-markdown seriously. If you discover a security vu
### How to Report

1. **Do not** open a public GitHub issue for security vulnerabilities
2. Email your findings to **val@viewdue.ai** (replace with your actual security email)
2. Email your findings to **val@viewdue.ai**
3. Alternatively, use [GitHub's private vulnerability reporting](https://github.com/BunsDev/create-markdown/security/advisories/new)

### What to Include
Expand Down Expand Up @@ -51,10 +51,11 @@ We will not pursue civil action or initiate a complaint to law enforcement for a
When using create-markdown in your projects:

1. **Sanitize User Input**: Always sanitize markdown content from untrusted sources before rendering
2. **Keep Dependencies Updated**: Regularly update to the latest version to receive security patches
3. **Content Security Policy**: Implement appropriate CSP headers when rendering markdown in browsers
4. **Review Generated HTML**: Be cautious with HTML output, especially when allowing raw HTML in markdown
2. **Treat Mermaid as Trusted by Default**: Use `mermaidPlugin({ config: { securityLevel: 'strict' } })` when diagram text can come from users
3. **Keep Dependencies Updated**: Regularly update to the latest version to receive security patches
4. **Content Security Policy**: Implement appropriate CSP headers when rendering markdown in browsers
5. **Review Generated HTML**: Be cautious with HTML output, especially when allowing raw HTML in markdown

## Acknowledgments

We appreciate the security research community's efforts in helping keep create-markdown secure. Contributors who report valid security issues will be acknowledged here (with their permission).
We appreciate the security research community's efforts in helping keep create-markdown secure. Contributors who report valid security issues will be acknowledged here (with their permission).
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@
"devDependencies": {
"@changesets/cli": "^2.27.0",
"@testing-library/react": "^16.0.0",
"@vitejs/plugin-react": "^4.3.0",
"jsdom": "^25.0.0",
"tsup": "^8.5.1",
"tsx": "^4.21.0",
"turbo": "^2.3.0",
"typescript": "^5.3.0",
"vitest": "^2.1.0"
"vite": "^7.1.11",
"vitest": "^4.1.2"
},
"pnpm": {
"overrides": {
"lodash-es": "4.18.1"
}
},
"packageManager": "pnpm@10.11.1",
"engines": {
Expand Down
10 changes: 10 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @create-markdown/core

## 2.0.1

### Patch Changes

- Patch release to publish the security remediation update across all packages.

- refresh vulnerable dependency resolutions in the workspace
- ship the pnpm-based security audit improvements
- document trusted-content expectations for preview rendering

## 2.0.0

### Major Changes
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@create-markdown/core",
"version": "2.0.0",
"version": "2.0.1",
"description": "Block-based markdown parsing and serialization with zero dependencies",
"author": "Val Alexander <val@viewdue.ai>",
"license": "MIT",
Expand Down Expand Up @@ -51,7 +51,8 @@
},
"devDependencies": {
"typescript": "^5.3.0",
"vitest": "^2.1.0"
"vite": "^7.1.11",
"vitest": "^4.1.2"
},
"engines": {
"node": ">=20.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ export function toMarkdown(blocksOrDoc: Block[] | { blocks: Block[] }): string {
/**
* Package version
*/
export const VERSION = '2.0.0';
export const VERSION = '2.0.1';
15 changes: 15 additions & 0 deletions packages/create-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# create-markdown

## 2.0.1

### Patch Changes

- Patch release to publish the security remediation update across all packages.

- refresh vulnerable dependency resolutions in the workspace
- ship the pnpm-based security audit improvements
- document trusted-content expectations for preview rendering

- Updated dependencies
- @create-markdown/core@2.0.1
- @create-markdown/react@2.0.1
- @create-markdown/preview@2.0.1

## 2.0.0

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-markdown",
"version": "2.0.0",
"version": "2.0.1",
"description": "Complete block-based markdown notes package - convenience bundle for @create-markdown packages",
"author": "Val Alexander <val@viewdue.ai>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-markdown/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export * from '@create-markdown/core';
/**
* Package version
*/
export const VERSION = '2.0.0';
export const VERSION = '2.0.1';
8 changes: 8 additions & 0 deletions packages/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @create-markdown/docs

## 1.0.1

### Patch Changes

- Updated dependencies
- @create-markdown/core@2.0.1
- @create-markdown/mdx@1.0.1

## 1.0.0

### Major Changes
Expand Down
1 change: 1 addition & 0 deletions packages/docs/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default async function DocPage({ params }: DocPageProps) {

{/* MDX Content */}
<div className="pb-12 pt-8">
{/* Docs content is compiled only from repository-local MDX files in packages/docs/content. */}
<MDXRemote
source={doc.content}
components={mdxComponents}
Expand Down
26 changes: 21 additions & 5 deletions packages/docs/content/api/preview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ pnpm add shiki mermaid

```typescript
import { markdownToHTML } from '@create-markdown/preview';
import DOMPurify from 'dompurify';

const html = markdownToHTML(`
const html = await markdownToHTML(`
# Hello World

This is **bold** and *italic* text.
`);

document.getElementById('preview').innerHTML = html;
const preview = document.getElementById('preview');

if (preview) {
preview.innerHTML = DOMPurify.sanitize(html, { USE_PROFILES: { html: true } });
}
```

Sanitize untrusted content before rendering it. Direct DOM assignment is only appropriate when you fully trust the markdown source.

### With Syntax Highlighting (Shiki)

```typescript
Expand Down Expand Up @@ -69,10 +76,17 @@ flowchart LR
`);

const html = await renderAsync(blocks, {
plugins: [mermaidPlugin({ theme: 'default' })],
plugins: [
mermaidPlugin({
theme: 'default',
config: { securityLevel: 'strict' },
}),
],
});
```

Use Mermaid's stricter security mode when diagram text can come from users. Only opt into looser Mermaid settings for fully trusted content.

### Web Component

```html
Expand Down Expand Up @@ -101,6 +115,8 @@ registerPreviewElement({
});
```

The web component renders trusted content by default, so sanitize user-provided markdown before passing it to the element.

## API

### `blocksToHTML(blocks, options?)`
Expand Down Expand Up @@ -135,11 +151,11 @@ interface PreviewOptions {
classPrefix?: string; // CSS class prefix (default: 'cm-')
theme?: string; // Theme name
linkTarget?: '_blank' | '_self';
sanitize?: boolean; // Sanitize HTML output
sanitize?: boolean | ((html: string) => string);
plugins?: PreviewPlugin[]; // Plugins for enhanced rendering
}
```

## License

MIT
MIT
9 changes: 7 additions & 2 deletions packages/docs/content/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const themed = applyPreviewTheme(raw); // wraps elements with cm-* classes
```

Pair with any theme CSS (`github.css`, `github-dark.css`, `minimal.css`, or `system.css`) and the styled output just works.
Sanitize untrusted HTML before assigning the themed output to the DOM.

### React Components

Expand Down Expand Up @@ -125,6 +126,8 @@ const html = await renderAsync(blocks, {
});
```

Preview output is intended for trusted content by default. If the markdown or generated HTML can come from users, sanitize it before rendering.

### CSS Custom Property Theming

The `system.css` theme uses CSS custom properties so it adapts to any design system:
Expand Down Expand Up @@ -156,7 +159,7 @@ import '@create-markdown/preview/themes/system.css';

### BYO Sanitizer

Pass any sanitizer function instead of relying on a built-in implementation:
Pass any sanitizer function when rendering untrusted content:

```typescript
import { blocksToHTML } from '@create-markdown/preview';
Expand Down Expand Up @@ -201,6 +204,8 @@ Use `shadowMode: 'none'` to render in the light DOM and inherit page styles:
registerPreviewElement({ shadowMode: 'none' });
```

The web component also assumes trusted markdown by default, so sanitize user-provided content before passing it in.

## Documentation

| Document | Description |
Expand Down Expand Up @@ -253,4 +258,4 @@ We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for gu

## License

MIT
MIT
4 changes: 2 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@create-markdown/docs",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"description": "Documentation site for create-markdown",
"type": "module",
Expand All @@ -22,7 +22,7 @@
"cmdk": "^1.0.0",
"lucide-react": "^0.460.0",
"next": "^16.1.6",
"next-mdx-remote": "^5.0.0",
"next-mdx-remote": "^6.0.0",
"next-themes": "^0.4.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/mdx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @create-markdown/mdx

## 1.0.1

### Patch Changes

- Patch release to publish the security remediation update across all packages.

- refresh vulnerable dependency resolutions in the workspace
- ship the pnpm-based security audit improvements
- document trusted-content expectations for preview rendering

- Updated dependencies
- @create-markdown/core@2.0.1

## 1.0.0

### Major Changes
Expand Down
5 changes: 3 additions & 2 deletions packages/mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@create-markdown/mdx",
"version": "1.0.0",
"version": "1.0.1",
"description": "Convert markdown blocks to MDX with component mappings",
"author": "Val Alexander <val@viewdue.ai>",
"license": "MIT",
Expand Down Expand Up @@ -53,7 +53,8 @@
"devDependencies": {
"@types/node": "^20.0.0",
"typescript": "^5.3.0",
"vitest": "^2.1.0"
"vite": "^7.1.11",
"vitest": "^4.1.2"
},
"peerDependencies": {
"@create-markdown/core": ">=2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ export type { Block, TextSpan, BlockType } from '@create-markdown/core';
/**
* Package version
*/
export const VERSION = '1.0.0';
export const VERSION = '1.0.1';
13 changes: 13 additions & 0 deletions packages/preview/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @create-markdown/preview

## 2.0.1

### Patch Changes

- Patch release to publish the security remediation update across all packages.

- refresh vulnerable dependency resolutions in the workspace
- ship the pnpm-based security audit improvements
- document trusted-content expectations for preview rendering

- Updated dependencies
- @create-markdown/core@2.0.1

## 2.0.0

### Major Changes
Expand Down
Loading
Loading