@alexlit/lint-kit 107.1.0 → 107.2.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.
Files changed (187) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +4 -4
  3. package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +22 -0
  4. package/packages/config-markdownlint/node_modules/markdown-it/README.md +309 -0
  5. package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +117 -0
  6. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +8441 -0
  7. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +3 -0
  8. package/packages/config-markdownlint/node_modules/markdown-it/index.js +4 -0
  9. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +6 -0
  10. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +70 -0
  11. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +28 -0
  12. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +317 -0
  13. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +7 -0
  14. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +80 -0
  15. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +48 -0
  16. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +55 -0
  17. package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +582 -0
  18. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +131 -0
  19. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +61 -0
  20. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +192 -0
  21. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +81 -0
  22. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +41 -0
  23. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +63 -0
  24. package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +341 -0
  25. package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +352 -0
  26. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +226 -0
  27. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +34 -0
  28. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +98 -0
  29. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +55 -0
  30. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +45 -0
  31. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +74 -0
  32. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +83 -0
  33. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +362 -0
  34. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +51 -0
  35. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +198 -0
  36. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +231 -0
  37. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +221 -0
  38. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +16 -0
  39. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +13 -0
  40. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +142 -0
  41. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +21 -0
  42. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +105 -0
  43. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +201 -0
  44. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +20 -0
  45. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +45 -0
  46. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +76 -0
  47. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +63 -0
  48. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +130 -0
  49. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +130 -0
  50. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +55 -0
  51. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +71 -0
  52. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +41 -0
  53. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +58 -0
  54. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +152 -0
  55. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +150 -0
  56. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +62 -0
  57. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +46 -0
  58. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +158 -0
  59. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +130 -0
  60. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +89 -0
  61. package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +201 -0
  62. package/packages/config-markdownlint/node_modules/markdown-it/package.json +87 -0
  63. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +428 -0
  64. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +92 -0
  65. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +21 -0
  66. package/packages/config-markdownlint/node_modules/markdownlint/README.md +1026 -0
  67. package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +6814 -0
  68. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +376 -0
  69. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +27 -0
  70. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +20 -0
  71. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +2335 -0
  72. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +37 -0
  73. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +59 -0
  74. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +49 -0
  75. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +53 -0
  76. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +52 -0
  77. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +51 -0
  78. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +56 -0
  79. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +30 -0
  80. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +38 -0
  81. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +57 -0
  82. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +54 -0
  83. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +27 -0
  84. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +28 -0
  85. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +29 -0
  86. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +31 -0
  87. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +52 -0
  88. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +33 -0
  89. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +47 -0
  90. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +49 -0
  91. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +40 -0
  92. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +24 -0
  93. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +40 -0
  94. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +98 -0
  95. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +82 -0
  96. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +50 -0
  97. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +55 -0
  98. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +27 -0
  99. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +50 -0
  100. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +42 -0
  101. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +45 -0
  102. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +37 -0
  103. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +40 -0
  104. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +21 -0
  105. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +52 -0
  106. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +49 -0
  107. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +32 -0
  108. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +69 -0
  109. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +35 -0
  110. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +40 -0
  111. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +40 -0
  112. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +34 -0
  113. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +41 -0
  114. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +32 -0
  115. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +32 -0
  116. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +61 -0
  117. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +40 -0
  118. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +38 -0
  119. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +100 -0
  120. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +21 -0
  121. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +70 -0
  122. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +1025 -0
  123. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +426 -0
  124. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +26 -0
  125. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +10 -0
  126. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +21 -0
  127. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +1152 -0
  128. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +14 -0
  129. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +406 -0
  130. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +1476 -0
  131. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +22 -0
  132. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +42 -0
  133. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +76 -0
  134. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +73 -0
  135. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +86 -0
  136. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +86 -0
  137. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +60 -0
  138. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +46 -0
  139. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +32 -0
  140. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +96 -0
  141. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +53 -0
  142. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +34 -0
  143. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +39 -0
  144. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +62 -0
  145. package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +62 -0
  146. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +108 -0
  147. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +38 -0
  148. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +38 -0
  149. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +32 -0
  150. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +50 -0
  151. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +56 -0
  152. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +30 -0
  153. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +67 -0
  154. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +61 -0
  155. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +40 -0
  156. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +78 -0
  157. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +39 -0
  158. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +79 -0
  159. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +24 -0
  160. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +56 -0
  161. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +91 -0
  162. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +97 -0
  163. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +67 -0
  164. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +37 -0
  165. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +42 -0
  166. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +49 -0
  167. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +64 -0
  168. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +107 -0
  169. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +60 -0
  170. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +33 -0
  171. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +28 -0
  172. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +30 -0
  173. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +89 -0
  174. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +172 -0
  175. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +39 -0
  176. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +59 -0
  177. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +125 -0
  178. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +65 -0
  179. package/packages/config-markdownlint/node_modules/markdownlint/package.json +109 -0
  180. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +297 -0
  181. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +266 -0
  182. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +1762 -0
  183. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +5 -0
  184. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +22 -0
  185. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +26 -0
  186. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +12 -0
  187. package/packages/config-markdownlint/package.json +3 -3
