@changerawr/markdown 1.0.4 → 1.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Owen Bonneville ( supernova@superdev.one )
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @changerawr/markdown
2
2
 
3
- > Powerful TypeScript-first markdown renderer with custom extensions - supports HTML, Tailwind CSS, and JSON outputs
3
+ > Powerful TypeScript-first markdown renderer with modular extensions - supports HTML, Tailwind CSS, and JSON outputs
4
4
 
5
5
  [![npm version](https://badge.fury.io/js/@changerawr%2Fmarkdown.svg)](https://www.npmjs.com/package/@changerawr/markdown)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
@@ -9,7 +9,9 @@
9
9
  ## ✨ Features
10
10
 
11
11
  - 🚀 **Multiple Output Formats**: HTML, Tailwind CSS, or JSON AST
12
- - 🧩 **Custom Extensions**: Built-in Alert, Button, and Embed extensions
12
+ - 🧩 **Modular Extensions**: Every feature is an extension - mix and match what you need
13
+ - 📦 **Core Extensions**: Text, headings, bold, italic, code, links, images, lists, blockquotes, and more
14
+ - 🎨 **Feature Extensions**: Built-in Alert, Button, and Embed extensions
13
15
  - ⚛️ **React Integration**: Drop-in `<MarkdownRenderer>` component + hooks
14
16
  - 🍦 **Vanilla JS Support**: Use anywhere with `renderCum()` function
15
17
  - 📝 **TypeScript First**: Fully typed with excellent IntelliSense
@@ -94,6 +96,57 @@ function MarkdownEditor() {
94
96
  }
95
97
  ```
96
98
 
99
+ ## 🧩 Modular Architecture
100
+
101
+ Unlike traditional markdown parsers, **every feature is an extension**. This gives you complete control over what functionality you include.
102
+
103
+ ### Core Extensions (Always Available)
104
+ - **TextExtension**: Plain text rendering with HTML escaping
105
+ - **HeadingExtension**: H1-H6 headings with anchor links
106
+ - **BoldExtension** & **ItalicExtension**: Text formatting
107
+ - **InlineCodeExtension** & **CodeBlockExtension**: Code syntax
108
+ - **LinkExtension** & **ImageExtension**: Links and images
109
+ - **ListExtension** & **TaskListExtension**: Regular and task lists
110
+ - **BlockquoteExtension**: Quote blocks
111
+ - **HorizontalRuleExtension**: Horizontal dividers
112
+ - **ParagraphExtension** & **LineBreakExtension**: Text flow
113
+
114
+ ### Feature Extensions (Built-in)
115
+ - **AlertExtension**: Colored alert boxes
116
+ - **ButtonExtension**: Interactive styled buttons
117
+ - **EmbedExtension**: Media embeds (YouTube, GitHub, etc.)
118
+
119
+ ### Engine Variants
120
+
121
+ ```typescript
122
+ import {
123
+ createEngine, // Full-featured (default)
124
+ createCoreOnlyEngine, // Just markdown basics
125
+ createMinimalEngine, // Only specified extensions
126
+ createHTMLEngine, // Plain HTML output
127
+ createTailwindEngine // Tailwind CSS output
128
+ } from '@changerawr/markdown';
129
+
130
+ // Full-featured engine (all extensions)
131
+ const full = createEngine();
132
+
133
+ // Core markdown only (no alerts/buttons/embeds)
134
+ const core = createCoreOnlyEngine();
135
+
136
+ // Minimal engine with only specific extensions
137
+ const minimal = createMinimalEngine([
138
+ TextExtension,
139
+ HeadingExtension,
140
+ BoldExtension
141
+ ]);
142
+
143
+ // Custom combination
144
+ const custom = createCustomEngine([
145
+ ...CoreExtensions, // All core extensions
146
+ MyCustomExtension // Your extension
147
+ ]);
148
+ ```
149
+
97
150
  ## 🎨 Output Formats
98
151
 
99
152
  ### Tailwind CSS (Default)
@@ -155,6 +208,8 @@ Add styled buttons with custom actions:
155
208
  ```markdown
156
209
  [button:Get Started](https://example.com){primary,lg}
157
210
  [button:Learn More](https://docs.example.com){secondary,sm}
211
+ [button:Same Tab](https://example.com){success,self}
212
+ [button:Disabled](#){danger,disabled}
158
213
  ```
159
214
 
160
215
  ### Media Embeds
@@ -162,7 +217,8 @@ Embed videos, images, and other media:
162
217
 
163
218
  ```markdown
164
219
  [embed:youtube](https://www.youtube.com/watch?v=dQw4w9WgXcQ){autoplay:1}
165
- [embed:image](https://example.com/image.jpg){width:800,height:600}
220
+ [embed:github](https://github.com/user/repo)
221
+ [embed:codepen](https://codepen.io/user/pen/abc123){height:500,theme:dark}
166
222
  ```
167
223
 
168
224
  ## ⚛️ React Components
@@ -206,7 +262,7 @@ import { ChangerawrMarkdown } from '@changerawr/markdown';
206
262
  const engine = new ChangerawrMarkdown();
207
263
 
208
264
  // Add a highlight extension
209
- engine.registerExtension({
265
+ const highlightExtension = {
210
266
  name: 'highlight',
211
267
  parseRules: [{
212
268
  name: 'highlight',
@@ -221,7 +277,9 @@ engine.registerExtension({
221
277
  type: 'highlight',
222
278
  render: (token) => `<mark class="bg-yellow-200 px-1">${token.content}</mark>`
223
279
  }]
224
- });
280
+ };
281
+
282
+ engine.registerExtension(highlightExtension);
225
283
 
226
284
  const html = engine.toHtml('This is ==highlighted text==');
227
285
  // <mark class="bg-yellow-200 px-1">highlighted text</mark>
@@ -278,10 +336,11 @@ import {
278
336
  createHTMLEngine,
279
337
  createTailwindEngine,
280
338
  createDebugEngine,
281
- createMinimalEngine
339
+ createMinimalEngine,
340
+ createCoreOnlyEngine
282
341
  } from '@changerawr/markdown';
283
342
 
284
- // General purpose engine
343
+ // General purpose engine (all extensions)
285
344
  const engine = createEngine();
286
345
 
287
346
  // HTML-only engine
@@ -290,8 +349,11 @@ const htmlEngine = createHTMLEngine();
290
349
  // Debug-enabled engine
291
350
  const debugEngine = createDebugEngine();
292
351
 
352
+ // Core markdown only (no feature extensions)
353
+ const coreEngine = createCoreOnlyEngine();
354
+
293
355
  // Minimal engine (no built-in extensions)
294
- const minimalEngine = createMinimalEngine();
356
+ const minimalEngine = createMinimalEngine([TextExtension, HeadingExtension]);
295
357
  ```
296
358
 
297
359
  ## 🍦 Standalone Usage (No React)
@@ -299,7 +361,7 @@ const minimalEngine = createMinimalEngine();
299
361
  Perfect for Node.js, vanilla JavaScript, or any non-React environment:
300
362
 
301
363
  ```html
302
- <script src="https://unpkg.com/@changerawr/markdown/dist/standalone.js"></script>
364
+ <script src="https://unpkg.com/@changerawr/markdown/dist/standalone.browser.js"></script>
303
365
  <script>
304
366
  const html = ChangerawrMarkdown.renderCum('# Hello World!');
305
367
  document.body.innerHTML = html;
@@ -316,6 +378,42 @@ const tokens = parseCum('# Hello World');
316
378
 
317
379
  ## 🎨 Styling & Theming
318
380
 
381
+ ### Tailwind CSS Plugin (v3 & v4 Compatible)
382
+
383
+ **For Tailwind CSS v3:**
384
+ ```javascript
385
+ // tailwind.config.js
386
+ const { changerawrMarkdownPlugin } = require('@changerawr/markdown/tailwind');
387
+
388
+ module.exports = {
389
+ content: ['./src/**/*.{js,ts,jsx,tsx}'],
390
+ plugins: [
391
+ changerawrMarkdownPlugin({
392
+ includeExtensions: true, // Include alert/button styles
393
+ darkMode: true // Include dark mode variants
394
+ })
395
+ ]
396
+ }
397
+ ```
398
+
399
+ **For Tailwind CSS v4:**
400
+ ```javascript
401
+ // tailwind.config.js
402
+ import { changerawrMarkdownPlugin } from '@changerawr/markdown/tailwind';
403
+
404
+ export default {
405
+ content: ['./src/**/*.{js,ts,jsx,tsx}'],
406
+ plugins: [
407
+ changerawrMarkdownPlugin({
408
+ includeExtensions: true, // Include alert/button styles
409
+ darkMode: true // Include dark mode variants
410
+ })
411
+ ]
412
+ }
413
+ ```
414
+
415
+ The plugin ensures all necessary classes are available for markdown rendering, even if they're not used elsewhere in your app.
416
+
319
417
  ### Custom CSS Classes
320
418
 
321
419
  ```typescript
@@ -349,6 +447,9 @@ const docsEngine = createEngineWithPreset('docs');
349
447
 
350
448
  // Minimal styling
351
449
  const minimalEngine = createEngineWithPreset('minimal');
450
+
451
+ // Core-only (no feature extensions)
452
+ const coreEngine = createEngineWithPreset('coreOnly');
352
453
  ```
353
454
 
354
455
  ## 🔍 Debugging & Development
@@ -400,7 +501,8 @@ console.log('Token count:', metrics.tokenCount);
400
501
 
401
502
  ### Optimization Tips
402
503
 
403
- - Use `createMinimalEngine()` if you don't need built-in extensions
504
+ - Use `createCoreOnlyEngine()` if you don't need feature extensions
505
+ - Use `createMinimalEngine()` with only the extensions you need
404
506
  - Set `sanitize: false` if you trust your content (be careful!)
405
507
  - Use `format: 'html'` for lighter output without CSS classes
406
508
  - Implement custom extensions efficiently to avoid performance bottlenecks
@@ -425,6 +527,16 @@ npm run test:coverage # Run with coverage report
425
527
  - `renderToTailwind(markdown: string): string` - Render with Tailwind classes
426
528
  - `renderToJSON(markdown: string): JsonAstNode` - Render to JSON AST
427
529
 
530
+ ### Factory Functions
531
+
532
+ - `createEngine(config?)` - Full-featured engine
533
+ - `createCoreOnlyEngine(config?)` - Core markdown only
534
+ - `createMinimalEngine(extensions[])` - Minimal with specified extensions
535
+ - `createHTMLEngine(config?)` - HTML output optimized
536
+ - `createTailwindEngine(config?)` - Tailwind output optimized
537
+ - `createDebugEngine(config?)` - Debug mode enabled
538
+ - `createCustomEngine(extensions[], config?)` - Custom extension set
539
+
428
540
  ### React Components
429
541
 
430
542
  - `<MarkdownRenderer />` - Main React component
@@ -444,6 +556,12 @@ npm run test:coverage # Run with coverage report
444
556
  - `MarkdownParser` - Content parsing
445
557
  - `MarkdownRenderer` - Token rendering
446
558
 
559
+ ### Extensions
560
+
561
+ - **Core Extensions**: `CoreExtensions` array or individual exports
562
+ - **Feature Extensions**: `AlertExtension`, `ButtonExtension`, `EmbedExtension`
563
+ - **Custom**: Create your own with `parseRules` and `renderRules`
564
+
447
565
  ## 🤝 Contributing
448
566
 
449
567
  We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
@@ -462,9 +580,9 @@ MIT © [Changerawr Team](https://github.com/changerawr)
462
580
 
463
581
  ## 💡 What Makes It Special?
464
582
 
583
+ - **Extension-First Architecture**: Every feature is modular - use only what you need
465
584
  - **TypeScript-First**: Built with TypeScript from the ground up for excellent developer experience
466
585
  - **Framework Agnostic**: Works with React, Vue, Svelte, vanilla JS, or any framework
467
- - **Extensible Architecture**: Easy to add custom markdown syntax and rendering
468
586
  - **Production Ready**: Thoroughly tested, performant, and secure
469
587
  - **Modern Output**: Tailwind CSS support for modern web applications
470
588
  - **Developer Friendly**: Great debugging tools and clear error messages
package/dist/index.d.mts CHANGED
@@ -91,53 +91,18 @@ declare class ChangerawrMarkdown {
91
91
  private renderer;
92
92
  private extensions;
93
93
  constructor(config?: EngineConfig);
94
- /**
95
- * Register a custom extension
96
- */
94
+ private registerFeatureExtensions;
95
+ private registerCoreExtensions;
97
96
  registerExtension(extension: Extension): ExtensionRegistration;
98
- /**
99
- * Unregister an extension
100
- */
101
97
  unregisterExtension(name: string): boolean;
102
- /**
103
- * Parse markdown content into tokens
104
- */
105
98
  parse(markdown: string): MarkdownToken[];
106
- /**
107
- * Render tokens to HTML
108
- */
109
99
  render(tokens: MarkdownToken[]): string;
110
- /**
111
- * Parse and render markdown to HTML in one step
112
- */
113
100
  toHtml(markdown: string): string;
114
- /**
115
- * Get list of registered extensions
116
- */
117
101
  getExtensions(): string[];
118
- /**
119
- * Check if extension is registered
120
- */
121
102
  hasExtension(name: string): boolean;
122
- /**
123
- * Get parser warnings
124
- */
125
103
  getWarnings(): string[];
126
- /**
127
- * Get debug information from last render
128
- */
129
104
  getDebugInfo(): DebugInfo | null;
130
- /**
131
- * Get performance metrics for the last operation
132
- */
133
105
  getPerformanceMetrics(): PerformanceMetrics | null;
134
- /**
135
- * Register built-in extensions
136
- */
137
- private registerBuiltInExtensions;
138
- /**
139
- * Rebuild parser and renderer with current extensions
140
- */
141
106
  private rebuildParserAndRenderer;
142
107
  }
143
108
  declare function parseMarkdown(content: string): MarkdownToken[];
@@ -409,7 +374,6 @@ declare class MarkdownParser {
409
374
  private config;
410
375
  constructor(config?: ParserConfig);
411
376
  addRule(rule: ParseRule): void;
412
- setupDefaultRulesIfEmpty(): void;
413
377
  hasRule(name: string): boolean;
414
378
  parse(markdown: string): MarkdownToken[];
415
379
  getWarnings(): string[];
@@ -417,11 +381,9 @@ declare class MarkdownParser {
417
381
  updateConfig(config: Partial<ParserConfig>): void;
418
382
  setDebugMode(enabled: boolean): void;
419
383
  clearWarnings(): void;
420
- getIterationCount(): number;
421
384
  private preprocessMarkdown;
422
385
  private validateMarkdown;
423
386
  private postProcessTokens;
424
- private setupDefaultRules;
425
387
  }
426
388
 
427
389
  declare class MarkdownRenderer {
@@ -432,15 +394,14 @@ declare class MarkdownRenderer {
432
394
  addRule(rule: RenderRule): void;
433
395
  hasRule(type: string): boolean;
434
396
  render(tokens: MarkdownToken[]): string;
397
+ private renderToken;
398
+ private createErrorBlock;
399
+ private createDebugBlock;
435
400
  getWarnings(): string[];
436
401
  getConfig(): RendererConfig;
437
402
  updateConfig(config: Partial<RendererConfig>): void;
438
403
  setDebugMode(enabled: boolean): void;
439
404
  clearWarnings(): void;
440
- private renderToken;
441
- private createErrorBlock;
442
- private createDebugBlock;
443
- private setupDefaultRules;
444
405
  }
445
406
 
446
407
  declare const AlertExtension: Extension;
@@ -449,6 +410,33 @@ declare const ButtonExtension: Extension;
449
410
 
450
411
  declare const EmbedExtension: Extension;
451
412
 
413
+ declare const BlockquoteExtension: Extension;
414
+
415
+ declare const LineBreakExtension: Extension;
416
+
417
+ declare const InlineCodeExtension: Extension;
418
+ declare const CodeBlockExtension: Extension;
419
+
420
+ declare const BoldExtension: Extension;
421
+ declare const ItalicExtension: Extension;
422
+
423
+ declare const HeadingExtension: Extension;
424
+
425
+ declare const HorizontalRuleExtension: Extension;
426
+
427
+ declare const ImageExtension: Extension;
428
+
429
+ declare const LinkExtension: Extension;
430
+
431
+ declare const ListExtension: Extension;
432
+ declare const TaskListExtension: Extension;
433
+
434
+ declare const ParagraphExtension: Extension;
435
+
436
+ declare const TextExtension: Extension;
437
+
438
+ declare const CoreExtensions: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
439
+
452
440
  /**
453
441
  * @changerawr/markdown - Main package exports
454
442
  *
@@ -473,9 +461,13 @@ declare function createTailwindEngine(config?: Omit<EngineConfig, 'renderer'>):
473
461
  */
474
462
  declare function createDebugEngine(config?: EngineConfig): ChangerawrMarkdown;
475
463
  /**
476
- * Create an engine without built-in extensions (minimal setup)
464
+ * Create an engine with only specified extensions (minimal setup)
465
+ */
466
+ declare function createMinimalEngine(extensions?: Extension[]): ChangerawrMarkdown;
467
+ /**
468
+ * Create an engine with only core markdown extensions (no custom features)
477
469
  */
478
- declare function createMinimalEngine(config?: EngineConfig): ChangerawrMarkdown;
470
+ declare function createCoreOnlyEngine(config?: EngineConfig): ChangerawrMarkdown;
479
471
  /**
480
472
  * Create an engine with custom extensions only
481
473
  */
@@ -496,11 +488,27 @@ declare const markdown: {
496
488
  readonly createTailwindEngine: typeof createTailwindEngine;
497
489
  readonly createDebugEngine: typeof createDebugEngine;
498
490
  readonly createMinimalEngine: typeof createMinimalEngine;
491
+ readonly createCoreOnlyEngine: typeof createCoreOnlyEngine;
499
492
  readonly createCustomEngine: typeof createCustomEngine;
500
493
  readonly renderCum: typeof renderCum;
501
494
  readonly parseCum: typeof parseCum;
502
495
  readonly ChangerawrMarkdown: typeof ChangerawrMarkdown;
503
496
  readonly extensions: {
497
+ readonly core: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
498
+ readonly Text: Extension;
499
+ readonly Heading: Extension;
500
+ readonly Bold: Extension;
501
+ readonly Italic: Extension;
502
+ readonly InlineCode: Extension;
503
+ readonly CodeBlock: Extension;
504
+ readonly Link: Extension;
505
+ readonly Image: Extension;
506
+ readonly List: Extension;
507
+ readonly TaskList: Extension;
508
+ readonly Blockquote: Extension;
509
+ readonly HorizontalRule: Extension;
510
+ readonly Paragraph: Extension;
511
+ readonly LineBreak: Extension;
504
512
  readonly Alert: Extension;
505
513
  readonly Button: Extension;
506
514
  readonly Embed: Extension;
@@ -563,6 +571,14 @@ declare const presets: {
563
571
  readonly sanitize: true;
564
572
  };
565
573
  };
574
+ /**
575
+ * Core-only preset with just markdown basics
576
+ */
577
+ readonly coreOnly: {
578
+ readonly renderer: {
579
+ readonly format: "tailwind";
580
+ };
581
+ };
566
582
  /**
567
583
  * Performance preset with minimal processing
568
584
  */
@@ -582,4 +598,4 @@ declare const presets: {
582
598
  */
583
599
  declare function createEngineWithPreset(presetName: keyof typeof presets, additionalConfig?: EngineConfig): ChangerawrMarkdown;
584
600
 
585
- export { type ASTStatistics, AlertExtension, ButtonExtension, ChangerawrMarkdown, type DebugInfo, EmbedExtension, type EngineConfig, type EngineEvents, type Extension, ExtensionError, type Extension as ExtensionInterface, type ExtensionRegistration, type JsonAstNode, Logger, MarkdownParseError, MarkdownParser, MarkdownRenderError, MarkdownRenderer, type MarkdownToken, type OutputFormat, type ParseRule, type ParserConfig, type PerformanceMetrics, PerformanceTimer, type RenderRule, type RendererConfig, type TokenComparison, type TokenDifference, type TokenStatistics, type TokenType, astToJSONString, astToTokens, basicSanitize, compareTokens, createCumEngine, createCustomEngine, createDebugEngine, createEngine, createEngineWithPreset, createHTMLEngine, createMinimalEngine, createTailwindEngine, debounce, deepMerge, markdown as default, defaultTailwindClasses, escapeHtml, extractDomain, generateId, getASTStats, getTokenStats, isBrowser, isNode, isValidUrl, markdown, minimalClasses, parseASTFromJSON, parseCum, parseMarkdown, parseOptions, parseTokensFromJSON, presets, proseClasses, renderCum, renderCumToHtml, renderCumToJson, renderCumToTailwind, renderMarkdown, renderToAST, renderToHTML, renderToHTMLUnsafe, renderToHTMLWithConfig, renderToJSON, renderToTailwind, renderToTailwindWithClasses, renderToTailwindWithConfig, sanitizeHtml, tokensToAST, tokensToJSONString };
601
+ export { type ASTStatistics, AlertExtension, BlockquoteExtension, BoldExtension, ButtonExtension, ChangerawrMarkdown, CodeBlockExtension, CoreExtensions, type DebugInfo, EmbedExtension, type EngineConfig, type EngineEvents, type Extension, ExtensionError, type Extension as ExtensionInterface, type ExtensionRegistration, HeadingExtension, HorizontalRuleExtension, ImageExtension, InlineCodeExtension, ItalicExtension, type JsonAstNode, LineBreakExtension, LinkExtension, ListExtension, Logger, MarkdownParseError, MarkdownParser, MarkdownRenderError, MarkdownRenderer, type MarkdownToken, type OutputFormat, ParagraphExtension, type ParseRule, type ParserConfig, type PerformanceMetrics, PerformanceTimer, type RenderRule, type RendererConfig, TaskListExtension, TextExtension, type TokenComparison, type TokenDifference, type TokenStatistics, type TokenType, astToJSONString, astToTokens, basicSanitize, compareTokens, createCoreOnlyEngine, createCumEngine, createCustomEngine, createDebugEngine, createEngine, createEngineWithPreset, createHTMLEngine, createMinimalEngine, createTailwindEngine, debounce, deepMerge, markdown as default, defaultTailwindClasses, escapeHtml, extractDomain, generateId, getASTStats, getTokenStats, isBrowser, isNode, isValidUrl, markdown, minimalClasses, parseASTFromJSON, parseCum, parseMarkdown, parseOptions, parseTokensFromJSON, presets, proseClasses, renderCum, renderCumToHtml, renderCumToJson, renderCumToTailwind, renderMarkdown, renderToAST, renderToHTML, renderToHTMLUnsafe, renderToHTMLWithConfig, renderToJSON, renderToTailwind, renderToTailwindWithClasses, renderToTailwindWithConfig, sanitizeHtml, tokensToAST, tokensToJSONString };
package/dist/index.d.ts CHANGED
@@ -91,53 +91,18 @@ declare class ChangerawrMarkdown {
91
91
  private renderer;
92
92
  private extensions;
93
93
  constructor(config?: EngineConfig);
94
- /**
95
- * Register a custom extension
96
- */
94
+ private registerFeatureExtensions;
95
+ private registerCoreExtensions;
97
96
  registerExtension(extension: Extension): ExtensionRegistration;
98
- /**
99
- * Unregister an extension
100
- */
101
97
  unregisterExtension(name: string): boolean;
102
- /**
103
- * Parse markdown content into tokens
104
- */
105
98
  parse(markdown: string): MarkdownToken[];
106
- /**
107
- * Render tokens to HTML
108
- */
109
99
  render(tokens: MarkdownToken[]): string;
110
- /**
111
- * Parse and render markdown to HTML in one step
112
- */
113
100
  toHtml(markdown: string): string;
114
- /**
115
- * Get list of registered extensions
116
- */
117
101
  getExtensions(): string[];
118
- /**
119
- * Check if extension is registered
120
- */
121
102
  hasExtension(name: string): boolean;
122
- /**
123
- * Get parser warnings
124
- */
125
103
  getWarnings(): string[];
126
- /**
127
- * Get debug information from last render
128
- */
129
104
  getDebugInfo(): DebugInfo | null;
130
- /**
131
- * Get performance metrics for the last operation
132
- */
133
105
  getPerformanceMetrics(): PerformanceMetrics | null;
134
- /**
135
- * Register built-in extensions
136
- */
137
- private registerBuiltInExtensions;
138
- /**
139
- * Rebuild parser and renderer with current extensions
140
- */
141
106
  private rebuildParserAndRenderer;
142
107
  }
143
108
  declare function parseMarkdown(content: string): MarkdownToken[];
@@ -409,7 +374,6 @@ declare class MarkdownParser {
409
374
  private config;
410
375
  constructor(config?: ParserConfig);
411
376
  addRule(rule: ParseRule): void;
412
- setupDefaultRulesIfEmpty(): void;
413
377
  hasRule(name: string): boolean;
414
378
  parse(markdown: string): MarkdownToken[];
415
379
  getWarnings(): string[];
@@ -417,11 +381,9 @@ declare class MarkdownParser {
417
381
  updateConfig(config: Partial<ParserConfig>): void;
418
382
  setDebugMode(enabled: boolean): void;
419
383
  clearWarnings(): void;
420
- getIterationCount(): number;
421
384
  private preprocessMarkdown;
422
385
  private validateMarkdown;
423
386
  private postProcessTokens;
424
- private setupDefaultRules;
425
387
  }
426
388
 
427
389
  declare class MarkdownRenderer {
@@ -432,15 +394,14 @@ declare class MarkdownRenderer {
432
394
  addRule(rule: RenderRule): void;
433
395
  hasRule(type: string): boolean;
434
396
  render(tokens: MarkdownToken[]): string;
397
+ private renderToken;
398
+ private createErrorBlock;
399
+ private createDebugBlock;
435
400
  getWarnings(): string[];
436
401
  getConfig(): RendererConfig;
437
402
  updateConfig(config: Partial<RendererConfig>): void;
438
403
  setDebugMode(enabled: boolean): void;
439
404
  clearWarnings(): void;
440
- private renderToken;
441
- private createErrorBlock;
442
- private createDebugBlock;
443
- private setupDefaultRules;
444
405
  }
445
406
 
446
407
  declare const AlertExtension: Extension;
@@ -449,6 +410,33 @@ declare const ButtonExtension: Extension;
449
410
 
450
411
  declare const EmbedExtension: Extension;
451
412
 
413
+ declare const BlockquoteExtension: Extension;
414
+
415
+ declare const LineBreakExtension: Extension;
416
+
417
+ declare const InlineCodeExtension: Extension;
418
+ declare const CodeBlockExtension: Extension;
419
+
420
+ declare const BoldExtension: Extension;
421
+ declare const ItalicExtension: Extension;
422
+
423
+ declare const HeadingExtension: Extension;
424
+
425
+ declare const HorizontalRuleExtension: Extension;
426
+
427
+ declare const ImageExtension: Extension;
428
+
429
+ declare const LinkExtension: Extension;
430
+
431
+ declare const ListExtension: Extension;
432
+ declare const TaskListExtension: Extension;
433
+
434
+ declare const ParagraphExtension: Extension;
435
+
436
+ declare const TextExtension: Extension;
437
+
438
+ declare const CoreExtensions: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
439
+
452
440
  /**
453
441
  * @changerawr/markdown - Main package exports
454
442
  *
@@ -473,9 +461,13 @@ declare function createTailwindEngine(config?: Omit<EngineConfig, 'renderer'>):
473
461
  */
474
462
  declare function createDebugEngine(config?: EngineConfig): ChangerawrMarkdown;
475
463
  /**
476
- * Create an engine without built-in extensions (minimal setup)
464
+ * Create an engine with only specified extensions (minimal setup)
465
+ */
466
+ declare function createMinimalEngine(extensions?: Extension[]): ChangerawrMarkdown;
467
+ /**
468
+ * Create an engine with only core markdown extensions (no custom features)
477
469
  */
478
- declare function createMinimalEngine(config?: EngineConfig): ChangerawrMarkdown;
470
+ declare function createCoreOnlyEngine(config?: EngineConfig): ChangerawrMarkdown;
479
471
  /**
480
472
  * Create an engine with custom extensions only
481
473
  */
@@ -496,11 +488,27 @@ declare const markdown: {
496
488
  readonly createTailwindEngine: typeof createTailwindEngine;
497
489
  readonly createDebugEngine: typeof createDebugEngine;
498
490
  readonly createMinimalEngine: typeof createMinimalEngine;
491
+ readonly createCoreOnlyEngine: typeof createCoreOnlyEngine;
499
492
  readonly createCustomEngine: typeof createCustomEngine;
500
493
  readonly renderCum: typeof renderCum;
501
494
  readonly parseCum: typeof parseCum;
502
495
  readonly ChangerawrMarkdown: typeof ChangerawrMarkdown;
503
496
  readonly extensions: {
497
+ readonly core: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
498
+ readonly Text: Extension;
499
+ readonly Heading: Extension;
500
+ readonly Bold: Extension;
501
+ readonly Italic: Extension;
502
+ readonly InlineCode: Extension;
503
+ readonly CodeBlock: Extension;
504
+ readonly Link: Extension;
505
+ readonly Image: Extension;
506
+ readonly List: Extension;
507
+ readonly TaskList: Extension;
508
+ readonly Blockquote: Extension;
509
+ readonly HorizontalRule: Extension;
510
+ readonly Paragraph: Extension;
511
+ readonly LineBreak: Extension;
504
512
  readonly Alert: Extension;
505
513
  readonly Button: Extension;
506
514
  readonly Embed: Extension;
@@ -563,6 +571,14 @@ declare const presets: {
563
571
  readonly sanitize: true;
564
572
  };
565
573
  };
574
+ /**
575
+ * Core-only preset with just markdown basics
576
+ */
577
+ readonly coreOnly: {
578
+ readonly renderer: {
579
+ readonly format: "tailwind";
580
+ };
581
+ };
566
582
  /**
567
583
  * Performance preset with minimal processing
568
584
  */
@@ -582,4 +598,4 @@ declare const presets: {
582
598
  */
583
599
  declare function createEngineWithPreset(presetName: keyof typeof presets, additionalConfig?: EngineConfig): ChangerawrMarkdown;
584
600
 
585
- export { type ASTStatistics, AlertExtension, ButtonExtension, ChangerawrMarkdown, type DebugInfo, EmbedExtension, type EngineConfig, type EngineEvents, type Extension, ExtensionError, type Extension as ExtensionInterface, type ExtensionRegistration, type JsonAstNode, Logger, MarkdownParseError, MarkdownParser, MarkdownRenderError, MarkdownRenderer, type MarkdownToken, type OutputFormat, type ParseRule, type ParserConfig, type PerformanceMetrics, PerformanceTimer, type RenderRule, type RendererConfig, type TokenComparison, type TokenDifference, type TokenStatistics, type TokenType, astToJSONString, astToTokens, basicSanitize, compareTokens, createCumEngine, createCustomEngine, createDebugEngine, createEngine, createEngineWithPreset, createHTMLEngine, createMinimalEngine, createTailwindEngine, debounce, deepMerge, markdown as default, defaultTailwindClasses, escapeHtml, extractDomain, generateId, getASTStats, getTokenStats, isBrowser, isNode, isValidUrl, markdown, minimalClasses, parseASTFromJSON, parseCum, parseMarkdown, parseOptions, parseTokensFromJSON, presets, proseClasses, renderCum, renderCumToHtml, renderCumToJson, renderCumToTailwind, renderMarkdown, renderToAST, renderToHTML, renderToHTMLUnsafe, renderToHTMLWithConfig, renderToJSON, renderToTailwind, renderToTailwindWithClasses, renderToTailwindWithConfig, sanitizeHtml, tokensToAST, tokensToJSONString };
601
+ export { type ASTStatistics, AlertExtension, BlockquoteExtension, BoldExtension, ButtonExtension, ChangerawrMarkdown, CodeBlockExtension, CoreExtensions, type DebugInfo, EmbedExtension, type EngineConfig, type EngineEvents, type Extension, ExtensionError, type Extension as ExtensionInterface, type ExtensionRegistration, HeadingExtension, HorizontalRuleExtension, ImageExtension, InlineCodeExtension, ItalicExtension, type JsonAstNode, LineBreakExtension, LinkExtension, ListExtension, Logger, MarkdownParseError, MarkdownParser, MarkdownRenderError, MarkdownRenderer, type MarkdownToken, type OutputFormat, ParagraphExtension, type ParseRule, type ParserConfig, type PerformanceMetrics, PerformanceTimer, type RenderRule, type RendererConfig, TaskListExtension, TextExtension, type TokenComparison, type TokenDifference, type TokenStatistics, type TokenType, astToJSONString, astToTokens, basicSanitize, compareTokens, createCoreOnlyEngine, createCumEngine, createCustomEngine, createDebugEngine, createEngine, createEngineWithPreset, createHTMLEngine, createMinimalEngine, createTailwindEngine, debounce, deepMerge, markdown as default, defaultTailwindClasses, escapeHtml, extractDomain, generateId, getASTStats, getTokenStats, isBrowser, isNode, isValidUrl, markdown, minimalClasses, parseASTFromJSON, parseCum, parseMarkdown, parseOptions, parseTokensFromJSON, presets, proseClasses, renderCum, renderCumToHtml, renderCumToJson, renderCumToTailwind, renderMarkdown, renderToAST, renderToHTML, renderToHTMLUnsafe, renderToHTMLWithConfig, renderToJSON, renderToTailwind, renderToTailwindWithClasses, renderToTailwindWithConfig, sanitizeHtml, tokensToAST, tokensToJSONString };