@yozora/tokenizer-footnote-reference 2.1.3 → 2.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-footnote-reference",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "files": [
29
29
  "lib/",
30
- "src/",
30
+ "lib/**/*.map",
31
31
  "package.json",
32
32
  "CHANGELOG.md",
33
33
  "LICENSE",
@@ -39,10 +39,10 @@
39
39
  "test": "cross-env TS_NODE_FILES=true NODE_OPTIONS=--experimental-vm-modules jest --config ../../jest.config.mjs --rootDir ."
40
40
  },
41
41
  "dependencies": {
42
- "@yozora/ast": "^2.1.3",
43
- "@yozora/character": "^2.1.3",
44
- "@yozora/core-tokenizer": "^2.1.3",
45
- "@yozora/tokenizer-footnote-definition": "^2.1.3"
42
+ "@yozora/ast": "^2.1.4",
43
+ "@yozora/character": "^2.1.4",
44
+ "@yozora/core-tokenizer": "^2.1.4",
45
+ "@yozora/tokenizer-footnote-definition": "^2.1.4"
46
46
  },
47
- "gitHead": "9abaaff74a12d0bae0f645813241ff947a0d828c"
47
+ "gitHead": "aa464ed1e3cd84892773a833910cfc53a556bf5f"
48
48
  }
