Skip to content

Commit df0d6a6

Browse files
committed
Refactor types
1 parent 27270d3 commit df0d6a6

File tree

6 files changed

+945
-725
lines changed

6 files changed

+945
-725
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
coverage/
77
node_modules/
88
yarn.lock
9+
!/lib/types.d.ts
910
!/index.d.ts

index.d.ts

+4-311
Original file line numberDiff line numberDiff line change
@@ -1,315 +1,6 @@
1-
import type {Info, State} from './lib/types.js'
2-
3-
/**
4-
* Interface of registered constructs.
5-
*
6-
* When working on extensions that use new constructs, extend the corresponding
7-
* interface to register its name:
8-
*
9-
* ```ts
10-
* declare module 'mdast-util-to-markdown' {
11-
* interface ConstructNameMap {
12-
* // Register a new construct name (value is used, key should match it).
13-
* gfmStrikethrough: 'gfmStrikethrough'
14-
* }
15-
* }
16-
* ```
17-
*/
18-
export interface ConstructNameMap {
19-
/**
20-
* Whole autolink.
21-
*
22-
* ```markdown
23-
* > | <https://example.com> and <admin@example.com>
24-
* ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
25-
* ```
26-
*/
27-
autolink: 'autolink'
28-
/**
29-
* Whole block quote.
30-
*
31-
* ```markdown
32-
* > | > a
33-
* ^^^
34-
* > | b
35-
* ^
36-
* ```
37-
*/
38-
blockquote: 'blockquote'
39-
/**
40-
* Whole code (indented).
41-
*
42-
* ```markdown
43-
* ␠␠␠␠console.log(1)
44-
* ^^^^^^^^^^^^^^^^^^
45-
* ```
46-
*/
47-
codeIndented: 'codeIndented'
48-
/**
49-
* Whole code (fenced).
50-
*
51-
* ````markdown
52-
* > | ```js
53-
* ^^^^^
54-
* > | console.log(1)
55-
* ^^^^^^^^^^^^^^
56-
* > | ```
57-
* ^^^
58-
* ````
59-
*/
60-
codeFenced: 'codeFenced'
61-
/**
62-
* Code (fenced) language, when fenced with grave accents.
63-
*
64-
* ````markdown
65-
* > | ```js
66-
* ^^
67-
* | console.log(1)
68-
* | ```
69-
* ````
70-
*/
71-
codeFencedLangGraveAccent: 'codeFencedLangGraveAccent'
72-
/**
73-
* Code (fenced) language, when fenced with tildes.
74-
*
75-
* ````markdown
76-
* > | ~~~js
77-
* ^^
78-
* | console.log(1)
79-
* | ~~~
80-
* ````
81-
*/
82-
codeFencedLangTilde: 'codeFencedLangTilde'
83-
/**
84-
* Code (fenced) meta string, when fenced with grave accents.
85-
*
86-
* ````markdown
87-
* > | ```js eval
88-
* ^^^^
89-
* | console.log(1)
90-
* | ```
91-
* ````
92-
*/
93-
codeFencedMetaGraveAccent: 'codeFencedMetaGraveAccent'
94-
/**
95-
* Code (fenced) meta string, when fenced with tildes.
96-
*
97-
* ````markdown
98-
* > | ~~~js eval
99-
* ^^^^
100-
* | console.log(1)
101-
* | ~~~
102-
* ````
103-
*/
104-
codeFencedMetaTilde: 'codeFencedMetaTilde'
105-
/**
106-
* Whole definition.
107-
*
108-
* ```markdown
109-
* > | [a]: b "c"
110-
* ^^^^^^^^^^
111-
* ```
112-
*/
113-
definition: 'definition'
114-
/**
115-
* Destination (literal) (occurs in definition, image, link).
116-
*
117-
* ```markdown
118-
* > | [a]: <b> "c"
119-
* ^^^
120-
* > | a ![b](<c> "d") e
121-
* ^^^
122-
* ```
123-
*/
124-
destinationLiteral: 'destinationLiteral'
125-
/**
126-
* Destination (raw) (occurs in definition, image, link).
127-
*
128-
* ```markdown
129-
* > | [a]: b "c"
130-
* ^
131-
* > | a ![b](c "d") e
132-
* ^
133-
* ```
134-
*/
135-
destinationRaw: 'destinationRaw'
136-
/**
137-
* Emphasis.
138-
*
139-
* ```markdown
140-
* > | *a*
141-
* ^^^
142-
* ```
143-
*/
144-
emphasis: 'emphasis'
145-
/**
146-
* Whole heading (atx).
147-
*
148-
* ```markdown
149-
* > | # alpha
150-
* ^^^^^^^
151-
* ```
152-
*/
153-
headingAtx: 'headingAtx'
154-
/**
155-
* Whole heading (setext).
156-
*
157-
* ```markdown
158-
* > | alpha
159-
* ^^^^^
160-
* > | =====
161-
* ^^^^^
162-
* ```
163-
*/
164-
headingSetext: 'headingSetext'
165-
/**
166-
* Whole image.
167-
*
168-
* ```markdown
169-
* > | ![a](b)
170-
* ^^^^^^^
171-
* > | ![c]
172-
* ^^^^
173-
* ```
174-
*/
175-
image: 'image'
176-
/**
177-
* Whole image reference.
178-
*
179-
* ```markdown
180-
* > | ![a]
181-
* ^^^^
182-
* ```
183-
*/
184-
imageReference: 'imageReference'
185-
/**
186-
* Label (occurs in definitions, image reference, image, link reference,
187-
* link).
188-
*
189-
* ```markdown
190-
* > | [a]: b "c"
191-
* ^^^
192-
* > | a [b] c
193-
* ^^^
194-
* > | a ![b][c] d
195-
* ^^^^
196-
* > | a [b](c) d
197-
* ^^^
198-
* ```
199-
*/
200-
label: 'label'
201-
/**
202-
* Whole link.
203-
*
204-
* ```markdown
205-
* > | [a](b)
206-
* ^^^^^^
207-
* > | [c]
208-
* ^^^
209-
* ```
210-
*/
211-
link: 'link'
212-
/**
213-
* Whole link reference.
214-
*
215-
* ```markdown
216-
* > | [a]
217-
* ^^^
218-
* ```
219-
*/
220-
linkReference: 'linkReference'
221-
/**
222-
* List.
223-
*
224-
* ```markdown
225-
* > | * a
226-
* ^^^
227-
* > | 1. b
228-
* ^^^^
229-
* ```
230-
*/
231-
list: 'list'
232-
/**
233-
* List item.
234-
*
235-
* ```markdown
236-
* > | * a
237-
* ^^^
238-
* > | 1. b
239-
* ^^^^
240-
* ```
241-
*/
242-
listItem: 'listItem'
243-
/**
244-
* Paragraph.
245-
*
246-
* ```markdown
247-
* > | a b
248-
* ^^^
249-
* > | c.
250-
* ^^
251-
* ```
252-
*/
253-
paragraph: 'paragraph'
254-
/**
255-
* Phrasing (occurs in headings, paragraphs, etc).
256-
*
257-
* ```markdown
258-
* > | a
259-
* ^
260-
* ```
261-
*/
262-
phrasing: 'phrasing'
263-
/**
264-
* Reference (occurs in image, link).
265-
*
266-
* ```markdown
267-
* > | [a][]
268-
* ^^
269-
* ```
270-
*/
271-
reference: 'reference'
272-
/**
273-
* Strong.
274-
*
275-
* ```markdown
276-
* > | **a**
277-
* ^^^^^
278-
* ```
279-
*/
280-
strong: 'strong'
281-
/**
282-
* Title using single quotes (occurs in definition, image, link).
283-
*
284-
* ```markdown
285-
* > | [a](b 'c')
286-
* ^^^
287-
* ```
288-
*/
289-
titleApostrophe: 'titleApostrophe'
290-
/**
291-
* Title using double quotes (occurs in definition, image, link).
292-
*
293-
* ```markdown
294-
* > | [a](b "c")
295-
* ^^^
296-
* ```
297-
*/
298-
titleQuote: 'titleQuote'
299-
}
300-
301-
/**
302-
* Construct names for things generated by `mdast-util-to-markdown`.
303-
*
304-
* This is an enum of strings, each being a semantic label, useful to know when
305-
* serializing whether we’re for example in a double (`"`) or single (`'`)
306-
* quoted title.
307-
*/
308-
export type ConstructName = ConstructNameMap[keyof ConstructNameMap]
309-
310-
export {toMarkdown} from './lib/index.js'
311-
export {handle as defaultHandlers} from './lib/handle/index.js'
3121
export type {
2+
ConstructNameMap,
3+
ConstructName,
3134
Handle,
3145
Handlers,
3156
Info,
@@ -321,3 +12,5 @@ export type {
32112
Tracker,
32213
Unsafe
32314
} from './lib/types.js'
15+
export {toMarkdown} from './lib/index.js'
16+
export {handle as defaultHandlers} from './lib/handle/index.js'

0 commit comments

Comments
 (0)