@yozora/tokenizer-list 2.1.3 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tokenizer.ts DELETED
@@ -1,45 +0,0 @@
1
- import type { NodeType } from '@yozora/ast'
2
- import { ParagraphType } from '@yozora/ast'
3
- import type {
4
- IBlockTokenizer,
5
- IMatchBlockHookCreator,
6
- IParseBlockHookCreator,
7
- } from '@yozora/core-tokenizer'
8
- import { BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer'
9
- import { match } from './match'
10
- import { parse } from './parse'
11
- import type { INode, IThis, IToken, ITokenizerProps, T } from './types'
12
- import { uniqueName } from './types'
13
-
14
- /**
15
- * Lexical Analyzer for List.
16
- *
17
- * A list is a sequence of one or more list items of the same type.
18
- * The list items may be separated by any number of blank lines.
19
- *
20
- * @see https://github.com/syntax-tree/mdast#list
21
- * @see https://github.github.com/gfm/#list
22
- */
23
- export class ListTokenizer
24
- extends BaseBlockTokenizer<T, IToken, INode, IThis>
25
- implements IBlockTokenizer<T, IToken, INode, IThis>
26
- {
27
- /* istanbul ignore next */
28
- constructor(props: ITokenizerProps = {}) {
29
- super({
30
- name: props.name ?? uniqueName,
31
- priority: props.priority ?? TokenizerPriority.CONTAINING_BLOCK,
32
- })
33
- this.enableTaskListItem = props.enableTaskListItem ?? false
34
- this.emptyItemCouldNotInterruptedTypes = props.emptyItemCouldNotInterruptedTypes ?? [
35
- ParagraphType,
36
- ]
37
- }
38
-
39
- public readonly enableTaskListItem: boolean
40
- public readonly emptyItemCouldNotInterruptedTypes: ReadonlyArray<NodeType>
41
-
42
- public override readonly match: IMatchBlockHookCreator<T, IToken, IThis> = match
43
-
44
- public override readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis> = parse
45
- }
package/src/types.ts DELETED
@@ -1,76 +0,0 @@
1
- import type { List, ListType, NodeType, TaskStatus } from '@yozora/ast'
2
- import type {
3
- IBaseBlockTokenizerProps,
4
- IBlockToken,
5
- IPartialBlockToken,
6
- ITokenizer,
7
- } from '@yozora/core-tokenizer'
8
-
9
- export type T = ListType
10
- export type INode = List
11
- export const uniqueName = '@yozora/tokenizer-list'
12
-
13
- export interface IToken extends IPartialBlockToken<T> {
14
- /**
15
- * Is it an ordered list item.
16
- */
17
- ordered: boolean
18
- /**
19
- * Marker of bullet list-item, or a delimiter of ordered list-item.
20
- */
21
- marker: number
22
- /**
23
- * Marker type of the list.
24
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol#attr-type
25
- */
26
- orderType?: '1' | 'a' | 'A' | 'i' | 'I'
27
- /**
28
- * Serial number of ordered list-item.
29
- */
30
- order?: number
31
- /**
32
- * Status of a todo task.
33
- */
34
- status?: TaskStatus
35
- /**
36
- * Indent of a list item.
37
- */
38
- indent: number
39
- /**
40
- * list-item 起始的空行数量
41
- * The number of blank lines at the beginning of a list-item
42
- */
43
- countOfTopBlankLine: number
44
- /**
45
- * Child token nodes.
46
- */
47
- children: IBlockToken[]
48
- }
49
-
50
- export interface IThis extends ITokenizer {
51
- /**
52
- * Specify an array of Node types that could not be interrupted
53
- * by this ITokenizer if the current list-item is empty.
54
- * @see https://github.github.com/gfm/#example-263
55
- */
56
- readonly emptyItemCouldNotInterruptedTypes: ReadonlyArray<NodeType>
57
-
58
- /**
59
- * Should enable task list item (extension).
60
- */
61
- readonly enableTaskListItem: boolean
62
- }
63
-
64
- export interface ITokenizerProps extends Partial<IBaseBlockTokenizerProps> {
65
- /**
66
- * Specify an array of Node types that could not be interrupted
67
- * by this ITokenizer if the current list-item is empty.
68
- * @see https://github.github.com/gfm/#example-263
69
- */
70
- readonly emptyItemCouldNotInterruptedTypes?: NodeType[]
71
-
72
- /**
73
- * Should enable task list item (extension).
74
- */
75
- readonly enableTaskListItem?: boolean
76
- }