package/src/index.ts DELETED
@@ -1,9 +0,0 @@
1
- export { match as footnoteReferenceMatch } from './match'
2
- export { parse as footnoteReferenceParse } from './parse'
3
- export { FootnoteReferenceTokenizer, FootnoteReferenceTokenizer as default } from './tokenizer'
4
- export { uniqueName as FootnoteReferenceTokenizerName } from './types'
5
- export type {
6
- IThis as IFootnoteReferenceHookContext,
7
- IToken as IFootnoteReferenceToken,
8
- ITokenizerProps as IFootnoteReferenceTokenizerProps,
9
- } from './types'
package/src/match.ts DELETED
@@ -1,85 +0,0 @@
1
- import { FootnoteReferenceType } from '@yozora/ast'
2
- import type { INodePoint } from '@yozora/character'
3
- import { AsciiCodePoint } from '@yozora/character'
4
- import type {
5
- IMatchInlineHookCreator,
6
- IResultOfProcessSingleDelimiter,
7
- } from '@yozora/core-tokenizer'
8
- import { genFindDelimiter, resolveLinkLabelAndIdentifier } from '@yozora/core-tokenizer'
9
- import { eatFootnoteLabel } from '@yozora/tokenizer-footnote-definition'
10
- import type { IDelimiter, IThis, IToken, T } from './types'
11
-
12
- /**
13
- * A full footnote consists of a footnote label.
14
- *
15
- * Unlike the link label, the footnote label should be on the same line and it
16
- * begins with a left bracket ([) followed by a caret (^), and ends with the
17
- * first right bracket (]) that is not backslash-escaped. Between the caret of
18
- * right bracket, there must be at least one non-whitespace character.
19
- * Unescaped square bracket characters are not allowed inside the opening creat
20
- * and closing square bracket of footnote labels. A footnote label can have at
21
- * most 999 characters inside the caret and right bracket.
22
- *
23
- * @see https://github.com/syntax-tree/mdast#footnotereference
24
- * @see https://github.github.com/gfm/#link-label
25
- */
26
- export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = function (api) {
27
- return {
28
- findDelimiter: () => genFindDelimiter<IDelimiter>(_findDelimiter),
29
- processSingleDelimiter,
30
- }
31
-
32
- function _findDelimiter(startIndex: number, endIndex: number): IDelimiter | null {
33
- const nodePoints: ReadonlyArray<INodePoint> = api.getNodePoints()
34
-
35
- for (let i = startIndex; i < endIndex; ++i) {
36
- const p = nodePoints[i]
37
- switch (p.codePoint) {
38
- case AsciiCodePoint.BACKSLASH:
39
- i += 1
40
- break
41
- /**
42
- * A footnote text consists of a sequence of zero or more inline elements
43
- * enclosed by square brackets ([ and ])
44
- * @see https://github.github.com/gfm/#footnote-text
45
- */
46
- case AsciiCodePoint.OPEN_BRACKET: {
47
- const nextIndex = eatFootnoteLabel(nodePoints, i, endIndex)
48
- if (nextIndex >= 0) {
49
- return {
50
- type: 'full',
51
- startIndex: i,
52
- endIndex: nextIndex,
53
- }
54
- }
55
- break
56
- }
57
- }
58
- }
59
- return null
60
- }
61
-
62
- function processSingleDelimiter(
63
- delimiter: IDelimiter,
64
- ): IResultOfProcessSingleDelimiter<T, IToken> {
65
- const nodePoints: ReadonlyArray<INodePoint> = api.getNodePoints()
66
- const labelAndIdentifier = resolveLinkLabelAndIdentifier(
67
- nodePoints,
68
- delimiter.startIndex + 2,
69
- delimiter.endIndex - 1,
70
- )
71
- if (labelAndIdentifier == null) return []
72
-
73
- const { label, identifier } = labelAndIdentifier
74
- if (!api.hasFootnoteDefinition(identifier)) return []
75
-
76
- const token: IToken = {
77
- nodeType: FootnoteReferenceType,
78
- startIndex: delimiter.startIndex,
79
- endIndex: delimiter.endIndex,
80
- label,
81
- identifier,
82
- }
83
- return [token]
84
- }
85
- }
package/src/parse.ts DELETED
@@ -1,16 +0,0 @@
1
- import { FootnoteReferenceType } from '@yozora/ast'
2
- import type { IParseInlineHookCreator } from '@yozora/core-tokenizer'
3
- import type { INode, IThis, IToken, T } from './types'
4
-
5
- export const parse: IParseInlineHookCreator<T, IToken, INode, IThis> = function (api) {
6
- return {
7
- parse: tokens =>
8
- tokens.map(token => {
9
- const { identifier, label } = token
10
- const node: INode = api.shouldReservePosition
11
- ? { type: FootnoteReferenceType, position: api.calcPosition(token), identifier, label }
12
- : { type: FootnoteReferenceType, identifier, label }
13
- return node
14
- }),
15
- }
16
- }
package/src/tokenizer.ts DELETED
@@ -1,32 +0,0 @@
1
- import type {
2
- IInlineTokenizer,
3
- IMatchInlineHookCreator,
4
- IParseInlineHookCreator,
5
- } from '@yozora/core-tokenizer'
6
- import { BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer'
7
- import { match } from './match'
8
- import { parse } from './parse'
9
- import type { IDelimiter, INode, IThis, IToken, ITokenizerProps, T } from './types'
10
- import { uniqueName } from './types'
11
-
12
- /**
13
- * Lexical Analyzer for footnote reference.
14
- * @see https://github.com/syntax-tree/mdast#footnotereference
15
- * @see https://github.github.com/gfm/#link-label
16
- */
17
- export class FootnoteReferenceTokenizer
18
- extends BaseInlineTokenizer<T, IDelimiter, IToken, INode, IThis>
19
- implements IInlineTokenizer<T, IDelimiter, IToken, INode, IThis>
20
- {
21
- /* istanbul ignore next */
22
- constructor(props: ITokenizerProps = {}) {
23
- super({
24
- name: props.name ?? uniqueName,
25
- priority: props.priority ?? TokenizerPriority.ATOMIC,
26
- })
27
- }
28
-
29
- public override readonly match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = match
30
-
31
- public override readonly parse: IParseInlineHookCreator<T, IToken, INode, IThis> = parse
32
- }
package/src/types.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { Association, FootnoteReference, FootnoteReferenceType } from '@yozora/ast'
2
- import type {
3
- IBaseInlineTokenizerProps,
4
- IPartialInlineToken,
5
- ITokenDelimiter,
6
- ITokenizer,
7
- } from '@yozora/core-tokenizer'
8
-
9
- export const uniqueName = '@yozora/tokenizer-footnote-reference'
10
-
11
- export type T = FootnoteReferenceType
12
- export type INode = FootnoteReference
13
-
14
- export interface IToken extends IPartialInlineToken<T>, Association {}
15
-
16
- export interface IDelimiter extends ITokenDelimiter {
17
- type: 'full'
18
- }
19
-
20
- export type IThis = ITokenizer
21
-
22
- export type ITokenizerProps = Partial<IBaseInlineTokenizerProps>