@yozora/tokenizer-admonition 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-admonition",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Tokenizer for processing admonitions",
5
5
  "author": {
6
6
  "name": "guanghechen",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "files": [
36
36
  "lib/",
37
- "src/",
37
+ "lib/**/*.map",
38
38
  "package.json",
39
39
  "CHANGELOG.md",
40
40
  "LICENSE",
@@ -46,10 +46,10 @@
46
46
  "test": "cross-env TS_NODE_FILES=true NODE_OPTIONS=--experimental-vm-modules jest --config ../../jest.config.mjs --rootDir ."
47
47
  },
48
48
  "dependencies": {
49
- "@yozora/ast": "^2.1.3",
50
- "@yozora/character": "^2.1.3",
51
- "@yozora/core-tokenizer": "^2.1.3",
52
- "@yozora/tokenizer-fenced-block": "^2.1.3"
49
+ "@yozora/ast": "^2.1.4",
50
+ "@yozora/character": "^2.1.4",
51
+ "@yozora/core-tokenizer": "^2.1.4",
52
+ "@yozora/tokenizer-fenced-block": "^2.1.4"
53
53
  },
54
- "gitHead": "9abaaff74a12d0bae0f645813241ff947a0d828c"
54
+ "gitHead": "aa464ed1e3cd84892773a833910cfc53a556bf5f"
55
55
  }
