Skip to content

Commit 65d7c80

Browse files
njg7194njg7194
andauthored
docs: clarify extension terminology ambiguity (#3881)
docs: clarify 'extension' terminology ambiguity Add a terminology note section to explain the difference between: - MarkedExtension: the configuration object passed to marked.use() - TokenizerAndRendererExtension: custom syntax definitions in the extensions array This addresses the confusion described in #3182 where 'extensions' is used with two different meanings throughout the documentation. Fixes #3182 Co-authored-by: njg7194 <njg7194@github.com>
1 parent 6b58506 commit 65d7c80

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/USING_PRO.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
To champion the single-responsibility and open/closed principles, we have tried to make it relatively painless to extend Marked. If you are looking to add custom functionality, this is the place to start.
44

5+
<h2 id="terminology">Terminology Note</h2>
6+
7+
Before diving in, it's important to understand the terminology used in this documentation:
8+
9+
| Term | TypeScript Type | Description |
10+
|------|----------------|-------------|
11+
| **Marked Extension** | `MarkedExtension` | The configuration object passed to `marked.use()`. Can contain options, hooks, renderer overrides, tokenizer overrides, and custom extensions. |
12+
| **Custom Extension** | `TokenizerAndRendererExtension` | Objects within the `extensions` array that define custom tokenizers and renderers for new syntax. |
13+
14+
In other words, a **Marked Extension** is the top-level plugin configuration, while **Custom Extensions** are the individual tokenizer/renderer definitions for custom syntax within that configuration.
15+
16+
```js
17+
// Marked Extension (MarkedExtension)
18+
marked.use({
19+
gfm: true,
20+
breaks: false,
21+
renderer: { /* renderer overrides */ },
22+
tokenizer: { /* tokenizer overrides */ },
23+
// Custom Extensions (TokenizerAndRendererExtension[])
24+
extensions: [
25+
{ name: 'myCustomSyntax', level: 'block', tokenizer: fn, renderer: fn }
26+
]
27+
});
28+
```
29+
530
<h2 id="use">marked.use()</h2>
631

732
`marked.use(extension)` is the recommended way to extend Marked. The `extension` object can contain any [option](/using_advanced#options) available in Marked:

0 commit comments

Comments
 (0)