@yozora/tokenizer-fenced-code 2.0.0-alpha.0 → 2.0.0-alpha.1

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/README.md CHANGED
@@ -84,14 +84,14 @@ so you can use `YozoraParser` / `GfmExParser` / `GfmParser` directly.
84
84
  registered in *YastParser* as a plugin-in before it can be used.
85
85
 
86
86
  ```typescript {4,9}
87
- import { DefaultYastParser } from '@yozora/core-parser'
87
+ import { DefaultParser } from '@yozora/core-parser'
88
88
  import ParagraphTokenizer from '@yozora/tokenizer-paragraph'
89
89
  import TextTokenizer from '@yozora/tokenizer-text'
90
90
  import FencedCodeTokenizer from '@yozora/tokenizer-fenced-code'
91
91
 
92
- const parser = new DefaultYastParser()
93
- .useBlockFallbackTokenizer(new ParagraphTokenizer())
94
- .useInlineFallbackTokenizer(new TextTokenizer())
92
+ const parser = new DefaultParser()
93
+ .useFallbackTokenizer(new ParagraphTokenizer())
94
+ .useFallbackTokenizer(new TextTokenizer())
95
95
  .useTokenizer(new FencedCodeTokenizer())
96
96
 
97
97
  // parse source markdown content
@@ -256,7 +256,6 @@ Name | Type | Required | Default
256
256
  [@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
257
257
  [@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
258
258
  [@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
259
- [@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
260
259
  [@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
261
260
  [@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
262
261
  [@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
@@ -316,7 +315,6 @@ Name | Type | Required | Default
316
315
  [doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
317
316
  [doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
318
317
  [doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
319
- [doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
320
318
  [doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
321
319
  [doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
322
320
  [doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
package/lib/cjs/index.js CHANGED
@@ -12,13 +12,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
12
12
  var FencedBlockTokenizer__default = /*#__PURE__*/_interopDefaultLegacy(FencedBlockTokenizer);
13
13
 
14
14
  const match = function (api) {
15
- const hook = FencedBlockTokenizer.fencedMatch.call(this, api);
15
+ const hook = FencedBlockTokenizer.fencedBlockMatch.call(this, api);
16
16
  return Object.assign(Object.assign({}, hook), { isContainingBlock: false });
17
17
  };
18
18
 
19
19
  const parse = function () {
20
20
  return {
21
- parse: token => {
21
+ parse: tokens => tokens.map(token => {
22
22
  const infoString = token.infoString;
23
23
  let i = 0;
24
24
  const lang = [];
@@ -32,12 +32,13 @@ const parse = function () {
32
32
  const contents = coreTokenizer.mergeContentLinesFaithfully(token.lines);
33
33
  const node = {
34
34
  type: ast.CodeType,
35
+ position: token.position,
35
36
  lang: character.calcEscapedStringFromNodePoints(lang, 0, lang.length, true),
36
37
  meta: character.calcEscapedStringFromNodePoints(infoString, i, infoString.length, true),
37
38
  value: character.calcStringFromNodePoints(contents),
38
39
  };
39
40
  return node;
40
- },
41
+ }),
41
42
  };
42
43
  };
43
44
 
package/lib/esm/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import FencedBlockTokenizer, { fencedMatch } from '@yozora/tokenizer-fenced-block';
1
+ import FencedBlockTokenizer, { fencedBlockMatch } from '@yozora/tokenizer-fenced-block';
2
2
  import { CodeType } from '@yozora/ast';
3
3
  import { isUnicodeWhitespaceCharacter, calcEscapedStringFromNodePoints, calcStringFromNodePoints, AsciiCodePoint } from '@yozora/character';
4
4
  import { eatOptionalWhitespaces, mergeContentLinesFaithfully, TokenizerPriority } from '@yozora/core-tokenizer';
5
5
 
6
6
  const match = function (api) {
7
- const hook = fencedMatch.call(this, api);
7
+ const hook = fencedBlockMatch.call(this, api);
8
8
  return Object.assign(Object.assign({}, hook), { isContainingBlock: false });
9
9
  };
10
10
 
11
11
  const parse = function () {
12
12
  return {
13
- parse: token => {
13
+ parse: tokens => tokens.map(token => {
14
14
  const infoString = token.infoString;
15
15
  let i = 0;
16
16
  const lang = [];
@@ -24,12 +24,13 @@ const parse = function () {
24
24
  const contents = mergeContentLinesFaithfully(token.lines);
25
25
  const node = {
26
26
  type: CodeType,
27
+ position: token.position,
27
28
  lang: calcEscapedStringFromNodePoints(lang, 0, lang.length, true),
28
29
  meta: calcEscapedStringFromNodePoints(infoString, i, infoString.length, true),
29
30
  value: calcStringFromNodePoints(contents),
30
31
  };
31
32
  return node;
32
- },
33
+ }),
33
34
  };
34
35
  };
35
36
 
@@ -2,4 +2,4 @@ export { match as fencedCodeMatch } from './match';
2
2
  export { parse as fencedCodeParse } from './parse';
3
3
  export { FencedCodeTokenizer, FencedCodeTokenizer as default } from './tokenizer';
4
4
  export { uniqueName as FencedCodeTokenizerName } from './types';
5
- export type { IHookContext as IFencedCodeHookContext, IToken as IFencedCodeToken, ITokenizerProps as IFencedCodeTokenizerProps, } from './types';
5
+ export type { IThis as IFencedCodeHookContext, IToken as IFencedCodeToken, ITokenizerProps as IFencedCodeTokenizerProps, } from './types';
@@ -1,5 +1,5 @@
1
1
  import type { IMatchBlockHookCreator } from '@yozora/core-tokenizer';
2
- import type { IHookContext, IToken, T } from './types';
2
+ import type { IThis, IToken, T } from './types';
3
3
  /**
4
4
  * A code fence is a sequence of at least three consecutive backtick characters
5
5
  * (`) or tildes (~). (Tildes and backticks cannot be mixed.) A fenced code
