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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,200 changes: 218 additions & 982 deletions AGENTS.md

Large diffs are not rendered by default.

33 changes: 15 additions & 18 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
# Security Policy
# Security policy

## Supported Versions
## Supported versions

| Version | Supported |
|---------|--------------------|
| Latest | :white_check_mark: |

## Reporting a Vulnerability
## Reporting a vulnerability

If you discover a security vulnerability in Comark, please report it responsibly.
If you discover a security vulnerability in Comark, report it privately.

**Do not open a public issue.** Instead, please email us at:
**Do not open a public issue.** Email **security@comark.dev** with:

**security@comark.dev**

Include the following in your report:

- Description of the vulnerability
- A description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if any)
- A suggested fix, if you have one

## Response Timeline
## Response timeline

- **Acknowledgment**: Within 48 hours of receiving the report
- **Assessment**: Within 7 days we will assess the severity and impact
- **Fix**: Critical vulnerabilities will be patched as soon as possible
- **Disclosure**: We will coordinate with you on public disclosure timing
- **Acknowledgment**: within 48 hours of receiving the report
- **Assessment**: we assess severity and impact within 7 days
- **Fix**: we patch critical vulnerabilities as soon as possible
- **Disclosure**: we coordinate public disclosure timing with you

## Scope

Expand All @@ -38,10 +34,11 @@ This policy applies to all packages in the Comark monorepo:
- `@comark/vue`
- `@comark/react`
- `@comark/svelte`
- `@comark/angular`
- `@comark/nuxt` (deprecated)

## Built-in Security
## Built-in security

