You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/5.api/1.parse.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -365,18 +365,18 @@ Both `parseMarkdown()` and `createMarkdownParser()` accept the same `ParserOptio
365
365
|`headingIds`|`boolean`|`true`| Auto-generate `id` attributes for `h1`–`h6` headings. Set `false` to disable |
366
366
|`registerDefaultPlugins`|`boolean`|`true`| Register the built-in default plugins (`frontmatter`, `html`, `alert`, `task-list`, `components`, `attributes`). Set `false` to disable. Also can be used to configure default plugins like `components` in conjunction with `plugins`|
367
367
|`plugins`|`ComarkPlugin[]`|`[]`| Array of plugins to apply |
368
-
|`perf`|`ComarkPerf`|`undefined`| Timing recorder for the parse pipeline — see [Timing the parse](#timing-the-parse)|
368
+
|`tracer`|`ComarkTracer`|`undefined`| Timing recorder for the parse pipeline — see [Timing the parse](#timing-the-parse)|
369
369
370
370
### Timing the parse
371
371
372
-
Pass a `perf` recorder to time each phase of the pipeline and every plugin hook, so you can see where parse time goes (e.g. a slow `post` highlight hook). The contract is a structural subset of [OpenTelemetry](https://opentelemetry.io/docs/languages/js/instrumentation/#creating-spans)`Tracer` — `startSpan` and `startActiveSpan` — so a real OTel tracer works as-is:
372
+
Pass a `tracer` to time each phase of the pipeline and every plugin hook, so you can see where parse time goes (e.g. a slow `post` highlight hook). The contract is a structural subset of [OpenTelemetry](https://opentelemetry.io/docs/languages/js/instrumentation/#creating-spans)`Tracer` — `startSpan` and `startActiveSpan` — so a real OTel tracer works as-is:
373
373
374
374
```ts
375
375
import { trace } from'@opentelemetry/api'
376
376
377
377
const parse =createMarkdownParser({
378
378
// Uses the OpenTelemetry provider registered by your app or hosting platform.
Recorded spans: a root `comark:parse` active span enclosing `comark:autoclose`, `comark:tokenize` (markdown parsing), `comark:nodes` (token → AST conversion and unwrapping), and `comark:pre:<name>` / `comark:post:<name>` for each plugin hook. Nested `startActiveSpan` calls form the parent → child hierarchy (OTel active context, or a stack in a simple recorder). There is no timing overhead when `perf` is omitted, and no Node-specific API is used — it works in the browser too.
421
+
Recorded spans: a root `comark:parse` active span enclosing `comark:autoclose`, `comark:tokenize` (markdown parsing), `comark:nodes` (token → AST conversion and unwrapping), and `comark:pre:<name>` / `comark:post:<name>` for each plugin hook. Nested `startActiveSpan` calls form the parent → child hierarchy (OTel active context, or a stack in a simple recorder). There is no timing overhead when `tracer` is omitted, and no Node-specific API is used — it works in the browser too.
0 commit comments