Skip to content

Commit 21a7d0a

Browse files
committedJan 4, 2023
Add export of defaultHandlers
1 parent 070ad5f commit 21a7d0a

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed
 

‎index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ export interface ConstructNameMap {
309309
export type ConstructName = ConstructNameMap[keyof ConstructNameMap]
310310

311311
export {toMarkdown} from './lib/index.js'
312+
export {handle as defaultHandlers} from './lib/handle/index.js'
312313
export type {
313314
Handle,
314315
Handlers,

‎index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export {toMarkdown} from './lib/index.js'
2+
export {handle as defaultHandlers} from './lib/handle/index.js'

‎lib/handle/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import {strong} from './strong.js'
1818
import {text} from './text.js'
1919
import {thematicBreak} from './thematic-break.js'
2020

21+
/**
22+
* Default (CommonMark) handlers.
23+
*/
2124
export const handle = {
2225
blockquote,
2326
break: hardBreak,

‎readme.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [Use](#use)
1919
* [API](#api)
2020
* [`toMarkdown(tree[, options])`](#tomarkdowntree-options)
21+
* [`defaultHandlers`](#defaulthandlers)
2122
* [`ConstructName`](#constructname)
2223
* [`ConstructNameMap`](#constructnamemap)
2324
* [`Handle`](#handle)
@@ -132,7 +133,7 @@ console.log(toMarkdown(tree))
132133
133134
## API
134135

135-
This package exports the identifier `toMarkdown`.
136+
This package exports the identifiers `toMarkdown` and `defaultHandlers`.
136137
There is no default export.
137138

138139
### `toMarkdown(tree[, options])`
@@ -150,6 +151,10 @@ Turn an **[mdast][]** syntax tree into markdown.
150151

151152
Serialized markdown representing `tree` (`string`).
152153

154+
### `defaultHandlers`
155+
156+
Default (CommonMark) handlers ([`Handlers`][handlers]).
157+
153158
### `ConstructName`
154159

155160
Construct names for things generated by `mdast-util-to-markdown` (TypeScript
@@ -167,7 +172,7 @@ type ConstructName = ConstructNameMap[keyof ConstructNameMap]
167172
168173
### `ConstructNameMap`
169174
170-
Interface of registered constructs.
175+
Interface of registered constructs (TypeScript type).
171176
172177
###### Type
173178

‎test/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ import test from 'node:test'
99
import {removePosition} from 'unist-util-remove-position'
1010
import {fromMarkdown as from} from 'mdast-util-from-markdown'
1111
import {toMarkdown as to} from '../index.js'
12+
import * as api from '../index.js'
1213

1314
test('core', () => {
15+
const identifiers = Object.keys(api)
16+
assert.ok(identifiers.includes('toMarkdown'), 'should expose `toMarkdown`')
17+
assert.ok(
18+
identifiers.includes('defaultHandlers'),
19+
'should expose `defaultHandlers`'
20+
)
21+
1422
assert.equal(
1523
to({
1624
type: 'root',

0 commit comments

Comments
 (0)
Please sign in to comment.