package/src/index.ts DELETED
@@ -1,9 +0,0 @@
1
- export { match as admonitionMatch } from './match'
2
- export { parse as admonitionParse } from './parse'
3
- export { AdmonitionTokenizer, AdmonitionTokenizer as default } from './tokenizer'
4
- export { uniqueName as AdmonitionTokenizerName } from './types'
5
- export type {
6
- IThis as IAdmonitionHookContext,
7
- IToken as IAdmonitionToken,
8
- ITokenizerProps as IAdmonitionTokenizerProps,
9
- } from './types'
package/src/match.ts DELETED
@@ -1,26 +0,0 @@
1
- import type { IMatchBlockHook, IMatchBlockHookCreator } from '@yozora/core-tokenizer'
2
- import { fencedBlockMatch } from '@yozora/tokenizer-fenced-block'
3
- import type { IThis, IToken, T } from './types'
4
-
5
- /**
6
- * A code fence is a sequence of at least three consecutive backtick characters
7
- * (`) or tildes (~). (Tildes and backticks cannot be mixed.) A fenced code
8
- * block begins with a code fence, indented no more than three spaces.
9
- *
10
- * @see https://github.com/syntax-tree/mdast#code
11
- * @see https://github.github.com/gfm/#code-fence
12
- */
13
- export const match: IMatchBlockHookCreator<T, IToken, IThis> = function (api) {
14
- const hook = fencedBlockMatch.call(this, api) as IMatchBlockHook<T, IToken>
15
- return {
16
- ...hook,
17
- isContainingBlock: true,
18
- onClose,
19
- }
20
-
21
- function onClose(token: IToken): void {
22
- const children = api.rollbackPhrasingLines(token.lines)
23
- // eslint-disable-next-line no-param-reassign
24
- token.children = children
25
- }
26
- }
package/src/parse.ts DELETED
@@ -1,54 +0,0 @@
1
- import type { Node } from '@yozora/ast'
2
- import { AdmonitionType } from '@yozora/ast'
3
- import type { INodePoint } from '@yozora/character'
4
- import { calcEscapedStringFromNodePoints, isUnicodeWhitespaceCharacter } from '@yozora/character'
5
- import type { IParseBlockHookCreator, IPhrasingContentLine } from '@yozora/core-tokenizer'
6
- import { eatOptionalWhitespaces, mergeAndStripContentLines } from '@yozora/core-tokenizer'
7
- import type { INode, IThis, IToken, T } from './types'
8
-
9
- export const parse: IParseBlockHookCreator<T, IToken, INode, IThis> = function (api) {
10
- return {
11
- parse: tokens =>
12
- tokens.map(token => {
13
- const infoString = token.infoString
14
-
15
- // Match an admonition keyword.
16
- let i = 0
17
- const keywordNodePoints: INodePoint[] = []
18
- for (; i < infoString.length; ++i) {
19
- const p = infoString[i]
20
- if (isUnicodeWhitespaceCharacter(p.codePoint)) break
21
- keywordNodePoints.push(p)
22
- }
23
-
24
- i = eatOptionalWhitespaces(infoString, i, infoString.length)
25
- const title: Node[] = ((): Node[] => {
26
- if (i >= infoString.length) return []
27
- const titleLines: IPhrasingContentLine[] = [
28
- {
29
- nodePoints: infoString,
30
- startIndex: i,
31
- endIndex: infoString.length,
32
- firstNonWhitespaceIndex: i,
33
- countOfPrecedeSpaces: 0,
34
- },
35
- ]
36
- const contents: INodePoint[] = mergeAndStripContentLines(titleLines)
37
- return api.processInlines(contents)
38
- })()
39
-
40
- const keyword: string = calcEscapedStringFromNodePoints(
41
- keywordNodePoints,
42
- 0,
43
- keywordNodePoints.length,
44
- true,
45
- )
46
- const children: Node[] = api.parseBlockTokens(token.children)
47
-
48
- const node: INode = api.shouldReservePosition
49
- ? { type: AdmonitionType, position: token.position, keyword, title, children }
50
- : { type: AdmonitionType, keyword, title, children }
51
- return node
52
- }),
53
- }
54
- }
package/src/tokenizer.ts DELETED
@@ -1,38 +0,0 @@
1
- import { AdmonitionType } from '@yozora/ast'
2
- import { AsciiCodePoint } from '@yozora/character'
3
- import type {
4
- IBlockTokenizer,
5
- IMatchBlockHookCreator,
6
- IParseBlockHookCreator,
7
- } from '@yozora/core-tokenizer'
8
- import { TokenizerPriority } from '@yozora/core-tokenizer'
9
- import FencedBlockTokenizer from '@yozora/tokenizer-fenced-block'
10
- import { match } from './match'
11
- import { parse } from './parse'
12
- import type { INode, IThis, IToken, ITokenizerProps, T } from './types'
13
- import { uniqueName } from './types'
14
-
15
- /**
16
- * Lexical Analyzer for Admonition.
17
- * @see https://github.com/syntax-tree/mdast#code
18
- * @see https://github.github.com/gfm/#code-fence
19
- */
20
- export class AdmonitionTokenizer
21
- extends FencedBlockTokenizer<T, INode, IThis>
22
- implements IBlockTokenizer<T, IToken, INode, IThis>
23
- {
24
- /* istanbul ignore next */
25
- constructor(props: ITokenizerProps = {}) {
26
- super({
27
- name: props.name ?? uniqueName,
28
- priority: props.priority ?? TokenizerPriority.FENCED_BLOCK,
29
- nodeType: AdmonitionType,
30
- markers: [AsciiCodePoint.COLON],
31
- markersRequired: 3,
32
- })
33
- }
34
-
35
- public override readonly match: IMatchBlockHookCreator<T, IToken, IThis> = match
36
-
37
- public override readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis> = parse
38
- }
package/src/types.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { Admonition, AdmonitionType } from '@yozora/ast'
2
- import type { IBaseBlockTokenizerProps, IBlockToken } from '@yozora/core-tokenizer'
3
- import type { IFencedBlockHookContext, IFencedBlockToken } from '@yozora/tokenizer-fenced-block'
4
-
5
- export type T = AdmonitionType
6
- export type INode = Admonition
7
- export const uniqueName = '@yozora/tokenizer-admonition'
8
-
9
- export interface IToken extends IFencedBlockToken<T> {
10
- /**
11
- *
12
- */
13
- children?: IBlockToken[]
14
- }
15
-
16
- export type IThis = IFencedBlockHookContext<T>
17
-
18
- export type ITokenizerProps = Partial<IBaseBlockTokenizerProps>