Comark includes a built-in [security plugin](https://comark.dev/plugins/built-in/security) (`comark/plugins/security`) that provides XSS sanitization. We recommend enabling it when rendering user-generated content.
Comark includes a [security plugin](https://comark.dev/plugins/built-in/security) (`comark/plugins/security`) for XSS sanitization. Enable it when rendering untrusted or user-generated content.

Thank you for helping keep Comark and its users safe.
6 changes: 0 additions & 6 deletions benchmarks/comark-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { markdownItComponents } from 'comark/plugins/components'
import { markdownItAttributes } from 'comark/plugins/attributes'
import { createMarkdownParser } from 'comark'

// Sample markdown content to test with
const sampleMarkdown = `---
title: Benchmark Test
---
Expand Down Expand Up @@ -56,7 +55,6 @@ Card content here

`

// Initialize markdown-it with MDC plugin
const markdownIt = new MarkdownIt({
html: true,
linkify: true,
Expand All @@ -65,7 +63,6 @@ const markdownIt = new MarkdownIt({
.use(markdownItComponents)
.use(markdownItAttributes)

// Initialize markdown-exit with MDC plugin
const markdownExit = new MarkdownExit({
html: true,
linkify: true,
Expand All @@ -80,12 +77,10 @@ const comarkStreaming = createMarkdownParser()

barplot(() => {
group('parse', () => {
// Benchmark: markdown-it parsing
bench('markdown-it parse', () => {
markdownIt.parse(sampleMarkdown, {})
})

// Benchmark: markdown-exit parsing
bench('markdown-exit parse', () => {
markdownExit.parse(sampleMarkdown, {})
})
Expand All @@ -104,6 +99,5 @@ barplot(() => {
})
})

// Run all benchmarks
console.log('🏃 Running benchmarks...\n')
await run()
7 changes: 0 additions & 7 deletions benchmarks/comark-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { markdownItAttributes } from 'comark/plugins/attributes'
import { createMarkdownParser } from 'comark'
import { renderHtmlFromDocument } from '../packages/comark-html/src/index.ts'

// Sample markdown content to test with
const sampleMarkdown = `---
title: Benchmark Test
---
Expand Down Expand Up @@ -57,7 +56,6 @@ Card content here

`

// Initialize markdown-it with MDC plugin
const markdownIt = new MarkdownIt({
html: true,
linkify: true,
Expand All @@ -66,7 +64,6 @@ const markdownIt = new MarkdownIt({
.use(markdownItComponents)
.use(markdownItAttributes)

// Initialize markdown-exit with MDC plugin
const markdownExit = new MarkdownExit({
html: true,
linkify: true,
Expand All @@ -81,17 +78,14 @@ const comarkStreaming = createMarkdownParser()

barplot(() => {
group('render', () => {
// Benchmark: markdown-it render
bench('markdown-it render', () => {
markdownIt.render(sampleMarkdown)
})

// Benchmark: markdown-exit render
bench('markdown-exit render', () => {
markdownExit.render(sampleMarkdown)
})

// Benchmark: comark parse + renderHtmlFromDocument
bench('comark parse + renderHtmlFromDocument', async () => {
const doc = await comark(sampleMarkdown)
renderHtmlFromDocument(doc)
Expand All @@ -109,6 +103,5 @@ barplot(() => {
})
})

// Run all benchmarks
console.log('🏃 Running benchmarks...\n')
await run()
2 changes: 1 addition & 1 deletion benchmarks/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Note ${i + 1} about **module ${i + 1}**.
).join('\n')}
`

/** Nested block and inline components with props — the Comark-specific syntax paths. */
/** Nested block and inline components with props, covering the Comark-specific syntax paths. */
export const componentHeavyMarkdown = `::parent{id="root"}
# Nested components

Expand Down
11 changes: 3 additions & 8 deletions benchmarks/plugin-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ npm run build:module-${i + 1}
`
).join('\n')

// markdown-it / markdown-exit produce flat tokens — to get syntax highlighting
// they still need shiki. We benchmark both pipelines with the same shiki work.
// markdown-it and markdown-exit produce flat tokens; to get syntax highlighting
// they still need shiki. Both pipelines run the same shiki work.
const markdownIt = new MarkdownIt({ html: true, linkify: true })
.enable(['table', 'strikethrough'])
.use(markdownItComponents)
Expand All @@ -101,18 +101,13 @@ const markdownExit = new MarkdownExit({ html: true, linkify: true })
.use(markdownItComponents)
.use(markdownItAttributes)

// comark: baseline vs highlight plugin
const comark = createMarkdownParser()
const comarkHl = createMarkdownParser({ plugins: [shiki()] })

// Pre-warm shiki so we benchmark steady-state, not cold-start
// Warm highlighter and load languages so samples measure steady-state, not cold-start
const shiki = await getHighlighter()

// Warm up comark shiki to ensure shiki languages are loaded
await comarkHl(medium)

// Helper: extract fence tokens from markdown-it/exit and highlight them with shiki
// This simulates what a real markdown-it + shiki pipeline does.
async function highlightTokens(tokens: any[]) {
for (const token of tokens) {
if (token.type === 'fence' && token.info) {
Expand Down
10 changes: 0 additions & 10 deletions benchmarks/plugin-punctuation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { createMarkdownParser } from 'comark'
import { printAnsi } from '@comark/ansi'
import punctuation from '../packages/comark/src/plugins/punctuation'

// ── Test content (exercises ALL features: quotes, dashes, ellipsis, symbols, normalization) ──

const short = `"Hello" -- world... (c) 2025 what???? ok,,`

const medium = `
Expand Down Expand Up @@ -39,8 +37,6 @@ Really???? Wow!!!!! hmm,, ok?.... end
`
).join('\n')

// ── markdown-it typographer ─────────────────────────────────────────────────

const parserTypographer = new MarkdownExit({
html: false,
linkify: true,
Expand All @@ -59,13 +55,9 @@ const parserNoTypographer = new MarkdownExit({
.use(markdownItComponents)
.use(markdownItAttributes)

// ── comark with full punctuation plugin (all features) ──────────────────────

const comarkFull = createMarkdownParser({ plugins: [punctuation()] })
const comarkBaseline = createMarkdownParser()

// ── Benchmarks ──────────────────────────────────────────────────────────────

barplot(() => {
group('short text (all features)', () => {
bench('markdown-it typographer', () => {
Expand Down Expand Up @@ -117,8 +109,6 @@ barplot(() => {
})
})

// ── Output comparison ───────────────────────────────────────────────────────

function flattenText(nodes: any[]): string {
let text = ''
for (const node of nodes) {
Expand Down
Loading
Loading