@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_block/state_block.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
// Parser state class
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var Token = require('../token');
|
|
6
|
-
var isSpace = require('../common/utils').isSpace;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function StateBlock(src, md, env, tokens) {
|
|
10
|
-
var ch, s, start, pos, len, indent, offset, indent_found;
|
|
11
|
-
|
|
12
|
-
this.src = src;
|
|
13
|
-
|
|
14
|
-
// link to parser instance
|
|
15
|
-
this.md = md;
|
|
16
|
-
|
|
17
|
-
this.env = env;
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
// Internal state vartiables
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
this.tokens = tokens;
|
|
24
|
-
|
|
25
|
-
this.bMarks = []; // line begin offsets for fast jumps
|
|
26
|
-
this.eMarks = []; // line end offsets for fast jumps
|
|
27
|
-
this.tShift = []; // offsets of the first non-space characters (tabs not expanded)
|
|
28
|
-
this.sCount = []; // indents for each line (tabs expanded)
|
|
29
|
-
|
|
30
|
-
// An amount of virtual spaces (tabs expanded) between beginning
|
|
31
|
-
// of each line (bMarks) and real beginning of that line.
|
|
32
|
-
//
|
|
33
|
-
// It exists only as a hack because blockquotes override bMarks
|
|
34
|
-
// losing information in the process.
|
|
35
|
-
//
|
|
36
|
-
// It's used only when expanding tabs, you can think about it as
|
|
37
|
-
// an initial tab length, e.g. bsCount=21 applied to string `\t123`
|
|
38
|
-
// means first tab should be expanded to 4-21%4 === 3 spaces.
|
|
39
|
-
//
|
|
40
|
-
this.bsCount = [];
|
|
41
|
-
|
|
42
|
-
// block parser variables
|
|
43
|
-
this.blkIndent = 0; // required block content indent (for example, if we are
|
|
44
|
-
// inside a list, it would be positioned after list marker)
|
|
45
|
-
this.line = 0; // line index in src
|
|
46
|
-
this.lineMax = 0; // lines count
|
|
47
|
-
this.tight = false; // loose/tight mode for lists
|
|
48
|
-
this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
|
|
49
|
-
this.listIndent = -1; // indent of the current list block (-1 if there isn't any)
|
|
50
|
-
|
|
51
|
-
// can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
|
|
52
|
-
// used in lists to determine if they interrupt a paragraph
|
|
53
|
-
this.parentType = 'root';
|
|
54
|
-
|
|
55
|
-
this.level = 0;
|
|
56
|
-
|
|
57
|
-
// renderer
|
|
58
|
-
this.result = '';
|
|
59
|
-
|
|
60
|
-
// Create caches
|
|
61
|
-
// Generate markers.
|
|
62
|
-
s = this.src;
|
|
63
|
-
indent_found = false;
|
|
64
|
-
|
|
65
|
-
for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
|
|
66
|
-
ch = s.charCodeAt(pos);
|
|
67
|
-
|
|
68
|
-
if (!indent_found) {
|
|
69
|
-
if (isSpace(ch)) {
|
|
70
|
-
indent++;
|
|
71
|
-
|
|
72
|
-
if (ch === 0x09) {
|
|
73
|
-
offset += 4 - offset % 4;
|
|
74
|
-
} else {
|
|
75
|
-
offset++;
|
|
76
|
-
}
|
|
77
|
-
continue;
|
|
78
|
-
} else {
|
|
79
|
-
indent_found = true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (ch === 0x0A || pos === len - 1) {
|
|
84
|
-
if (ch !== 0x0A) { pos++; }
|
|
85
|
-
this.bMarks.push(start);
|
|
86
|
-
this.eMarks.push(pos);
|
|
87
|
-
this.tShift.push(indent);
|
|
88
|
-
this.sCount.push(offset);
|
|
89
|
-
this.bsCount.push(0);
|
|
90
|
-
|
|
91
|
-
indent_found = false;
|
|
92
|
-
indent = 0;
|
|
93
|
-
offset = 0;
|
|
94
|
-
start = pos + 1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Push fake entry to simplify cache bounds checks
|
|
99
|
-
this.bMarks.push(s.length);
|
|
100
|
-
this.eMarks.push(s.length);
|
|
101
|
-
this.tShift.push(0);
|
|
102
|
-
this.sCount.push(0);
|
|
103
|
-
this.bsCount.push(0);
|
|
104
|
-
|
|
105
|
-
this.lineMax = this.bMarks.length - 1; // don't count last fake line
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Push new token to "stream".
|
|
109
|
-
//
|
|
110
|
-
StateBlock.prototype.push = function (type, tag, nesting) {
|
|
111
|
-
var token = new Token(type, tag, nesting);
|
|
112
|
-
token.block = true;
|
|
113
|
-
|
|
114
|
-
if (nesting < 0) this.level--; // closing tag
|
|
115
|
-
token.level = this.level;
|
|
116
|
-
if (nesting > 0) this.level++; // opening tag
|
|
117
|
-
|
|
118
|
-
this.tokens.push(token);
|
|
119
|
-
return token;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
StateBlock.prototype.isEmpty = function isEmpty(line) {
|
|
123
|
-
return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
|
|
127
|
-
for (var max = this.lineMax; from < max; from++) {
|
|
128
|
-
if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return from;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// Skip spaces from given position.
|
|
136
|
-
StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
|
|
137
|
-
var ch;
|
|
138
|
-
|
|
139
|
-
for (var max = this.src.length; pos < max; pos++) {
|
|
140
|
-
ch = this.src.charCodeAt(pos);
|
|
141
|
-
if (!isSpace(ch)) { break; }
|
|
142
|
-
}
|
|
143
|
-
return pos;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// Skip spaces from given position in reverse.
|
|
147
|
-
StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
|
|
148
|
-
if (pos <= min) { return pos; }
|
|
149
|
-
|
|
150
|
-
while (pos > min) {
|
|
151
|
-
if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }
|
|
152
|
-
}
|
|
153
|
-
return pos;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// Skip char codes from given position
|
|
157
|
-
StateBlock.prototype.skipChars = function skipChars(pos, code) {
|
|
158
|
-
for (var max = this.src.length; pos < max; pos++) {
|
|
159
|
-
if (this.src.charCodeAt(pos) !== code) { break; }
|
|
160
|
-
}
|
|
161
|
-
return pos;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Skip char codes reverse from given position - 1
|
|
165
|
-
StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
|
|
166
|
-
if (pos <= min) { return pos; }
|
|
167
|
-
|
|
168
|
-
while (pos > min) {
|
|
169
|
-
if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
|
|
170
|
-
}
|
|
171
|
-
return pos;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// cut lines range from source.
|
|
175
|
-
StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
|
|
176
|
-
var i, lineIndent, ch, first, last, queue, lineStart,
|
|
177
|
-
line = begin;
|
|
178
|
-
|
|
179
|
-
if (begin >= end) {
|
|
180
|
-
return '';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
queue = new Array(end - begin);
|
|
184
|
-
|
|
185
|
-
for (i = 0; line < end; line++, i++) {
|
|
186
|
-
lineIndent = 0;
|
|
187
|
-
lineStart = first = this.bMarks[line];
|
|
188
|
-
|
|
189
|
-
if (line + 1 < end || keepLastLF) {
|
|
190
|
-
// No need for bounds check because we have fake entry on tail.
|
|
191
|
-
last = this.eMarks[line] + 1;
|
|
192
|
-
} else {
|
|
193
|
-
last = this.eMarks[line];
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
while (first < last && lineIndent < indent) {
|
|
197
|
-
ch = this.src.charCodeAt(first);
|
|
198
|
-
|
|
199
|
-
if (isSpace(ch)) {
|
|
200
|
-
if (ch === 0x09) {
|
|
201
|
-
lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
|
|
202
|
-
} else {
|
|
203
|
-
lineIndent++;
|
|
204
|
-
}
|
|
205
|
-
} else if (first - lineStart < this.tShift[line]) {
|
|
206
|
-
// patched tShift masked characters to look like spaces (blockquotes, list markers)
|
|
207
|
-
lineIndent++;
|
|
208
|
-
} else {
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
first++;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (lineIndent > indent) {
|
|
216
|
-
// partially expanding tabs in code blocks, e.g '\t\tfoobar'
|
|
217
|
-
// with indent=2 becomes ' \tfoobar'
|
|
218
|
-
queue[i] = new Array(lineIndent - indent + 1).join(' ') + this.src.slice(first, last);
|
|
219
|
-
} else {
|
|
220
|
-
queue[i] = this.src.slice(first, last);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return queue.join('');
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// re-export Token class to use in block rules
|
|
228
|
-
StateBlock.prototype.Token = Token;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
module.exports = StateBlock;
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
// GFM table, https://github.github.com/gfm/#tables-extension-
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var isSpace = require('../common/utils').isSpace;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function getLine(state, line) {
|
|
9
|
-
var pos = state.bMarks[line] + state.tShift[line],
|
|
10
|
-
max = state.eMarks[line];
|
|
11
|
-
|
|
12
|
-
return state.src.slice(pos, max);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function escapedSplit(str) {
|
|
16
|
-
var result = [],
|
|
17
|
-
pos = 0,
|
|
18
|
-
max = str.length,
|
|
19
|
-
ch,
|
|
20
|
-
isEscaped = false,
|
|
21
|
-
lastPos = 0,
|
|
22
|
-
current = '';
|
|
23
|
-
|
|
24
|
-
ch = str.charCodeAt(pos);
|
|
25
|
-
|
|
26
|
-
while (pos < max) {
|
|
27
|
-
if (ch === 0x7c/* | */) {
|
|
28
|
-
if (!isEscaped) {
|
|
29
|
-
// pipe separating cells, '|'
|
|
30
|
-
result.push(current + str.substring(lastPos, pos));
|
|
31
|
-
current = '';
|
|
32
|
-
lastPos = pos + 1;
|
|
33
|
-
} else {
|
|
34
|
-
// escaped pipe, '\|'
|
|
35
|
-
current += str.substring(lastPos, pos - 1);
|
|
36
|
-
lastPos = pos;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
isEscaped = (ch === 0x5c/* \ */);
|
|
41
|
-
pos++;
|
|
42
|
-
|
|
43
|
-
ch = str.charCodeAt(pos);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
result.push(current + str.substring(lastPos));
|
|
47
|
-
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
module.exports = function table(state, startLine, endLine, silent) {
|
|
53
|
-
var ch, lineText, pos, i, l, nextLine, columns, columnCount, token,
|
|
54
|
-
aligns, t, tableLines, tbodyLines, oldParentType, terminate,
|
|
55
|
-
terminatorRules, firstCh, secondCh;
|
|
56
|
-
|
|
57
|
-
// should have at least two lines
|
|
58
|
-
if (startLine + 2 > endLine) { return false; }
|
|
59
|
-
|
|
60
|
-
nextLine = startLine + 1;
|
|
61
|
-
|
|
62
|
-
if (state.sCount[nextLine] < state.blkIndent) { return false; }
|
|
63
|
-
|
|
64
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
65
|
-
if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
|
|
66
|
-
|
|
67
|
-
// first character of the second line should be '|', '-', ':',
|
|
68
|
-
// and no other characters are allowed but spaces;
|
|
69
|
-
// basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
|
|
70
|
-
|
|
71
|
-
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
72
|
-
if (pos >= state.eMarks[nextLine]) { return false; }
|
|
73
|
-
|
|
74
|
-
firstCh = state.src.charCodeAt(pos++);
|
|
75
|
-
if (firstCh !== 0x7C/* | */ && firstCh !== 0x2D/* - */ && firstCh !== 0x3A/* : */) { return false; }
|
|
76
|
-
|
|
77
|
-
if (pos >= state.eMarks[nextLine]) { return false; }
|
|
78
|
-
|
|
79
|
-
secondCh = state.src.charCodeAt(pos++);
|
|
80
|
-
if (secondCh !== 0x7C/* | */ && secondCh !== 0x2D/* - */ && secondCh !== 0x3A/* : */ && !isSpace(secondCh)) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// if first character is '-', then second character must not be a space
|
|
85
|
-
// (due to parsing ambiguity with list)
|
|
86
|
-
if (firstCh === 0x2D/* - */ && isSpace(secondCh)) { return false; }
|
|
87
|
-
|
|
88
|
-
while (pos < state.eMarks[nextLine]) {
|
|
89
|
-
ch = state.src.charCodeAt(pos);
|
|
90
|
-
|
|
91
|
-
if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; }
|
|
92
|
-
|
|
93
|
-
pos++;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
lineText = getLine(state, startLine + 1);
|
|
97
|
-
|
|
98
|
-
columns = lineText.split('|');
|
|
99
|
-
aligns = [];
|
|
100
|
-
for (i = 0; i < columns.length; i++) {
|
|
101
|
-
t = columns[i].trim();
|
|
102
|
-
if (!t) {
|
|
103
|
-
// allow empty columns before and after table, but not in between columns;
|
|
104
|
-
// e.g. allow ` |---| `, disallow ` ---||--- `
|
|
105
|
-
if (i === 0 || i === columns.length - 1) {
|
|
106
|
-
continue;
|
|
107
|
-
} else {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!/^:?-+:?$/.test(t)) { return false; }
|
|
113
|
-
if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
|
|
114
|
-
aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
|
|
115
|
-
} else if (t.charCodeAt(0) === 0x3A/* : */) {
|
|
116
|
-
aligns.push('left');
|
|
117
|
-
} else {
|
|
118
|
-
aligns.push('');
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
lineText = getLine(state, startLine).trim();
|
|
123
|
-
if (lineText.indexOf('|') === -1) { return false; }
|
|
124
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
125
|
-
columns = escapedSplit(lineText);
|
|
126
|
-
if (columns.length && columns[0] === '') columns.shift();
|
|
127
|
-
if (columns.length && columns[columns.length - 1] === '') columns.pop();
|
|
128
|
-
|
|
129
|
-
// header row will define an amount of columns in the entire table,
|
|
130
|
-
// and align row should be exactly the same (the rest of the rows can differ)
|
|
131
|
-
columnCount = columns.length;
|
|
132
|
-
if (columnCount === 0 || columnCount !== aligns.length) { return false; }
|
|
133
|
-
|
|
134
|
-
if (silent) { return true; }
|
|
135
|
-
|
|
136
|
-
oldParentType = state.parentType;
|
|
137
|
-
state.parentType = 'table';
|
|
138
|
-
|
|
139
|
-
// use 'blockquote' lists for termination because it's
|
|
140
|
-
// the most similar to tables
|
|
141
|
-
terminatorRules = state.md.block.ruler.getRules('blockquote');
|
|
142
|
-
|
|
143
|
-
token = state.push('table_open', 'table', 1);
|
|
144
|
-
token.map = tableLines = [ startLine, 0 ];
|
|
145
|
-
|
|
146
|
-
token = state.push('thead_open', 'thead', 1);
|
|
147
|
-
token.map = [ startLine, startLine + 1 ];
|
|
148
|
-
|
|
149
|
-
token = state.push('tr_open', 'tr', 1);
|
|
150
|
-
token.map = [ startLine, startLine + 1 ];
|
|
151
|
-
|
|
152
|
-
for (i = 0; i < columns.length; i++) {
|
|
153
|
-
token = state.push('th_open', 'th', 1);
|
|
154
|
-
if (aligns[i]) {
|
|
155
|
-
token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
token = state.push('inline', '', 0);
|
|
159
|
-
token.content = columns[i].trim();
|
|
160
|
-
token.children = [];
|
|
161
|
-
|
|
162
|
-
token = state.push('th_close', 'th', -1);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
token = state.push('tr_close', 'tr', -1);
|
|
166
|
-
token = state.push('thead_close', 'thead', -1);
|
|
167
|
-
|
|
168
|
-
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
|
|
169
|
-
if (state.sCount[nextLine] < state.blkIndent) { break; }
|
|
170
|
-
|
|
171
|
-
terminate = false;
|
|
172
|
-
for (i = 0, l = terminatorRules.length; i < l; i++) {
|
|
173
|
-
if (terminatorRules[i](state, nextLine, endLine, true)) {
|
|
174
|
-
terminate = true;
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (terminate) { break; }
|
|
180
|
-
lineText = getLine(state, nextLine).trim();
|
|
181
|
-
if (!lineText) { break; }
|
|
182
|
-
if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
|
|
183
|
-
columns = escapedSplit(lineText);
|
|
184
|
-
if (columns.length && columns[0] === '') columns.shift();
|
|
185
|
-
if (columns.length && columns[columns.length - 1] === '') columns.pop();
|
|
186
|
-
|
|
187
|
-
if (nextLine === startLine + 2) {
|
|
188
|
-
token = state.push('tbody_open', 'tbody', 1);
|
|
189
|
-
token.map = tbodyLines = [ startLine + 2, 0 ];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
token = state.push('tr_open', 'tr', 1);
|
|
193
|
-
token.map = [ nextLine, nextLine + 1 ];
|
|
194
|
-
|
|
195
|
-
for (i = 0; i < columnCount; i++) {
|
|
196
|
-
token = state.push('td_open', 'td', 1);
|
|
197
|
-
if (aligns[i]) {
|
|
198
|
-
token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
token = state.push('inline', '', 0);
|
|
202
|
-
token.content = columns[i] ? columns[i].trim() : '';
|
|
203
|
-
token.children = [];
|
|
204
|
-
|
|
205
|
-
token = state.push('td_close', 'td', -1);
|
|
206
|
-
}
|
|
207
|
-
token = state.push('tr_close', 'tr', -1);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (tbodyLines) {
|
|
211
|
-
token = state.push('tbody_close', 'tbody', -1);
|
|
212
|
-
tbodyLines[1] = nextLine;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
token = state.push('table_close', 'table', -1);
|
|
216
|
-
tableLines[1] = nextLine;
|
|
217
|
-
|
|
218
|
-
state.parentType = oldParentType;
|
|
219
|
-
state.line = nextLine;
|
|
220
|
-
return true;
|
|
221
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module.exports = function block(state) {
|
|
5
|
-
var token;
|
|
6
|
-
|
|
7
|
-
if (state.inlineMode) {
|
|
8
|
-
token = new state.Token('inline', '', 0);
|
|
9
|
-
token.content = state.src;
|
|
10
|
-
token.map = [ 0, 1 ];
|
|
11
|
-
token.children = [];
|
|
12
|
-
state.tokens.push(token);
|
|
13
|
-
} else {
|
|
14
|
-
state.md.block.parse(state.src, state.md, state.env, state.tokens);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function inline(state) {
|
|
4
|
-
var tokens = state.tokens, tok, i, l;
|
|
5
|
-
|
|
6
|
-
// Parse inlines
|
|
7
|
-
for (i = 0, l = tokens.length; i < l; i++) {
|
|
8
|
-
tok = tokens[i];
|
|
9
|
-
if (tok.type === 'inline') {
|
|
10
|
-
state.md.inline.parse(tok.content, state.md, state.env, tok.children);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
// Replace link-like texts with link nodes.
|
|
2
|
-
//
|
|
3
|
-
// Currently restricted by `md.validateLink()` to http/https/ftp
|
|
4
|
-
//
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var arrayReplaceAt = require('../common/utils').arrayReplaceAt;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function isLinkOpen(str) {
|
|
12
|
-
return /^<a[>\s]/i.test(str);
|
|
13
|
-
}
|
|
14
|
-
function isLinkClose(str) {
|
|
15
|
-
return /^<\/a\s*>/i.test(str);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
module.exports = function linkify(state) {
|
|
20
|
-
var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,
|
|
21
|
-
level, htmlLinkLevel, url, fullUrl, urlText,
|
|
22
|
-
blockTokens = state.tokens,
|
|
23
|
-
links;
|
|
24
|
-
|
|
25
|
-
if (!state.md.options.linkify) { return; }
|
|
26
|
-
|
|
27
|
-
for (j = 0, l = blockTokens.length; j < l; j++) {
|
|
28
|
-
if (blockTokens[j].type !== 'inline' ||
|
|
29
|
-
!state.md.linkify.pretest(blockTokens[j].content)) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
tokens = blockTokens[j].children;
|
|
34
|
-
|
|
35
|
-
htmlLinkLevel = 0;
|
|
36
|
-
|
|
37
|
-
// We scan from the end, to keep position when new tags added.
|
|
38
|
-
// Use reversed logic in links start/end match
|
|
39
|
-
for (i = tokens.length - 1; i >= 0; i--) {
|
|
40
|
-
currentToken = tokens[i];
|
|
41
|
-
|
|
42
|
-
// Skip content of markdown links
|
|
43
|
-
if (currentToken.type === 'link_close') {
|
|
44
|
-
i--;
|
|
45
|
-
while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {
|
|
46
|
-
i--;
|
|
47
|
-
}
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Skip content of html tag links
|
|
52
|
-
if (currentToken.type === 'html_inline') {
|
|
53
|
-
if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
|
|
54
|
-
htmlLinkLevel--;
|
|
55
|
-
}
|
|
56
|
-
if (isLinkClose(currentToken.content)) {
|
|
57
|
-
htmlLinkLevel++;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (htmlLinkLevel > 0) { continue; }
|
|
61
|
-
|
|
62
|
-
if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {
|
|
63
|
-
|
|
64
|
-
text = currentToken.content;
|
|
65
|
-
links = state.md.linkify.match(text);
|
|
66
|
-
|
|
67
|
-
// Now split string to nodes
|
|
68
|
-
nodes = [];
|
|
69
|
-
level = currentToken.level;
|
|
70
|
-
lastPos = 0;
|
|
71
|
-
|
|
72
|
-
// forbid escape sequence at the start of the string,
|
|
73
|
-
// this avoids http\://example.com/ from being linkified as
|
|
74
|
-
// http:<a href="//example.com/">//example.com/</a>
|
|
75
|
-
if (links.length > 0 &&
|
|
76
|
-
links[0].index === 0 &&
|
|
77
|
-
i > 0 &&
|
|
78
|
-
tokens[i - 1].type === 'text_special') {
|
|
79
|
-
links = links.slice(1);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
for (ln = 0; ln < links.length; ln++) {
|
|
83
|
-
url = links[ln].url;
|
|
84
|
-
fullUrl = state.md.normalizeLink(url);
|
|
85
|
-
if (!state.md.validateLink(fullUrl)) { continue; }
|
|
86
|
-
|
|
87
|
-
urlText = links[ln].text;
|
|
88
|
-
|
|
89
|
-
// Linkifier might send raw hostnames like "example.com", where url
|
|
90
|
-
// starts with domain name. So we prepend http:// in those cases,
|
|
91
|
-
// and remove it afterwards.
|
|
92
|
-
//
|
|
93
|
-
if (!links[ln].schema) {
|
|
94
|
-
urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');
|
|
95
|
-
} else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {
|
|
96
|
-
urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');
|
|
97
|
-
} else {
|
|
98
|
-
urlText = state.md.normalizeLinkText(urlText);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
pos = links[ln].index;
|
|
102
|
-
|
|
103
|
-
if (pos > lastPos) {
|
|
104
|
-
token = new state.Token('text', '', 0);
|
|
105
|
-
token.content = text.slice(lastPos, pos);
|
|
106
|
-
token.level = level;
|
|
107
|
-
nodes.push(token);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
token = new state.Token('link_open', 'a', 1);
|
|
111
|
-
token.attrs = [ [ 'href', fullUrl ] ];
|
|
112
|
-
token.level = level++;
|
|
113
|
-
token.markup = 'linkify';
|
|
114
|
-
token.info = 'auto';
|
|
115
|
-
nodes.push(token);
|
|
116
|
-
|
|
117
|
-
token = new state.Token('text', '', 0);
|
|
118
|
-
token.content = urlText;
|
|
119
|
-
token.level = level;
|
|
120
|
-
nodes.push(token);
|
|
121
|
-
|
|
122
|
-
token = new state.Token('link_close', 'a', -1);
|
|
123
|
-
token.level = --level;
|
|
124
|
-
token.markup = 'linkify';
|
|
125
|
-
token.info = 'auto';
|
|
126
|
-
nodes.push(token);
|
|
127
|
-
|
|
128
|
-
lastPos = links[ln].lastIndex;
|
|
129
|
-
}
|
|
130
|
-
if (lastPos < text.length) {
|
|
131
|
-
token = new state.Token('text', '', 0);
|
|
132
|
-
token.content = text.slice(lastPos);
|
|
133
|
-
token.level = level;
|
|
134
|
-
nodes.push(token);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// replace current node
|
|
138
|
-
blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Normalize input string
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// https://spec.commonmark.org/0.29/#line-ending
|
|
7
|
-
var NEWLINES_RE = /\r\n?|\n/g;
|
|
8
|
-
var NULL_RE = /\0/g;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = function normalize(state) {
|
|
12
|
-
var str;
|
|
13
|
-
|
|
14
|
-
// Normalize newlines
|
|
15
|
-
str = state.src.replace(NEWLINES_RE, '\n');
|
|
16
|
-
|
|
17
|
-
// Replace NULL characters
|
|
18
|
-
str = str.replace(NULL_RE, '\uFFFD');
|
|
19
|
-
|
|
20
|
-
state.src = str;
|
|
21
|
-
};
|