Skip to content

Commit

Permalink
Add export of defaultHandlers
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 4, 2023
1 parent 070ad5f commit 21a7d0a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export interface ConstructNameMap {
export type ConstructName = ConstructNameMap[keyof ConstructNameMap]

export {toMarkdown} from './lib/index.js'
export {handle as defaultHandlers} from './lib/handle/index.js'
export type {
Handle,
Handlers,
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {toMarkdown} from './lib/index.js'
export {handle as defaultHandlers} from './lib/handle/index.js'
3 changes: 3 additions & 0 deletions lib/handle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {strong} from './strong.js'
import {text} from './text.js'
import {thematicBreak} from './thematic-break.js'

/**
* Default (CommonMark) handlers.
*/
export const handle = {
blockquote,
break: hardBreak,
Expand Down
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* [Use](#use)
* [API](#api)
* [`toMarkdown(tree[, options])`](#tomarkdowntree-options)
* [`defaultHandlers`](#defaulthandlers)
* [`ConstructName`](#constructname)
* [`ConstructNameMap`](#constructnamemap)
* [`Handle`](#handle)
Expand Down Expand Up @@ -132,7 +133,7 @@ console.log(toMarkdown(tree))
## API

This package exports the identifier `toMarkdown`.
This package exports the identifiers `toMarkdown` and `defaultHandlers`.
There is no default export.

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

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

### `defaultHandlers`

Default (CommonMark) handlers ([`Handlers`][handlers]).

### `ConstructName`

Construct names for things generated by `mdast-util-to-markdown` (TypeScript
Expand All @@ -167,7 +172,7 @@ type ConstructName = ConstructNameMap[keyof ConstructNameMap]
### `ConstructNameMap`
Interface of registered constructs.
Interface of registered constructs (TypeScript type).
###### Type
Expand Down
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ import test from 'node:test'
import {removePosition} from 'unist-util-remove-position'
import {fromMarkdown as from} from 'mdast-util-from-markdown'
import {toMarkdown as to} from '../index.js'
import * as api from '../index.js'

test('core', () => {
const identifiers = Object.keys(api)
assert.ok(identifiers.includes('toMarkdown'), 'should expose `toMarkdown`')
assert.ok(
identifiers.includes('defaultHandlers'),
'should expose `defaultHandlers`'
)

assert.equal(
to({
type: 'root',
Expand Down

0 comments on commit 21a7d0a

Please sign in to comment.