@@ -0,0 +1,362 @@
1
+ // Lists
2
+
3
+ 'use strict';
4
+
5
+ var isSpace = require('../common/utils').isSpace;
6
+
7
+
8
+ // Search `[-+*][\n ]`, returns next pos after marker on success
9
+ // or -1 on fail.
10
+ function skipBulletListMarker(state, startLine) {
11
+ var marker, pos, max, ch;
12
+
13
+ pos = state.bMarks[startLine] + state.tShift[startLine];
14
+ max = state.eMarks[startLine];
15
+
16
+ marker = state.src.charCodeAt(pos++);
17
+ // Check bullet
18
+ if (marker !== 0x2A/* * */ &&
19
+ marker !== 0x2D/* - */ &&
20
+ marker !== 0x2B/* + */) {
21
+ return -1;
22
+ }
23
+
24
+ if (pos < max) {
25
+ ch = state.src.charCodeAt(pos);
26
+
27
+ if (!isSpace(ch)) {
28
+ // " -test " - is not a list item
29
+ return -1;
30
+ }
31
+ }
32
+
33
+ return pos;
34
+ }
35
+
36
+ // Search `\d+[.)][\n ]`, returns next pos after marker on success
37
+ // or -1 on fail.
38
+ function skipOrderedListMarker(state, startLine) {
39
+ var ch,
40
+ start = state.bMarks[startLine] + state.tShift[startLine],
41
+ pos = start,
42
+ max = state.eMarks[startLine];
43
+
44
+ // List marker should have at least 2 chars (digit + dot)
45
+ if (pos + 1 >= max) { return -1; }
46
+
47
+ ch = state.src.charCodeAt(pos++);
48
+
49
+ if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
50
+
51
+ for (;;) {
52
+ // EOL -> fail
53
+ if (pos >= max) { return -1; }
54
+
55
+ ch = state.src.charCodeAt(pos++);
56
+
57
+ if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
58
+
59
+ // List marker should have no more than 9 digits
60
+ // (prevents integer overflow in browsers)
61
+ if (pos - start >= 10) { return -1; }
62
+
63
+ continue;
64
+ }
65
+
66
+ // found valid marker
67
+ if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
68
+ break;
69
+ }
70
+
71
+ return -1;
72
+ }
73
+
74
+
75
+ if (pos < max) {
76
+ ch = state.src.charCodeAt(pos);
77
+
78
+ if (!isSpace(ch)) {
79
+ // " 1.test " - is not a list item
80
+ return -1;
81
+ }
82
+ }
83
+ return pos;
84
+ }
85
+
86
+ function markTightParagraphs(state, idx) {
87
+ var i, l,
88
+ level = state.level + 2;
89
+
90
+ for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
91
+ if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
92
+ state.tokens[i + 2].hidden = true;
93
+ state.tokens[i].hidden = true;
94
+ i += 2;
95
+ }
96
+ }
97
+ }
98
+
99
+
100
+ module.exports = function list(state, startLine, endLine, silent) {
101
+ var ch,
102
+ contentStart,
103
+ i,
104
+ indent,
105
+ indentAfterMarker,
106
+ initial,
107
+ isOrdered,
108
+ itemLines,
109
+ l,
110
+ listLines,
111
+ listTokIdx,
112
+ markerCharCode,
113
+ markerValue,
114
+ max,
115
+ offset,
116
+ oldListIndent,
117
+ oldParentType,
118
+ oldSCount,
119
+ oldTShift,
120
+ oldTight,
121
+ pos,
122
+ posAfterMarker,
123
+ prevEmptyEnd,
124
+ start,
125
+ terminate,
126
+ terminatorRules,
127
+ token,
128
+ nextLine = startLine,
129
+ isTerminatingParagraph = false,
130
+ tight = true;
131
+
132
+ // if it's indented more than 3 spaces, it should be a code block
133
+ if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
134
+
135
+ // Special case:
136
+ // - item 1
137
+ // - item 2
138
+ // - item 3
139
+ // - item 4
140
+ // - this one is a paragraph continuation
141
+ if (state.listIndent >= 0 &&
142
+ state.sCount[nextLine] - state.listIndent >= 4 &&
143
+ state.sCount[nextLine] < state.blkIndent) {
144
+ return false;
145
+ }
146
+
147
+ // limit conditions when list can interrupt
148
+ // a paragraph (validation mode only)
149
+ if (silent && state.parentType === 'paragraph') {
150
+ // Next list item should still terminate previous list item;
151
+ //
152
+ // This code can fail if plugins use blkIndent as well as lists,
153
+ // but I hope the spec gets fixed long before that happens.
154
+ //
155
+ if (state.sCount[nextLine] >= state.blkIndent) {
156
+ isTerminatingParagraph = true;
157
+ }
158
+ }
159
+
160
+ // Detect list type and position after marker
161
+ if ((posAfterMarker = skipOrderedListMarker(state, nextLine)) >= 0) {
162
+ isOrdered = true;
163
+ start = state.bMarks[nextLine] + state.tShift[nextLine];
164
+ markerValue = Number(state.src.slice(start, posAfterMarker - 1));
165
+
166
+ // If we're starting a new ordered list right after
167
+ // a paragraph, it should start with 1.
168
+ if (isTerminatingParagraph && markerValue !== 1) return false;
169
+
170
+ } else if ((posAfterMarker = skipBulletListMarker(state, nextLine)) >= 0) {
171
+ isOrdered = false;
172
+
173
+ } else {
174
+ return false;
175
+ }
176
+
177
+ // If we're starting a new unordered list right after
178
+ // a paragraph, first line should not be empty.
179
+ if (isTerminatingParagraph) {
180
+ if (state.skipSpaces(posAfterMarker) >= state.eMarks[nextLine]) return false;
181
+ }
182
+
183
+ // For validation mode we can terminate immediately
184
+ if (silent) { return true; }
185
+
186
+ // We should terminate list on style change. Remember first one to compare.
187
+ markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
188
+
189
+ // Start list
190
+ listTokIdx = state.tokens.length;
191
+
192
+ if (isOrdered) {
193
+ token = state.push('ordered_list_open', 'ol', 1);
194
+ if (markerValue !== 1) {
195
+ token.attrs = [ [ 'start', markerValue ] ];
196
+ }
197
+
198
+ } else {
199
+ token = state.push('bullet_list_open', 'ul', 1);
200
+ }
201
+
202
+ token.map = listLines = [ nextLine, 0 ];
203
+ token.markup = String.fromCharCode(markerCharCode);
204
+
205
+ //
206
+ // Iterate list items
207
+ //
208
+
209
+ prevEmptyEnd = false;
210
+ terminatorRules = state.md.block.ruler.getRules('list');
211
+
212
+ oldParentType = state.parentType;
213
+ state.parentType = 'list';
214
+
215
+ while (nextLine < endLine) {
216
+ pos = posAfterMarker;
217
+ max = state.eMarks[nextLine];
218
+
219
+ initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[nextLine] + state.tShift[nextLine]);
220
+
221
+ while (pos < max) {
222
+ ch = state.src.charCodeAt(pos);
223
+
224
+ if (ch === 0x09) {
225
+ offset += 4 - (offset + state.bsCount[nextLine]) % 4;
226
+ } else if (ch === 0x20) {
227
+ offset++;
228
+ } else {
229
+ break;
230
+ }
231
+
232
+ pos++;
233
+ }
234
+
235
+ contentStart = pos;
236
+
237
+ if (contentStart >= max) {
238
+ // trimming space in "- \n 3" case, indent is 1 here
239
+ indentAfterMarker = 1;
240
+ } else {
241
+ indentAfterMarker = offset - initial;
242
+ }
243
+
244
+ // If we have more than 4 spaces, the indent is 1
245
+ // (the rest is just indented code block)
246
+ if (indentAfterMarker > 4) { indentAfterMarker = 1; }
247
+
248
+ // " - test"
249
+ // ^^^^^ - calculating total length of this thing
250
+ indent = initial + indentAfterMarker;
251
+
252
+ // Run subparser & write tokens
253
+ token = state.push('list_item_open', 'li', 1);
254
+ token.markup = String.fromCharCode(markerCharCode);
255
+ token.map = itemLines = [ nextLine, 0 ];
256
+ if (isOrdered) {
257
+ token.info = state.src.slice(start, posAfterMarker - 1);
258
+ }
259
+
260
+ // change current state, then restore it after parser subcall
261
+ oldTight = state.tight;
262
+ oldTShift = state.tShift[nextLine];
263
+ oldSCount = state.sCount[nextLine];
264
+
265
+ // - example list
266
+ // ^ listIndent position will be here
267
+ // ^ blkIndent position will be here
268
+ //
269
+ oldListIndent = state.listIndent;
270
+ state.listIndent = state.blkIndent;
271
+ state.blkIndent = indent;
272
+
273
+ state.tight = true;
274
+ state.tShift[nextLine] = contentStart - state.bMarks[nextLine];
275
+ state.sCount[nextLine] = offset;
276
+
277
+ if (contentStart >= max && state.isEmpty(nextLine + 1)) {
278
+ // workaround for this case
279
+ // (list item is empty, list terminates before "foo"):
280
+ // ~~~~~~~~
281
+ // -
282
+ //
283
+ // foo
284
+ // ~~~~~~~~
285
+ state.line = Math.min(state.line + 2, endLine);
286
+ } else {
287
+ state.md.block.tokenize(state, nextLine, endLine, true);
288
+ }
289
+
290
+ // If any of list item is tight, mark list as tight
291
+ if (!state.tight || prevEmptyEnd) {
292
+ tight = false;
293
+ }
294
+ // Item become loose if finish with empty line,
295
+ // but we should filter last element, because it means list finish
296
+ prevEmptyEnd = (state.line - nextLine) > 1 && state.isEmpty(state.line - 1);
297
+
298
+ state.blkIndent = state.listIndent;
299
+ state.listIndent = oldListIndent;
300
+ state.tShift[nextLine] = oldTShift;
301
+ state.sCount[nextLine] = oldSCount;
302
+ state.tight = oldTight;
303
+
304
+ token = state.push('list_item_close', 'li', -1);
305
+ token.markup = String.fromCharCode(markerCharCode);
306
+
307
+ nextLine = state.line;
308
+ itemLines[1] = nextLine;
309
+
310
+ if (nextLine >= endLine) { break; }
311
+
312
+ //
313
+ // Try to check if list is terminated or continued.
314
+ //
315
+ if (state.sCount[nextLine] < state.blkIndent) { break; }
316
+
317
+ // if it's indented more than 3 spaces, it should be a code block
318
+ if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
319
+
320
+ // fail if terminating block found
321
+ terminate = false;
322
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
323
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
324
+ terminate = true;
325
+ break;
326
+ }
327
+ }
328
+ if (terminate) { break; }
329
+
330
+ // fail if list has another type
331
+ if (isOrdered) {
332
+ posAfterMarker = skipOrderedListMarker(state, nextLine);
333
+ if (posAfterMarker < 0) { break; }
334
+ start = state.bMarks[nextLine] + state.tShift[nextLine];
335
+ } else {
336
+ posAfterMarker = skipBulletListMarker(state, nextLine);
337
+ if (posAfterMarker < 0) { break; }
338
+ }
339
+
340
+ if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
341
+ }
342
+
343
+ // Finalize list
344
+ if (isOrdered) {
345
+ token = state.push('ordered_list_close', 'ol', -1);
346
+ } else {
347
+ token = state.push('bullet_list_close', 'ul', -1);
348
+ }
349
+ token.markup = String.fromCharCode(markerCharCode);
350
+
351
+ listLines[1] = nextLine;
352
+ state.line = nextLine;
353
+
354
+ state.parentType = oldParentType;
355
+
356
+ // mark paragraphs tight if needed
357
+ if (tight) {
358
+ markTightParagraphs(state, listTokIdx);
359
+ }
360
+
361
+ return true;
362
+ };
@@ -0,0 +1,51 @@
1
+ // Paragraph
2
+
3
+ 'use strict';
4
+
5
+
6
+ module.exports = function paragraph(state, startLine, endLine) {
7
+ var content, terminate, i, l, token, oldParentType,
8
+ nextLine = startLine + 1,
9
+ terminatorRules = state.md.block.ruler.getRules('paragraph');
10
+
11
+ oldParentType = state.parentType;
12
+ state.parentType = 'paragraph';
13
+
14
+ // jump line-by-line until empty one or EOF
15
+ for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
16
+ // this would be a code block normally, but after paragraph
17
+ // it's considered a lazy continuation regardless of what's there
18
+ if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
19
+
20
+ // quirk for blockquotes, this line should already be checked by that rule
21
+ if (state.sCount[nextLine] < 0) { continue; }
22
+
23
+ // Some tags can terminate paragraph without empty line.
24
+ terminate = false;
25
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
26
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
27
+ terminate = true;
28
+ break;
29
+ }
30
+ }
31
+ if (terminate) { break; }
32
+ }
33
+
34
+ content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
35
+
36
+ state.line = nextLine;
37
+
38
+ token = state.push('paragraph_open', 'p', 1);
39
+ token.map = [ startLine, state.line ];
40
+
41
+ token = state.push('inline', '', 0);
42
+ token.content = content;
43
+ token.map = [ startLine, state.line ];
44
+ token.children = [];
45
+
46
+ token = state.push('paragraph_close', 'p', -1);
47
+
48
+ state.parentType = oldParentType;
49
+
50
+ return true;
51
+ };
@@ -0,0 +1,198 @@
1
+ 'use strict';
2
+
3
+
4
+ var normalizeReference = require('../common/utils').normalizeReference;
5
+ var isSpace = require('../common/utils').isSpace;
6
+
7
+
8
+ module.exports = function reference(state, startLine, _endLine, silent) {
9
+ var ch,
10
+ destEndPos,
11
+ destEndLineNo,
12
+ endLine,
13
+ href,
14
+ i,
15
+ l,
16
+ label,
17
+ labelEnd,
18
+ oldParentType,
19
+ res,
20
+ start,
21
+ str,
22
+ terminate,
23
+ terminatorRules,
24
+ title,
25
+ lines = 0,
26
+ pos = state.bMarks[startLine] + state.tShift[startLine],
27
+ max = state.eMarks[startLine],
28
+ nextLine = startLine + 1;
29
+
30
+ // if it's indented more than 3 spaces, it should be a code block
31
+ if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
32
+
33
+ if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }
34
+
35
+ // Simple check to quickly interrupt scan on [link](url) at the start of line.
36
+ // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
37
+ while (++pos < max) {
38
+ if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&
39
+ state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {
40
+ if (pos + 1 === max) { return false; }
41
+ if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }
42
+ break;
43
+ }
44
+ }
45
+
46
+ endLine = state.lineMax;
47
+
48
+ // jump line-by-line until empty one or EOF
49
+ terminatorRules = state.md.block.ruler.getRules('reference');
50
+
51
+ oldParentType = state.parentType;
52
+ state.parentType = 'reference';
53
+
54
+ for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
55
+ // this would be a code block normally, but after paragraph
56
+ // it's considered a lazy continuation regardless of what's there
57
+ if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
58
+
59
+ // quirk for blockquotes, this line should already be checked by that rule
60
+ if (state.sCount[nextLine] < 0) { continue; }
61
+
62
+ // Some tags can terminate paragraph without empty line.
63
+ terminate = false;
64
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
65
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
66
+ terminate = true;
67
+ break;
68
+ }
69
+ }
70
+ if (terminate) { break; }
71
+ }
72
+
73
+ str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
74
+ max = str.length;
75
+
76
+ for (pos = 1; pos < max; pos++) {
77
+ ch = str.charCodeAt(pos);
78
+ if (ch === 0x5B /* [ */) {
79
+ return false;
80
+ } else if (ch === 0x5D /* ] */) {
81
+ labelEnd = pos;
82
+ break;
83
+ } else if (ch === 0x0A /* \n */) {
84
+ lines++;
85
+ } else if (ch === 0x5C /* \ */) {
86
+ pos++;
87
+ if (pos < max && str.charCodeAt(pos) === 0x0A) {
88
+ lines++;
89
+ }
90
+ }
91
+ }
92
+
93
+ if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }
94
+
95
+ // [label]: destination 'title'
96
+ // ^^^ skip optional whitespace here
97
+ for (pos = labelEnd + 2; pos < max; pos++) {
98
+ ch = str.charCodeAt(pos);
99
+ if (ch === 0x0A) {
100
+ lines++;
101
+ } else if (isSpace(ch)) {
102
+ /*eslint no-empty:0*/
103
+ } else {
104
+ break;
105
+ }
106
+ }
107
+
108
+ // [label]: destination 'title'
109
+ // ^^^^^^^^^^^ parse this
110
+ res = state.md.helpers.parseLinkDestination(str, pos, max);
111
+ if (!res.ok) { return false; }
112
+
113
+ href = state.md.normalizeLink(res.str);
114
+ if (!state.md.validateLink(href)) { return false; }
115
+
116
+ pos = res.pos;
117
+ lines += res.lines;
118
+
119
+ // save cursor state, we could require to rollback later
120
+ destEndPos = pos;
121
+ destEndLineNo = lines;
122
+
123
+ // [label]: destination 'title'
124
+ // ^^^ skipping those spaces
125
+ start = pos;
126
+ for (; pos < max; pos++) {
127
+ ch = str.charCodeAt(pos);
128
+ if (ch === 0x0A) {
129
+ lines++;
130
+ } else if (isSpace(ch)) {
131
+ /*eslint no-empty:0*/
132
+ } else {
133
+ break;
134
+ }
135
+ }
136
+
137
+ // [label]: destination 'title'
138
+ // ^^^^^^^ parse this
139
+ res = state.md.helpers.parseLinkTitle(str, pos, max);
140
+ if (pos < max && start !== pos && res.ok) {
141
+ title = res.str;
142
+ pos = res.pos;
143
+ lines += res.lines;
144
+ } else {
145
+ title = '';
146
+ pos = destEndPos;
147
+ lines = destEndLineNo;
148
+ }
149
+
150
+ // skip trailing spaces until the rest of the line
151
+ while (pos < max) {
152
+ ch = str.charCodeAt(pos);
153
+ if (!isSpace(ch)) { break; }
154
+ pos++;
155
+ }
156
+
157
+ if (pos < max && str.charCodeAt(pos) !== 0x0A) {
158
+ if (title) {
159
+ // garbage at the end of the line after title,
160
+ // but it could still be a valid reference if we roll back
161
+ title = '';
162
+ pos = destEndPos;
163
+ lines = destEndLineNo;
164
+ while (pos < max) {
165
+ ch = str.charCodeAt(pos);
166
+ if (!isSpace(ch)) { break; }
167
+ pos++;
168
+ }
169
+ }
170
+ }
171
+
172
+ if (pos < max && str.charCodeAt(pos) !== 0x0A) {
173
+ // garbage at the end of the line
174
+ return false;
175
+ }
176
+
177
+ label = normalizeReference(str.slice(1, labelEnd));
178
+ if (!label) {
179
+ // CommonMark 0.20 disallows empty labels
180
+ return false;
181
+ }
182
+
183
+ // Reference can not terminate anything. This check is for safety only.
184
+ /*istanbul ignore if*/
185
+ if (silent) { return true; }
186
+
187
+ if (typeof state.env.references === 'undefined') {
188
+ state.env.references = {};
189
+ }
190
+ if (typeof state.env.references[label] === 'undefined') {
191
+ state.env.references[label] = { title: title, href: href };
192
+ }
193
+
194
+ state.parentType = oldParentType;
195
+
196
+ state.line = startLine + lines + 1;
197
+ return true;
198
+ };