@alexlit/lint-kit 107.2.2 → 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 +9 -0
- package/.linthtmlrc.cjs +5 -0
- package/{.commitlintrc.js → commitlint.config.js} +1 -1
- package/package.json +11 -10
- 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/dictionaries/index.js +2 -1
- package/packages/config-eslint/index.js +14 -3
- 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 +4 -4
- 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/README.md +5 -5
- package/packages/config-markdownlint/index.json +17 -0
- package/packages/config-markdownlint/package.json +5 -5
- 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/scripts/lint.eslint.sh +1 -1
- package/scripts/lint.markdownlint.sh +1 -1
- package/stylelint.config.js +14 -0
- package/.eslintrc.js +0 -3
- package/.huskyrc.js +0 -3
- package/.linthtmlrc.js +0 -3
- package/.lintstagedrc.js +0 -3
- package/.markdownlintrc.js +0 -3
- package/.prettierrc.js +0 -3
- package/.stylelintrc.js +0 -4
- package/packages/config-hooks/husky.js +0 -6
- package/packages/config-markdownlint/index.js +0 -17
- 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
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// Block quotes
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var isSpace = require('../common/utils').isSpace;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = function blockquote(state, startLine, endLine, silent) {
|
|
9
|
-
var adjustTab,
|
|
10
|
-
ch,
|
|
11
|
-
i,
|
|
12
|
-
initial,
|
|
13
|
-
l,
|
|
14
|
-
lastLineEmpty,
|
|
15
|
-
lines,
|
|
16
|
-
nextLine,
|
|
17
|
-
offset,
|
|
18
|
-
oldBMarks,
|
|
19
|
-
oldBSCount,
|
|
20
|
-
oldIndent,
|
|
21
|
-
oldParentType,
|
|
22
|
-
oldSCount,
|
|
23
|
-
oldTShift,
|
|
24
|
-
spaceAfterMarker,
|
|
25
|
-
terminate,
|
|
26
|
-
terminatorRules,
|
|
27
|
-
token,
|
|
28
|
-
isOutdented,
|
|
29
|
-
oldLineMax = state.lineMax,
|
|
30
|
-
pos = state.bMarks[startLine] + state.tShift[startLine],
|
|
31
|
-
max = state.eMarks[startLine];
|
|
32
|
-
|
|
33
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
34
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
35
|
-
|
|
36
|
-
// check the block quote marker
|
|
37
|
-
if (state.src.charCodeAt(pos) !== 0x3E/* > */) { return false; }
|
|
38
|
-
|
|
39
|
-
// we know that it's going to be a valid blockquote,
|
|
40
|
-
// so no point trying to find the end of it in silent mode
|
|
41
|
-
if (silent) { return true; }
|
|
42
|
-
|
|
43
|
-
oldBMarks = [];
|
|
44
|
-
oldBSCount = [];
|
|
45
|
-
oldSCount = [];
|
|
46
|
-
oldTShift = [];
|
|
47
|
-
|
|
48
|
-
terminatorRules = state.md.block.ruler.getRules('blockquote');
|
|
49
|
-
|
|
50
|
-
oldParentType = state.parentType;
|
|
51
|
-
state.parentType = 'blockquote';
|
|
52
|
-
|
|
53
|
-
// Search the end of the block
|
|
54
|
-
//
|
|
55
|
-
// Block ends with either:
|
|
56
|
-
// 1. an empty line outside:
|
|
57
|
-
// ```
|
|
58
|
-
// > test
|
|
59
|
-
//
|
|
60
|
-
// ```
|
|
61
|
-
// 2. an empty line inside:
|
|
62
|
-
// ```
|
|
63
|
-
// >
|
|
64
|
-
// test
|
|
65
|
-
// ```
|
|
66
|
-
// 3. another tag:
|
|
67
|
-
// ```
|
|
68
|
-
// > test
|
|
69
|
-
// - - -
|
|
70
|
-
// ```
|
|
71
|
-
for (nextLine = startLine; nextLine < endLine; nextLine++) {
|
|
72
|
-
// check if it's outdented, i.e. it's inside list item and indented
|
|
73
|
-
// less than said list item:
|
|
74
|
-
//
|
|
75
|
-
// ```
|
|
76
|
-
// 1. anything
|
|
77
|
-
// > current blockquote
|
|
78
|
-
// 2. checking this line
|
|
79
|
-
// ```
|
|
80
|
-
isOutdented = state.sCount[nextLine] < state.blkIndent;
|
|
81
|
-
|
|
82
|
-
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
83
|
-
max = state.eMarks[nextLine];
|
|
84
|
-
|
|
85
|
-
if (pos >= max) {
|
|
86
|
-
// Case 1: line is not inside the blockquote, and this line is empty.
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) {
|
|
91
|
-
// This line is inside the blockquote.
|
|
92
|
-
|
|
93
|
-
// set offset past spaces and ">"
|
|
94
|
-
initial = state.sCount[nextLine] + 1;
|
|
95
|
-
|
|
96
|
-
// skip one optional space after '>'
|
|
97
|
-
if (state.src.charCodeAt(pos) === 0x20 /* space */) {
|
|
98
|
-
// ' > test '
|
|
99
|
-
// ^ -- position start of line here:
|
|
100
|
-
pos++;
|
|
101
|
-
initial++;
|
|
102
|
-
adjustTab = false;
|
|
103
|
-
spaceAfterMarker = true;
|
|
104
|
-
} else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
|
|
105
|
-
spaceAfterMarker = true;
|
|
106
|
-
|
|
107
|
-
if ((state.bsCount[nextLine] + initial) % 4 === 3) {
|
|
108
|
-
// ' >\t test '
|
|
109
|
-
// ^ -- position start of line here (tab has width===1)
|
|
110
|
-
pos++;
|
|
111
|
-
initial++;
|
|
112
|
-
adjustTab = false;
|
|
113
|
-
} else {
|
|
114
|
-
// ' >\t test '
|
|
115
|
-
// ^ -- position start of line here + shift bsCount slightly
|
|
116
|
-
// to make extra space appear
|
|
117
|
-
adjustTab = true;
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
spaceAfterMarker = false;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
offset = initial;
|
|
124
|
-
oldBMarks.push(state.bMarks[nextLine]);
|
|
125
|
-
state.bMarks[nextLine] = pos;
|
|
126
|
-
|
|
127
|
-
while (pos < max) {
|
|
128
|
-
ch = state.src.charCodeAt(pos);
|
|
129
|
-
|
|
130
|
-
if (isSpace(ch)) {
|
|
131
|
-
if (ch === 0x09) {
|
|
132
|
-
offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
|
|
133
|
-
} else {
|
|
134
|
-
offset++;
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
pos++;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
lastLineEmpty = pos >= max;
|
|
144
|
-
|
|
145
|
-
oldBSCount.push(state.bsCount[nextLine]);
|
|
146
|
-
state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
|
|
147
|
-
|
|
148
|
-
oldSCount.push(state.sCount[nextLine]);
|
|
149
|
-
state.sCount[nextLine] = offset - initial;
|
|
150
|
-
|
|
151
|
-
oldTShift.push(state.tShift[nextLine]);
|
|
152
|
-
state.tShift[nextLine] = pos - state.bMarks[nextLine];
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Case 2: line is not inside the blockquote, and the last line was empty.
|
|
157
|
-
if (lastLineEmpty) { break; }
|
|
158
|
-
|
|
159
|
-
// Case 3: another tag found.
|
|
160
|
-
terminate = false;
|
|
161
|
-
for (i = 0, l = terminatorRules.length; i < l; i++) {
|
|
162
|
-
if (terminatorRules[i](state, nextLine, endLine, true)) {
|
|
163
|
-
terminate = true;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (terminate) {
|
|
169
|
-
// Quirk to enforce "hard termination mode" for paragraphs;
|
|
170
|
-
// normally if you call `tokenize(state, startLine, nextLine)`,
|
|
171
|
-
// paragraphs will look below nextLine for paragraph continuation,
|
|
172
|
-
// but if blockquote is terminated by another tag, they shouldn't
|
|
173
|
-
state.lineMax = nextLine;
|
|
174
|
-
|
|
175
|
-
if (state.blkIndent !== 0) {
|
|
176
|
-
// state.blkIndent was non-zero, we now set it to zero,
|
|
177
|
-
// so we need to re-calculate all offsets to appear as
|
|
178
|
-
// if indent wasn't changed
|
|
179
|
-
oldBMarks.push(state.bMarks[nextLine]);
|
|
180
|
-
oldBSCount.push(state.bsCount[nextLine]);
|
|
181
|
-
oldTShift.push(state.tShift[nextLine]);
|
|
182
|
-
oldSCount.push(state.sCount[nextLine]);
|
|
183
|
-
state.sCount[nextLine] -= state.blkIndent;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
oldBMarks.push(state.bMarks[nextLine]);
|
|
190
|
-
oldBSCount.push(state.bsCount[nextLine]);
|
|
191
|
-
oldTShift.push(state.tShift[nextLine]);
|
|
192
|
-
oldSCount.push(state.sCount[nextLine]);
|
|
193
|
-
|
|
194
|
-
// A negative indentation means that this is a paragraph continuation
|
|
195
|
-
//
|
|
196
|
-
state.sCount[nextLine] = -1;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
oldIndent = state.blkIndent;
|
|
200
|
-
state.blkIndent = 0;
|
|
201
|
-
|
|
202
|
-
token = state.push('blockquote_open', 'blockquote', 1);
|
|
203
|
-
token.markup = '>';
|
|
204
|
-
token.map = lines = [ startLine, 0 ];
|
|
205
|
-
|
|
206
|
-
state.md.block.tokenize(state, startLine, nextLine);
|
|
207
|
-
|
|
208
|
-
token = state.push('blockquote_close', 'blockquote', -1);
|
|
209
|
-
token.markup = '>';
|
|
210
|
-
|
|
211
|
-
state.lineMax = oldLineMax;
|
|
212
|
-
state.parentType = oldParentType;
|
|
213
|
-
lines[1] = state.line;
|
|
214
|
-
|
|
215
|
-
// Restore original tShift; this might not be necessary since the parser
|
|
216
|
-
// has already been here, but just to make sure we can do that.
|
|
217
|
-
for (i = 0; i < oldTShift.length; i++) {
|
|
218
|
-
state.bMarks[i + startLine] = oldBMarks[i];
|
|
219
|
-
state.tShift[i + startLine] = oldTShift[i];
|
|
220
|
-
state.sCount[i + startLine] = oldSCount[i];
|
|
221
|
-
state.bsCount[i + startLine] = oldBSCount[i];
|
|
222
|
-
}
|
|
223
|
-
state.blkIndent = oldIndent;
|
|
224
|
-
|
|
225
|
-
return true;
|
|
226
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Code block (4 spaces padded)
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = function code(state, startLine, endLine/*, silent*/) {
|
|
7
|
-
var nextLine, last, token;
|
|
8
|
-
|
|
9
|
-
if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
|
|
10
|
-
|
|
11
|
-
last = nextLine = startLine + 1;
|
|
12
|
-
|
|
13
|
-
while (nextLine < endLine) {
|
|
14
|
-
if (state.isEmpty(nextLine)) {
|
|
15
|
-
nextLine++;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (state.sCount[nextLine] - state.blkIndent >= 4) {
|
|
20
|
-
nextLine++;
|
|
21
|
-
last = nextLine;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
state.line = last;
|
|
28
|
-
|
|
29
|
-
token = state.push('code_block', 'code', 0);
|
|
30
|
-
token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n';
|
|
31
|
-
token.map = [ startLine, state.line ];
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// fences (``` lang, ~~~ lang)
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = function fence(state, startLine, endLine, silent) {
|
|
7
|
-
var marker, len, params, nextLine, mem, token, markup,
|
|
8
|
-
haveEndMarker = false,
|
|
9
|
-
pos = state.bMarks[startLine] + state.tShift[startLine],
|
|
10
|
-
max = state.eMarks[startLine];
|
|
11
|
-
|
|
12
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
13
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
14
|
-
|
|
15
|
-
if (pos + 3 > max) { return false; }
|
|
16
|
-
|
|
17
|
-
marker = state.src.charCodeAt(pos);
|
|
18
|
-
|
|
19
|
-
if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// scan marker length
|
|
24
|
-
mem = pos;
|
|
25
|
-
pos = state.skipChars(pos, marker);
|
|
26
|
-
|
|
27
|
-
len = pos - mem;
|
|
28
|
-
|
|
29
|
-
if (len < 3) { return false; }
|
|
30
|
-
|
|
31
|
-
markup = state.src.slice(mem, pos);
|
|
32
|
-
params = state.src.slice(pos, max);
|
|
33
|
-
|
|
34
|
-
if (marker === 0x60 /* ` */) {
|
|
35
|
-
if (params.indexOf(String.fromCharCode(marker)) >= 0) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Since start is found, we can report success here in validation mode
|
|
41
|
-
if (silent) { return true; }
|
|
42
|
-
|
|
43
|
-
// search end of block
|
|
44
|
-
nextLine = startLine;
|
|
45
|
-
|
|
46
|
-
for (;;) {
|
|
47
|
-
nextLine++;
|
|
48
|
-
if (nextLine >= endLine) {
|
|
49
|
-
// unclosed block should be autoclosed by end of document.
|
|
50
|
-
// also block seems to be autoclosed by end of parent
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
55
|
-
max = state.eMarks[nextLine];
|
|
56
|
-
|
|
57
|
-
if (pos < max && state.sCount[nextLine] < state.blkIndent) {
|
|
58
|
-
// non-empty line with negative indent should stop the list:
|
|
59
|
-
// - ```
|
|
60
|
-
// test
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (state.src.charCodeAt(pos) !== marker) { continue; }
|
|
65
|
-
|
|
66
|
-
if (state.sCount[nextLine] - state.blkIndent >= 4) {
|
|
67
|
-
// closing fence should be indented less than 4 spaces
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
pos = state.skipChars(pos, marker);
|
|
72
|
-
|
|
73
|
-
// closing code fence must be at least as long as the opening one
|
|
74
|
-
if (pos - mem < len) { continue; }
|
|
75
|
-
|
|
76
|
-
// make sure tail has spaces only
|
|
77
|
-
pos = state.skipSpaces(pos);
|
|
78
|
-
|
|
79
|
-
if (pos < max) { continue; }
|
|
80
|
-
|
|
81
|
-
haveEndMarker = true;
|
|
82
|
-
// found!
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// If a fence has heading spaces, they should be removed from its inner block
|
|
87
|
-
len = state.sCount[startLine];
|
|
88
|
-
|
|
89
|
-
state.line = nextLine + (haveEndMarker ? 1 : 0);
|
|
90
|
-
|
|
91
|
-
token = state.push('fence', 'code', 0);
|
|
92
|
-
token.info = params;
|
|
93
|
-
token.content = state.getLines(startLine + 1, nextLine, len, true);
|
|
94
|
-
token.markup = markup;
|
|
95
|
-
token.map = [ startLine, state.line ];
|
|
96
|
-
|
|
97
|
-
return true;
|
|
98
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// heading (#, ##, ...)
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var isSpace = require('../common/utils').isSpace;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = function heading(state, startLine, endLine, silent) {
|
|
9
|
-
var ch, level, tmp, token,
|
|
10
|
-
pos = state.bMarks[startLine] + state.tShift[startLine],
|
|
11
|
-
max = state.eMarks[startLine];
|
|
12
|
-
|
|
13
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
14
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
15
|
-
|
|
16
|
-
ch = state.src.charCodeAt(pos);
|
|
17
|
-
|
|
18
|
-
if (ch !== 0x23/* # */ || pos >= max) { return false; }
|
|
19
|
-
|
|
20
|
-
// count heading level
|
|
21
|
-
level = 1;
|
|
22
|
-
ch = state.src.charCodeAt(++pos);
|
|
23
|
-
while (ch === 0x23/* # */ && pos < max && level <= 6) {
|
|
24
|
-
level++;
|
|
25
|
-
ch = state.src.charCodeAt(++pos);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (level > 6 || (pos < max && !isSpace(ch))) { return false; }
|
|
29
|
-
|
|
30
|
-
if (silent) { return true; }
|
|
31
|
-
|
|
32
|
-
// Let's cut tails like ' ### ' from the end of string
|
|
33
|
-
|
|
34
|
-
max = state.skipSpacesBack(max, pos);
|
|
35
|
-
tmp = state.skipCharsBack(max, 0x23, pos); // #
|
|
36
|
-
if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {
|
|
37
|
-
max = tmp;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
state.line = startLine + 1;
|
|
41
|
-
|
|
42
|
-
token = state.push('heading_open', 'h' + String(level), 1);
|
|
43
|
-
token.markup = '########'.slice(0, level);
|
|
44
|
-
token.map = [ startLine, state.line ];
|
|
45
|
-
|
|
46
|
-
token = state.push('inline', '', 0);
|
|
47
|
-
token.content = state.src.slice(pos, max).trim();
|
|
48
|
-
token.map = [ startLine, state.line ];
|
|
49
|
-
token.children = [];
|
|
50
|
-
|
|
51
|
-
token = state.push('heading_close', 'h' + String(level), -1);
|
|
52
|
-
token.markup = '########'.slice(0, level);
|
|
53
|
-
|
|
54
|
-
return true;
|
|
55
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Horizontal rule
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var isSpace = require('../common/utils').isSpace;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = function hr(state, startLine, endLine, silent) {
|
|
9
|
-
var marker, cnt, ch, token,
|
|
10
|
-
pos = state.bMarks[startLine] + state.tShift[startLine],
|
|
11
|
-
max = state.eMarks[startLine];
|
|
12
|
-
|
|
13
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
14
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
15
|
-
|
|
16
|
-
marker = state.src.charCodeAt(pos++);
|
|
17
|
-
|
|
18
|
-
// Check hr marker
|
|
19
|
-
if (marker !== 0x2A/* * */ &&
|
|
20
|
-
marker !== 0x2D/* - */ &&
|
|
21
|
-
marker !== 0x5F/* _ */) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// markers can be mixed with spaces, but there should be at least 3 of them
|
|
26
|
-
|
|
27
|
-
cnt = 1;
|
|
28
|
-
while (pos < max) {
|
|
29
|
-
ch = state.src.charCodeAt(pos++);
|
|
30
|
-
if (ch !== marker && !isSpace(ch)) { return false; }
|
|
31
|
-
if (ch === marker) { cnt++; }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (cnt < 3) { return false; }
|
|
35
|
-
|
|
36
|
-
if (silent) { return true; }
|
|
37
|
-
|
|
38
|
-
state.line = startLine + 1;
|
|
39
|
-
|
|
40
|
-
token = state.push('hr', 'hr', 0);
|
|
41
|
-
token.map = [ startLine, state.line ];
|
|
42
|
-
token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
|
|
43
|
-
|
|
44
|
-
return true;
|
|
45
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// HTML block
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var block_names = require('../common/html_blocks');
|
|
7
|
-
var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE;
|
|
8
|
-
|
|
9
|
-
// An array of opening and corresponding closing sequences for html tags,
|
|
10
|
-
// last argument defines whether it can terminate a paragraph or not
|
|
11
|
-
//
|
|
12
|
-
var HTML_SEQUENCES = [
|
|
13
|
-
[ /^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true ],
|
|
14
|
-
[ /^<!--/, /-->/, true ],
|
|
15
|
-
[ /^<\?/, /\?>/, true ],
|
|
16
|
-
[ /^<![A-Z]/, />/, true ],
|
|
17
|
-
[ /^<!\[CDATA\[/, /\]\]>/, true ],
|
|
18
|
-
[ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],
|
|
19
|
-
[ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
module.exports = function html_block(state, startLine, endLine, silent) {
|
|
24
|
-
var i, nextLine, token, lineText,
|
|
25
|
-
pos = state.bMarks[startLine] + state.tShift[startLine],
|
|
26
|
-
max = state.eMarks[startLine];
|
|
27
|
-
|
|
28
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
29
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
30
|
-
|
|
31
|
-
if (!state.md.options.html) { return false; }
|
|
32
|
-
|
|
33
|
-
if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
|
|
34
|
-
|
|
35
|
-
lineText = state.src.slice(pos, max);
|
|
36
|
-
|
|
37
|
-
for (i = 0; i < HTML_SEQUENCES.length; i++) {
|
|
38
|
-
if (HTML_SEQUENCES[i][0].test(lineText)) { break; }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (i === HTML_SEQUENCES.length) { return false; }
|
|
42
|
-
|
|
43
|
-
if (silent) {
|
|
44
|
-
// true if this sequence can be a terminator, false otherwise
|
|
45
|
-
return HTML_SEQUENCES[i][2];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
nextLine = startLine + 1;
|
|
49
|
-
|
|
50
|
-
// If we are here - we detected HTML block.
|
|
51
|
-
// Let's roll down till block end.
|
|
52
|
-
if (!HTML_SEQUENCES[i][1].test(lineText)) {
|
|
53
|
-
for (; nextLine < endLine; nextLine++) {
|
|
54
|
-
if (state.sCount[nextLine] < state.blkIndent) { break; }
|
|
55
|
-
|
|
56
|
-
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
57
|
-
max = state.eMarks[nextLine];
|
|
58
|
-
lineText = state.src.slice(pos, max);
|
|
59
|
-
|
|
60
|
-
if (HTML_SEQUENCES[i][1].test(lineText)) {
|
|
61
|
-
if (lineText.length !== 0) { nextLine++; }
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
state.line = nextLine;
|
|
68
|
-
|
|
69
|
-
token = state.push('html_block', '', 0);
|
|
70
|
-
token.map = [ startLine, nextLine ];
|
|
71
|
-
token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
|
|
72
|
-
|
|
73
|
-
return true;
|
|
74
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// lheading (---, ===)
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = function lheading(state, startLine, endLine/*, silent*/) {
|
|
7
|
-
var content, terminate, i, l, token, pos, max, level, marker,
|
|
8
|
-
nextLine = startLine + 1, oldParentType,
|
|
9
|
-
terminatorRules = state.md.block.ruler.getRules('paragraph');
|
|
10
|
-
|
|
11
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
12
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
|
|
13
|
-
|
|
14
|
-
oldParentType = state.parentType;
|
|
15
|
-
state.parentType = 'paragraph'; // use paragraph to match terminatorRules
|
|
16
|
-
|
|
17
|
-
// jump line-by-line until empty one or EOF
|
|
18
|
-
for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
|
|
19
|
-
// this would be a code block normally, but after paragraph
|
|
20
|
-
// it's considered a lazy continuation regardless of what's there
|
|
21
|
-
if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
// Check for underline in setext header
|
|
25
|
-
//
|
|
26
|
-
if (state.sCount[nextLine] >= state.blkIndent) {
|
|
27
|
-
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
28
|
-
max = state.eMarks[nextLine];
|
|
29
|
-
|
|
30
|
-
if (pos < max) {
|
|
31
|
-
marker = state.src.charCodeAt(pos);
|
|
32
|
-
|
|
33
|
-
if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {
|
|
34
|
-
pos = state.skipChars(pos, marker);
|
|
35
|
-
pos = state.skipSpaces(pos);
|
|
36
|
-
|
|
37
|
-
if (pos >= max) {
|
|
38
|
-
level = (marker === 0x3D/* = */ ? 1 : 2);
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// quirk for blockquotes, this line should already be checked by that rule
|
|
46
|
-
if (state.sCount[nextLine] < 0) { continue; }
|
|
47
|
-
|
|
48
|
-
// Some tags can terminate paragraph without empty line.
|
|
49
|
-
terminate = false;
|
|
50
|
-
for (i = 0, l = terminatorRules.length; i < l; i++) {
|
|
51
|
-
if (terminatorRules[i](state, nextLine, endLine, true)) {
|
|
52
|
-
terminate = true;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (terminate) { break; }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!level) {
|
|
60
|
-
// Didn't find valid underline
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
|
|
65
|
-
|
|
66
|
-
state.line = nextLine + 1;
|
|
67
|
-
|
|
68
|
-
token = state.push('heading_open', 'h' + String(level), 1);
|
|
69
|
-
token.markup = String.fromCharCode(marker);
|
|
70
|
-
token.map = [ startLine, state.line ];
|
|
71
|
-
|
|
72
|
-
token = state.push('inline', '', 0);
|
|
73
|
-
token.content = content;
|
|
74
|
-
token.map = [ startLine, state.line - 1 ];
|
|
75
|
-
token.children = [];
|
|
76
|
-
|
|
77
|
-
token = state.push('heading_close', 'h' + String(level), -1);
|
|
78
|
-
token.markup = String.fromCharCode(marker);
|
|
79
|
-
|
|
80
|
-
state.parentType = oldParentType;
|
|
81
|
-
|
|
82
|
-
return true;
|
|
83
|
-
};
|