@@ -8,4 +8,4 @@ import type { IHookContext, IToken, T } from './types';
8
8
  * @see https://github.com/syntax-tree/mdast#code
9
9
  * @see https://github.github.com/gfm/#code-fence
10
10
  */
11
- export declare const match: IMatchBlockHookCreator<T, IToken, IHookContext>;
11
+ export declare const match: IMatchBlockHookCreator<T, IToken, IThis>;
@@ -1,3 +1,3 @@
1
1
  import type { IParseBlockHookCreator } from '@yozora/core-tokenizer';
2
- import type { IHookContext, INode, IToken, T } from './types';
3
- export declare const parse: IParseBlockHookCreator<T, IToken, INode, IHookContext>;
2
+ import type { INode, IThis, IToken, T } from './types';
3
+ export declare const parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
@@ -1,13 +1,13 @@
1
1
  import type { IBlockTokenizer, IMatchBlockHookCreator, IParseBlockHookCreator } from '@yozora/core-tokenizer';
2
2
  import FencedBlockTokenizer from '@yozora/tokenizer-fenced-block';
3
- import type { IHookContext, INode, IToken, ITokenizerProps, T } from './types';
3
+ import type { INode, IThis, IToken, ITokenizerProps, T } from './types';
4
4
  /**
5
5
  * Lexical Analyzer for FencedCode.
6
6
  * @see https://github.com/syntax-tree/mdast#code
7
7
  * @see https://github.github.com/gfm/#code-fence
8
8
  */
9
- export declare class FencedCodeTokenizer extends FencedBlockTokenizer<T, INode, IHookContext> implements IBlockTokenizer<T, IToken, INode, IHookContext> {
9
+ export declare class FencedCodeTokenizer extends FencedBlockTokenizer<T, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
10
10
  constructor(props?: ITokenizerProps);
11
- readonly match: IMatchBlockHookCreator<T, IToken, IHookContext>;
12
- readonly parse: IParseBlockHookCreator<T, IToken, INode, IHookContext>;
11
+ readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
12
+ readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
13
13
  }
@@ -5,5 +5,5 @@ export declare type T = CodeType;
5
5
  export declare type INode = ICode;
6
6
  export declare const uniqueName = "@yozora/tokenizer-fenced-code";
7
7
  export declare type IToken = IFencedBlockToken<T>;
8
- export declare type IHookContext = IFencedBlockHookContext<T>;
8
+ export declare type IThis = IFencedBlockHookContext<T>;
9
9
  export declare type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-fenced-code",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -35,10 +35,10 @@
35
35
  "test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
36
36
  },
37
37
  "dependencies": {
38
- "@yozora/ast": "^2.0.0-alpha.0",
39
- "@yozora/character": "^2.0.0-alpha.0",
40
- "@yozora/core-tokenizer": "^2.0.0-alpha.0",
41
- "@yozora/tokenizer-fenced-block": "^2.0.0-alpha.0"
38
+ "@yozora/ast": "^2.0.0-alpha.1",
39
+ "@yozora/character": "^2.0.0-alpha.1",
40
+ "@yozora/core-tokenizer": "^2.0.0-alpha.1",
41
+ "@yozora/tokenizer-fenced-block": "^2.0.0-alpha.1"
42
42
  },
43
- "gitHead": "0171501339c49ffd02ed16a63447fa20a47a29a7"
43
+ "gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
44
44
  }