@alexlit/lint-kit 107.3.0 → 108.0.0
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/.eslintrc.cjs +7 -1
- package/.linthtmlrc.cjs +3 -1
- package/{.commitlintrc.cjs → commitlint.config.js} +1 -1
- package/package.json +5 -5
- package/packages/config-commitlint/LICENSE +20 -0
- package/packages/config-commitlint/README.md +5 -9
- package/packages/config-commitlint/index.js +1 -1
- package/packages/config-commitlint/package.json +4 -3
- package/packages/config-eslint/LICENSE +20 -0
- package/packages/config-eslint/index.js +12 -2
- package/packages/config-eslint/package.json +25 -25
- package/packages/config-eslint/plugins/typescript/index.js +1 -1
- package/packages/config-eslint/plugins/unicorn.js +2 -0
- package/packages/config-eslint/plugins/vue.js +34 -2
- package/packages/config-hooks/LICENSE +20 -0
- package/packages/config-hooks/README.md +18 -12
- package/packages/config-hooks/index.js +2 -0
- package/packages/config-hooks/lint-staged.js +1 -1
- package/packages/config-hooks/package.json +6 -5
- package/packages/config-htmllint/LICENSE +20 -0
- package/packages/config-markdownlint/LICENSE +20 -0
- package/packages/config-markdownlint/package.json +3 -3
- package/packages/config-npmlint/LICENSE +20 -0
- package/packages/config-npmlint/package.json +2 -2
- package/packages/config-prettier/LICENSE +20 -0
- package/packages/config-prettier/README.md +8 -3
- package/packages/config-prettier/index.js +14 -10
- package/packages/config-prettier/package.json +16 -12
- package/packages/config-prettier/plugins/jsdoc.js +1 -1
- package/packages/config-prettier/plugins/pug.js +1 -1
- package/packages/config-prettier/plugins/sort-json.js +1 -1
- package/packages/config-prettier/plugins/svelte.js +1 -1
- package/packages/config-prettier/plugins/tailwindcss.js +1 -1
- package/packages/config-prettier/plugins/xml.js +1 -1
- package/packages/config-stylelint/LICENSE +20 -0
- package/packages/config-stylelint/README.md +5 -4
- package/packages/config-stylelint/index.js +22 -25
- package/packages/config-stylelint/package.json +22 -18
- package/packages/config-stylelint/plugins/a11y.js +1 -1
- package/packages/config-stylelint/plugins/at-rule-no-children.js +1 -1
- package/packages/config-stylelint/plugins/color-format.js +1 -1
- package/packages/config-stylelint/plugins/declaration-block-no-ignored-properties.js +1 -1
- package/packages/config-stylelint/plugins/high-performance-animation.js +1 -1
- package/packages/config-stylelint/plugins/no-nested-media.js +1 -1
- package/packages/config-stylelint/plugins/no-unresolved-module.js +1 -1
- package/packages/config-stylelint/plugins/no-unsupported-browser-features.js +1 -1
- package/packages/config-stylelint/plugins/optional/gamut.js +1 -1
- package/packages/config-stylelint/plugins/optional/logical-css.js +1 -1
- package/packages/config-stylelint/plugins/optional/no-indistinguishable-colors.js +1 -1
- package/packages/config-stylelint/plugins/order.js +1 -1
- package/packages/config-stylelint/plugins/prettier.js +1 -1
- package/packages/config-stylelint/plugins/scss.js +1 -1
- package/packages/config-stylelint/plugins/selector-no-empty.js +1 -1
- package/packages/config-stylelint/plugins/use-nesting.js +1 -1
- package/packages/config-stylelint/plugins/vue.js +1 -1
- package/prettier.config.js +5 -0
- package/stylelint.config.js +14 -0
- package/.huskyrc.cjs +0 -3
- package/.lintstagedrc.cjs +0 -3
- package/.prettierrc.cjs +0 -3
- package/.stylelintrc.cjs +0 -4
- package/packages/config-hooks/husky.js +0 -6
- package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +0 -22
- package/packages/config-markdownlint/node_modules/markdown-it/README.md +0 -309
- package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +0 -117
- package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +0 -8441
- package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
- package/packages/config-markdownlint/node_modules/markdown-it/index.js +0 -4
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +0 -6
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +0 -70
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +0 -28
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +0 -317
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +0 -7
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +0 -80
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +0 -48
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +0 -55
- package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +0 -582
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +0 -131
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +0 -61
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +0 -192
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +0 -81
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +0 -41
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +0 -63
- package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +0 -341
- package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +0 -352
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +0 -226
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +0 -34
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +0 -98
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +0 -55
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +0 -45
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +0 -74
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +0 -83
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +0 -362
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +0 -51
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +0 -198
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +0 -231
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +0 -221
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +0 -16
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +0 -13
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +0 -142
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +0 -21
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +0 -105
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +0 -201
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +0 -20
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +0 -45
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +0 -76
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +0 -63
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +0 -130
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +0 -130
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +0 -55
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +0 -71
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +0 -41
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +0 -58
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +0 -152
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +0 -150
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +0 -62
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +0 -46
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +0 -158
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +0 -130
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +0 -89
- package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +0 -201
- package/packages/config-markdownlint/node_modules/markdown-it/package.json +0 -87
- package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -428
- package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -92
- package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1026
- package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +0 -6814
- package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -376
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +0 -20
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +0 -2335
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +0 -59
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +0 -53
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +0 -51
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +0 -57
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +0 -54
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +0 -29
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +0 -31
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +0 -24
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +0 -98
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +0 -82
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +0 -55
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +0 -69
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +0 -35
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +0 -34
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +0 -41
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -61
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +0 -100
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -70
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +0 -1025
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +0 -426
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +0 -26
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +0 -10
- package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +0 -1152
- package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +0 -14
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +0 -406
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +0 -1476
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +0 -22
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +0 -76
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +0 -73
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +0 -86
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +0 -86
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +0 -60
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +0 -46
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +0 -96
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +0 -53
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +0 -34
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +0 -62
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +0 -62
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +0 -108
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +0 -61
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +0 -78
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +0 -79
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +0 -24
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +0 -91
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +0 -97
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +0 -64
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +0 -107
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +0 -60
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +0 -89
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +0 -172
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +0 -59
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +0 -125
- package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +0 -65
- package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -109
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -297
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -266
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -1762
- package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +0 -5
- package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +0 -22
- package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +0 -26
- package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +0 -12
- /package/packages/config-eslint/plugins/{security.js → optional/security.js} +0 -0
package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// Simple typographic replacements
|
|
2
|
-
//
|
|
3
|
-
// (c) (C) → ©
|
|
4
|
-
// (tm) (TM) → ™
|
|
5
|
-
// (r) (R) → ®
|
|
6
|
-
// +- → ±
|
|
7
|
-
// ... → … (also ?.... → ?.., !.... → !..)
|
|
8
|
-
// ???????? → ???, !!!!! → !!!, `,,` → `,`
|
|
9
|
-
// -- → –, --- → —
|
|
10
|
-
//
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
// TODO:
|
|
14
|
-
// - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
|
|
15
|
-
// - multiplications 2 x 4 -> 2 × 4
|
|
16
|
-
|
|
17
|
-
var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
|
|
18
|
-
|
|
19
|
-
// Workaround for phantomjs - need regex without /g flag,
|
|
20
|
-
// or root check will fail every second time
|
|
21
|
-
var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
|
|
22
|
-
|
|
23
|
-
var SCOPED_ABBR_RE = /\((c|tm|r)\)/ig;
|
|
24
|
-
var SCOPED_ABBR = {
|
|
25
|
-
c: '©',
|
|
26
|
-
r: '®',
|
|
27
|
-
tm: '™'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function replaceFn(match, name) {
|
|
31
|
-
return SCOPED_ABBR[name.toLowerCase()];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function replace_scoped(inlineTokens) {
|
|
35
|
-
var i, token, inside_autolink = 0;
|
|
36
|
-
|
|
37
|
-
for (i = inlineTokens.length - 1; i >= 0; i--) {
|
|
38
|
-
token = inlineTokens[i];
|
|
39
|
-
|
|
40
|
-
if (token.type === 'text' && !inside_autolink) {
|
|
41
|
-
token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (token.type === 'link_open' && token.info === 'auto') {
|
|
45
|
-
inside_autolink--;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (token.type === 'link_close' && token.info === 'auto') {
|
|
49
|
-
inside_autolink++;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function replace_rare(inlineTokens) {
|
|
55
|
-
var i, token, inside_autolink = 0;
|
|
56
|
-
|
|
57
|
-
for (i = inlineTokens.length - 1; i >= 0; i--) {
|
|
58
|
-
token = inlineTokens[i];
|
|
59
|
-
|
|
60
|
-
if (token.type === 'text' && !inside_autolink) {
|
|
61
|
-
if (RARE_RE.test(token.content)) {
|
|
62
|
-
token.content = token.content
|
|
63
|
-
.replace(/\+-/g, '±')
|
|
64
|
-
// .., ..., ....... -> …
|
|
65
|
-
// but ?..... & !..... -> ?.. & !..
|
|
66
|
-
.replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
|
|
67
|
-
.replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
|
|
68
|
-
// em-dash
|
|
69
|
-
.replace(/(^|[^-])---(?=[^-]|$)/mg, '$1\u2014')
|
|
70
|
-
// en-dash
|
|
71
|
-
.replace(/(^|\s)--(?=\s|$)/mg, '$1\u2013')
|
|
72
|
-
.replace(/(^|[^-\s])--(?=[^-\s]|$)/mg, '$1\u2013');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (token.type === 'link_open' && token.info === 'auto') {
|
|
77
|
-
inside_autolink--;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (token.type === 'link_close' && token.info === 'auto') {
|
|
81
|
-
inside_autolink++;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
module.exports = function replace(state) {
|
|
88
|
-
var blkIdx;
|
|
89
|
-
|
|
90
|
-
if (!state.md.options.typographer) { return; }
|
|
91
|
-
|
|
92
|
-
for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
|
|
93
|
-
|
|
94
|
-
if (state.tokens[blkIdx].type !== 'inline') { continue; }
|
|
95
|
-
|
|
96
|
-
if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
|
|
97
|
-
replace_scoped(state.tokens[blkIdx].children);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (RARE_RE.test(state.tokens[blkIdx].content)) {
|
|
101
|
-
replace_rare(state.tokens[blkIdx].children);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
};
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
// Convert straight quotation marks to typographic ones
|
|
2
|
-
//
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var isWhiteSpace = require('../common/utils').isWhiteSpace;
|
|
7
|
-
var isPunctChar = require('../common/utils').isPunctChar;
|
|
8
|
-
var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
|
|
9
|
-
|
|
10
|
-
var QUOTE_TEST_RE = /['"]/;
|
|
11
|
-
var QUOTE_RE = /['"]/g;
|
|
12
|
-
var APOSTROPHE = '\u2019'; /* ’ */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function replaceAt(str, index, ch) {
|
|
16
|
-
return str.slice(0, index) + ch + str.slice(index + 1);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function process_inlines(tokens, state) {
|
|
20
|
-
var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,
|
|
21
|
-
isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,
|
|
22
|
-
canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
|
|
23
|
-
|
|
24
|
-
stack = [];
|
|
25
|
-
|
|
26
|
-
for (i = 0; i < tokens.length; i++) {
|
|
27
|
-
token = tokens[i];
|
|
28
|
-
|
|
29
|
-
thisLevel = tokens[i].level;
|
|
30
|
-
|
|
31
|
-
for (j = stack.length - 1; j >= 0; j--) {
|
|
32
|
-
if (stack[j].level <= thisLevel) { break; }
|
|
33
|
-
}
|
|
34
|
-
stack.length = j + 1;
|
|
35
|
-
|
|
36
|
-
if (token.type !== 'text') { continue; }
|
|
37
|
-
|
|
38
|
-
text = token.content;
|
|
39
|
-
pos = 0;
|
|
40
|
-
max = text.length;
|
|
41
|
-
|
|
42
|
-
/*eslint no-labels:0,block-scoped-var:0*/
|
|
43
|
-
OUTER:
|
|
44
|
-
while (pos < max) {
|
|
45
|
-
QUOTE_RE.lastIndex = pos;
|
|
46
|
-
t = QUOTE_RE.exec(text);
|
|
47
|
-
if (!t) { break; }
|
|
48
|
-
|
|
49
|
-
canOpen = canClose = true;
|
|
50
|
-
pos = t.index + 1;
|
|
51
|
-
isSingle = (t[0] === "'");
|
|
52
|
-
|
|
53
|
-
// Find previous character,
|
|
54
|
-
// default to space if it's the beginning of the line
|
|
55
|
-
//
|
|
56
|
-
lastChar = 0x20;
|
|
57
|
-
|
|
58
|
-
if (t.index - 1 >= 0) {
|
|
59
|
-
lastChar = text.charCodeAt(t.index - 1);
|
|
60
|
-
} else {
|
|
61
|
-
for (j = i - 1; j >= 0; j--) {
|
|
62
|
-
if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
|
|
63
|
-
if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'
|
|
64
|
-
|
|
65
|
-
lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Find next character,
|
|
71
|
-
// default to space if it's the end of the line
|
|
72
|
-
//
|
|
73
|
-
nextChar = 0x20;
|
|
74
|
-
|
|
75
|
-
if (pos < max) {
|
|
76
|
-
nextChar = text.charCodeAt(pos);
|
|
77
|
-
} else {
|
|
78
|
-
for (j = i + 1; j < tokens.length; j++) {
|
|
79
|
-
if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
|
|
80
|
-
if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'
|
|
81
|
-
|
|
82
|
-
nextChar = tokens[j].content.charCodeAt(0);
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
|
|
88
|
-
isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
|
|
89
|
-
|
|
90
|
-
isLastWhiteSpace = isWhiteSpace(lastChar);
|
|
91
|
-
isNextWhiteSpace = isWhiteSpace(nextChar);
|
|
92
|
-
|
|
93
|
-
if (isNextWhiteSpace) {
|
|
94
|
-
canOpen = false;
|
|
95
|
-
} else if (isNextPunctChar) {
|
|
96
|
-
if (!(isLastWhiteSpace || isLastPunctChar)) {
|
|
97
|
-
canOpen = false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (isLastWhiteSpace) {
|
|
102
|
-
canClose = false;
|
|
103
|
-
} else if (isLastPunctChar) {
|
|
104
|
-
if (!(isNextWhiteSpace || isNextPunctChar)) {
|
|
105
|
-
canClose = false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (nextChar === 0x22 /* " */ && t[0] === '"') {
|
|
110
|
-
if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {
|
|
111
|
-
// special case: 1"" - count first quote as an inch
|
|
112
|
-
canClose = canOpen = false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (canOpen && canClose) {
|
|
117
|
-
// Replace quotes in the middle of punctuation sequence, but not
|
|
118
|
-
// in the middle of the words, i.e.:
|
|
119
|
-
//
|
|
120
|
-
// 1. foo " bar " baz - not replaced
|
|
121
|
-
// 2. foo-"-bar-"-baz - replaced
|
|
122
|
-
// 3. foo"bar"baz - not replaced
|
|
123
|
-
//
|
|
124
|
-
canOpen = isLastPunctChar;
|
|
125
|
-
canClose = isNextPunctChar;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (!canOpen && !canClose) {
|
|
129
|
-
// middle of word
|
|
130
|
-
if (isSingle) {
|
|
131
|
-
token.content = replaceAt(token.content, t.index, APOSTROPHE);
|
|
132
|
-
}
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (canClose) {
|
|
137
|
-
// this could be a closing quote, rewind the stack to get a match
|
|
138
|
-
for (j = stack.length - 1; j >= 0; j--) {
|
|
139
|
-
item = stack[j];
|
|
140
|
-
if (stack[j].level < thisLevel) { break; }
|
|
141
|
-
if (item.single === isSingle && stack[j].level === thisLevel) {
|
|
142
|
-
item = stack[j];
|
|
143
|
-
|
|
144
|
-
if (isSingle) {
|
|
145
|
-
openQuote = state.md.options.quotes[2];
|
|
146
|
-
closeQuote = state.md.options.quotes[3];
|
|
147
|
-
} else {
|
|
148
|
-
openQuote = state.md.options.quotes[0];
|
|
149
|
-
closeQuote = state.md.options.quotes[1];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// replace token.content *before* tokens[item.token].content,
|
|
153
|
-
// because, if they are pointing at the same token, replaceAt
|
|
154
|
-
// could mess up indices when quote length != 1
|
|
155
|
-
token.content = replaceAt(token.content, t.index, closeQuote);
|
|
156
|
-
tokens[item.token].content = replaceAt(
|
|
157
|
-
tokens[item.token].content, item.pos, openQuote);
|
|
158
|
-
|
|
159
|
-
pos += closeQuote.length - 1;
|
|
160
|
-
if (item.token === i) { pos += openQuote.length - 1; }
|
|
161
|
-
|
|
162
|
-
text = token.content;
|
|
163
|
-
max = text.length;
|
|
164
|
-
|
|
165
|
-
stack.length = j;
|
|
166
|
-
continue OUTER;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (canOpen) {
|
|
172
|
-
stack.push({
|
|
173
|
-
token: i,
|
|
174
|
-
pos: t.index,
|
|
175
|
-
single: isSingle,
|
|
176
|
-
level: thisLevel
|
|
177
|
-
});
|
|
178
|
-
} else if (canClose && isSingle) {
|
|
179
|
-
token.content = replaceAt(token.content, t.index, APOSTROPHE);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
module.exports = function smartquotes(state) {
|
|
187
|
-
/*eslint max-depth:0*/
|
|
188
|
-
var blkIdx;
|
|
189
|
-
|
|
190
|
-
if (!state.md.options.typographer) { return; }
|
|
191
|
-
|
|
192
|
-
for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
|
|
193
|
-
|
|
194
|
-
if (state.tokens[blkIdx].type !== 'inline' ||
|
|
195
|
-
!QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
process_inlines(state.tokens[blkIdx].children, state);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Core state object
|
|
2
|
-
//
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var Token = require('../token');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function StateCore(src, md, env) {
|
|
9
|
-
this.src = src;
|
|
10
|
-
this.env = env;
|
|
11
|
-
this.tokens = [];
|
|
12
|
-
this.inlineMode = false;
|
|
13
|
-
this.md = md; // link to parser instance
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// re-export Token class to use in core rules
|
|
17
|
-
StateCore.prototype.Token = Token;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
module.exports = StateCore;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Join raw text tokens with the rest of the text
|
|
2
|
-
//
|
|
3
|
-
// This is set as a separate rule to provide an opportunity for plugins
|
|
4
|
-
// to run text replacements after text join, but before escape join.
|
|
5
|
-
//
|
|
6
|
-
// For example, `\:)` shouldn't be replaced with an emoji.
|
|
7
|
-
//
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = function text_join(state) {
|
|
12
|
-
var j, l, tokens, curr, max, last,
|
|
13
|
-
blockTokens = state.tokens;
|
|
14
|
-
|
|
15
|
-
for (j = 0, l = blockTokens.length; j < l; j++) {
|
|
16
|
-
if (blockTokens[j].type !== 'inline') continue;
|
|
17
|
-
|
|
18
|
-
tokens = blockTokens[j].children;
|
|
19
|
-
max = tokens.length;
|
|
20
|
-
|
|
21
|
-
for (curr = 0; curr < max; curr++) {
|
|
22
|
-
if (tokens[curr].type === 'text_special') {
|
|
23
|
-
tokens[curr].type = 'text';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
for (curr = last = 0; curr < max; curr++) {
|
|
28
|
-
if (tokens[curr].type === 'text' &&
|
|
29
|
-
curr + 1 < max &&
|
|
30
|
-
tokens[curr + 1].type === 'text') {
|
|
31
|
-
|
|
32
|
-
// collapse two adjacent text nodes
|
|
33
|
-
tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
|
|
34
|
-
} else {
|
|
35
|
-
if (curr !== last) { tokens[last] = tokens[curr]; }
|
|
36
|
-
|
|
37
|
-
last++;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (curr !== last) {
|
|
42
|
-
tokens.length = last;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// Process autolinks '<protocol:...>'
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/*eslint max-len:0*/
|
|
7
|
-
var EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;
|
|
8
|
-
var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = function autolink(state, silent) {
|
|
12
|
-
var url, fullUrl, token, ch, start, max,
|
|
13
|
-
pos = state.pos;
|
|
14
|
-
|
|
15
|
-
if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
|
|
16
|
-
|
|
17
|
-
start = state.pos;
|
|
18
|
-
max = state.posMax;
|
|
19
|
-
|
|
20
|
-
for (;;) {
|
|
21
|
-
if (++pos >= max) return false;
|
|
22
|
-
|
|
23
|
-
ch = state.src.charCodeAt(pos);
|
|
24
|
-
|
|
25
|
-
if (ch === 0x3C /* < */) return false;
|
|
26
|
-
if (ch === 0x3E /* > */) break;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
url = state.src.slice(start + 1, pos);
|
|
30
|
-
|
|
31
|
-
if (AUTOLINK_RE.test(url)) {
|
|
32
|
-
fullUrl = state.md.normalizeLink(url);
|
|
33
|
-
if (!state.md.validateLink(fullUrl)) { return false; }
|
|
34
|
-
|
|
35
|
-
if (!silent) {
|
|
36
|
-
token = state.push('link_open', 'a', 1);
|
|
37
|
-
token.attrs = [ [ 'href', fullUrl ] ];
|
|
38
|
-
token.markup = 'autolink';
|
|
39
|
-
token.info = 'auto';
|
|
40
|
-
|
|
41
|
-
token = state.push('text', '', 0);
|
|
42
|
-
token.content = state.md.normalizeLinkText(url);
|
|
43
|
-
|
|
44
|
-
token = state.push('link_close', 'a', -1);
|
|
45
|
-
token.markup = 'autolink';
|
|
46
|
-
token.info = 'auto';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
state.pos += url.length + 2;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (EMAIL_RE.test(url)) {
|
|
54
|
-
fullUrl = state.md.normalizeLink('mailto:' + url);
|
|
55
|
-
if (!state.md.validateLink(fullUrl)) { return false; }
|
|
56
|
-
|
|
57
|
-
if (!silent) {
|
|
58
|
-
token = state.push('link_open', 'a', 1);
|
|
59
|
-
token.attrs = [ [ 'href', fullUrl ] ];
|
|
60
|
-
token.markup = 'autolink';
|
|
61
|
-
token.info = 'auto';
|
|
62
|
-
|
|
63
|
-
token = state.push('text', '', 0);
|
|
64
|
-
token.content = state.md.normalizeLinkText(url);
|
|
65
|
-
|
|
66
|
-
token = state.push('link_close', 'a', -1);
|
|
67
|
-
token.markup = 'autolink';
|
|
68
|
-
token.info = 'auto';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
state.pos += url.length + 2;
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return false;
|
|
76
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Parse backticks
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = function backtick(state, silent) {
|
|
7
|
-
var start, max, marker, token, matchStart, matchEnd, openerLength, closerLength,
|
|
8
|
-
pos = state.pos,
|
|
9
|
-
ch = state.src.charCodeAt(pos);
|
|
10
|
-
|
|
11
|
-
if (ch !== 0x60/* ` */) { return false; }
|
|
12
|
-
|
|
13
|
-
start = pos;
|
|
14
|
-
pos++;
|
|
15
|
-
max = state.posMax;
|
|
16
|
-
|
|
17
|
-
// scan marker length
|
|
18
|
-
while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
|
|
19
|
-
|
|
20
|
-
marker = state.src.slice(start, pos);
|
|
21
|
-
openerLength = marker.length;
|
|
22
|
-
|
|
23
|
-
if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
|
|
24
|
-
if (!silent) state.pending += marker;
|
|
25
|
-
state.pos += openerLength;
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
matchEnd = pos;
|
|
30
|
-
|
|
31
|
-
// Nothing found in the cache, scan until the end of the line (or until marker is found)
|
|
32
|
-
while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
|
|
33
|
-
matchEnd = matchStart + 1;
|
|
34
|
-
|
|
35
|
-
// scan marker length
|
|
36
|
-
while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
|
|
37
|
-
|
|
38
|
-
closerLength = matchEnd - matchStart;
|
|
39
|
-
|
|
40
|
-
if (closerLength === openerLength) {
|
|
41
|
-
// Found matching closer length.
|
|
42
|
-
if (!silent) {
|
|
43
|
-
token = state.push('code_inline', 'code', 0);
|
|
44
|
-
token.markup = marker;
|
|
45
|
-
token.content = state.src.slice(pos, matchStart)
|
|
46
|
-
.replace(/\n/g, ' ')
|
|
47
|
-
.replace(/^ (.+) $/, '$1');
|
|
48
|
-
}
|
|
49
|
-
state.pos = matchEnd;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Some different length found, put it in cache as upper limit of where closer can be found
|
|
54
|
-
state.backticks[closerLength] = matchStart;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Scanned through the end, didn't find anything
|
|
58
|
-
state.backticksScanned = true;
|
|
59
|
-
|
|
60
|
-
if (!silent) state.pending += marker;
|
|
61
|
-
state.pos += openerLength;
|
|
62
|
-
return true;
|
|
63
|
-
};
|
package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
// For each opening emphasis-like marker find a matching closing one
|
|
2
|
-
//
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function processDelimiters(delimiters) {
|
|
7
|
-
var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx,
|
|
8
|
-
isOddMatch, lastJump,
|
|
9
|
-
openersBottom = {},
|
|
10
|
-
max = delimiters.length;
|
|
11
|
-
|
|
12
|
-
if (!max) return;
|
|
13
|
-
|
|
14
|
-
// headerIdx is the first delimiter of the current (where closer is) delimiter run
|
|
15
|
-
var headerIdx = 0;
|
|
16
|
-
var lastTokenIdx = -2; // needs any value lower than -1
|
|
17
|
-
var jumps = [];
|
|
18
|
-
|
|
19
|
-
for (closerIdx = 0; closerIdx < max; closerIdx++) {
|
|
20
|
-
closer = delimiters[closerIdx];
|
|
21
|
-
|
|
22
|
-
jumps.push(0);
|
|
23
|
-
|
|
24
|
-
// markers belong to same delimiter run if:
|
|
25
|
-
// - they have adjacent tokens
|
|
26
|
-
// - AND markers are the same
|
|
27
|
-
//
|
|
28
|
-
if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {
|
|
29
|
-
headerIdx = closerIdx;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
lastTokenIdx = closer.token;
|
|
33
|
-
|
|
34
|
-
// Length is only used for emphasis-specific "rule of 3",
|
|
35
|
-
// if it's not defined (in strikethrough or 3rd party plugins),
|
|
36
|
-
// we can default it to 0 to disable those checks.
|
|
37
|
-
//
|
|
38
|
-
closer.length = closer.length || 0;
|
|
39
|
-
|
|
40
|
-
if (!closer.close) continue;
|
|
41
|
-
|
|
42
|
-
// Previously calculated lower bounds (previous fails)
|
|
43
|
-
// for each marker, each delimiter length modulo 3,
|
|
44
|
-
// and for whether this closer can be an opener;
|
|
45
|
-
// https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
|
|
46
|
-
if (!openersBottom.hasOwnProperty(closer.marker)) {
|
|
47
|
-
openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)];
|
|
51
|
-
|
|
52
|
-
openerIdx = headerIdx - jumps[headerIdx] - 1;
|
|
53
|
-
|
|
54
|
-
newMinOpenerIdx = openerIdx;
|
|
55
|
-
|
|
56
|
-
for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
|
|
57
|
-
opener = delimiters[openerIdx];
|
|
58
|
-
|
|
59
|
-
if (opener.marker !== closer.marker) continue;
|
|
60
|
-
|
|
61
|
-
if (opener.open && opener.end < 0) {
|
|
62
|
-
|
|
63
|
-
isOddMatch = false;
|
|
64
|
-
|
|
65
|
-
// from spec:
|
|
66
|
-
//
|
|
67
|
-
// If one of the delimiters can both open and close emphasis, then the
|
|
68
|
-
// sum of the lengths of the delimiter runs containing the opening and
|
|
69
|
-
// closing delimiters must not be a multiple of 3 unless both lengths
|
|
70
|
-
// are multiples of 3.
|
|
71
|
-
//
|
|
72
|
-
if (opener.close || closer.open) {
|
|
73
|
-
if ((opener.length + closer.length) % 3 === 0) {
|
|
74
|
-
if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {
|
|
75
|
-
isOddMatch = true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!isOddMatch) {
|
|
81
|
-
// If previous delimiter cannot be an opener, we can safely skip
|
|
82
|
-
// the entire sequence in future checks. This is required to make
|
|
83
|
-
// sure algorithm has linear complexity (see *_*_*_*_*_... case).
|
|
84
|
-
//
|
|
85
|
-
lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ?
|
|
86
|
-
jumps[openerIdx - 1] + 1 :
|
|
87
|
-
0;
|
|
88
|
-
|
|
89
|
-
jumps[closerIdx] = closerIdx - openerIdx + lastJump;
|
|
90
|
-
jumps[openerIdx] = lastJump;
|
|
91
|
-
|
|
92
|
-
closer.open = false;
|
|
93
|
-
opener.end = closerIdx;
|
|
94
|
-
opener.close = false;
|
|
95
|
-
newMinOpenerIdx = -1;
|
|
96
|
-
// treat next token as start of run,
|
|
97
|
-
// it optimizes skips in **<...>**a**<...>** pathological case
|
|
98
|
-
lastTokenIdx = -2;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (newMinOpenerIdx !== -1) {
|
|
105
|
-
// If match for this delimiter run failed, we want to set lower bound for
|
|
106
|
-
// future lookups. This is required to make sure algorithm has linear
|
|
107
|
-
// complexity.
|
|
108
|
-
//
|
|
109
|
-
// See details here:
|
|
110
|
-
// https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
|
|
111
|
-
//
|
|
112
|
-
openersBottom[closer.marker][(closer.open ? 3 : 0) + ((closer.length || 0) % 3)] = newMinOpenerIdx;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
module.exports = function link_pairs(state) {
|
|
119
|
-
var curr,
|
|
120
|
-
tokens_meta = state.tokens_meta,
|
|
121
|
-
max = state.tokens_meta.length;
|
|
122
|
-
|
|
123
|
-
processDelimiters(state.delimiters);
|
|
124
|
-
|
|
125
|
-
for (curr = 0; curr < max; curr++) {
|
|
126
|
-
if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
|
|
127
|
-
processDelimiters(tokens_meta[curr].delimiters);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
};
|