@alexlit/lint-kit 107.0.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 (193) hide show
  1. package/package.json +1 -11
  2. package/packages/config-commitlint/package.json +2 -2
  3. package/packages/config-eslint/package.json +4 -4
  4. package/packages/config-hooks/package.json +3 -3
  5. package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +22 -0
  6. package/packages/config-markdownlint/node_modules/markdown-it/README.md +309 -0
  7. package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +117 -0
  8. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +8441 -0
  9. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +3 -0
  10. package/packages/config-markdownlint/node_modules/markdown-it/index.js +4 -0
  11. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +6 -0
  12. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +70 -0
  13. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +28 -0
  14. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +317 -0
  15. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +7 -0
  16. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +80 -0
  17. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +48 -0
  18. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +55 -0
  19. package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +582 -0
  20. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +131 -0
  21. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +61 -0
  22. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +192 -0
  23. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +81 -0
  24. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +41 -0
  25. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +63 -0
  26. package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +341 -0
  27. package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +352 -0
  28. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +226 -0
  29. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +34 -0
  30. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +98 -0
  31. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +55 -0
  32. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +45 -0
  33. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +74 -0
  34. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +83 -0
  35. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +362 -0
  36. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +51 -0
  37. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +198 -0
  38. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +231 -0
  39. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +221 -0
  40. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +16 -0
  41. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +13 -0
  42. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +142 -0
  43. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +21 -0
  44. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +105 -0
  45. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +201 -0
  46. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +20 -0
  47. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +45 -0
  48. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +76 -0
  49. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +63 -0
  50. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +130 -0
  51. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +130 -0
  52. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +55 -0
  53. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +71 -0
  54. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +41 -0
  55. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +58 -0
  56. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +152 -0
  57. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +150 -0
  58. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +62 -0
  59. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +46 -0
  60. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +158 -0
  61. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +130 -0
  62. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +89 -0
  63. package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +201 -0
  64. package/packages/config-markdownlint/node_modules/markdown-it/package.json +87 -0
  65. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +428 -0
  66. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +92 -0
  67. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +21 -0
  68. package/packages/config-markdownlint/node_modules/markdownlint/README.md +1026 -0
  69. package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +6814 -0
  70. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +376 -0
  71. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +27 -0
  72. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +20 -0
  73. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +2335 -0
  74. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +37 -0
  75. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +59 -0
  76. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +49 -0
  77. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +53 -0
  78. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +52 -0
  79. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +51 -0
  80. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +56 -0
  81. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +30 -0
  82. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +38 -0
  83. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +57 -0
  84. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +54 -0
  85. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +27 -0
  86. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +28 -0
  87. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +29 -0
  88. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +31 -0
  89. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +52 -0
  90. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +33 -0
  91. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +47 -0
  92. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +49 -0
  93. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +40 -0
  94. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +24 -0
  95. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +40 -0
  96. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +98 -0
  97. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +82 -0
  98. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +50 -0
  99. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +55 -0
  100. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +27 -0
  101. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +50 -0
  102. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +42 -0
  103. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +45 -0
  104. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +37 -0
  105. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +40 -0
  106. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +21 -0
  107. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +52 -0
  108. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +49 -0
  109. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +32 -0
  110. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +69 -0
  111. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +35 -0
  112. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +40 -0
  113. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +40 -0
  114. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +34 -0
  115. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +41 -0
  116. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +32 -0
  117. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +32 -0
  118. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +61 -0
  119. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +40 -0
  120. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +38 -0
  121. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +100 -0
  122. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +21 -0
  123. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +70 -0
  124. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +1025 -0
  125. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +426 -0
  126. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +26 -0
  127. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +10 -0
  128. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +21 -0
  129. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +1152 -0
  130. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +14 -0
  131. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +406 -0
  132. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +1476 -0
  133. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +22 -0
  134. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +42 -0
  135. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +76 -0
  136. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +73 -0
  137. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +86 -0
  138. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +86 -0
  139. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +60 -0
  140. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +46 -0
  141. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +32 -0
  142. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +96 -0
  143. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +53 -0
  144. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +34 -0
  145. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +39 -0
  146. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +62 -0
  147. package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +62 -0
  148. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +108 -0
  149. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +38 -0
  150. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +38 -0
  151. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +32 -0
  152. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +50 -0
  153. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +56 -0
  154. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +30 -0
  155. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +67 -0
  156. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +61 -0
  157. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +40 -0
  158. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +78 -0
  159. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +39 -0
  160. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +79 -0
  161. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +24 -0
  162. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +56 -0
  163. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +91 -0
  164. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +97 -0
  165. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +67 -0
  166. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +37 -0
  167. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +42 -0
  168. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +49 -0
  169. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +64 -0
  170. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +107 -0
  171. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +60 -0
  172. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +33 -0
  173. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +28 -0
  174. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +30 -0
  175. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +89 -0
  176. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +172 -0
  177. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +39 -0
  178. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +59 -0
  179. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +125 -0
  180. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +65 -0
  181. package/packages/config-markdownlint/node_modules/markdownlint/package.json +109 -0
  182. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +297 -0
  183. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +266 -0
  184. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +1762 -0
  185. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +5 -0
  186. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +22 -0
  187. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +26 -0
  188. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +12 -0
  189. package/packages/config-markdownlint/package.json +3 -3
  190. package/packages/config-prettier/README.md +16 -0
  191. package/packages/config-prettier/package.json +4 -4
  192. package/packages/config-stylelint/package.json +2 -2
  193. package/scripts/semver.sh +6 -5
@@ -0,0 +1,130 @@
1
+ // Process *this* and _that_
2
+ //
3
+ 'use strict';
4
+
5
+
6
+ // Insert each marker as a separate text token, and add it to delimiter list
7
+ //
8
+ module.exports.tokenize = function emphasis(state, silent) {
9
+ var i, scanned, token,
10
+ start = state.pos,
11
+ marker = state.src.charCodeAt(start);
12
+
13
+ if (silent) { return false; }
14
+
15
+ if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }
16
+
17
+ scanned = state.scanDelims(state.pos, marker === 0x2A);
18
+
19
+ for (i = 0; i < scanned.length; i++) {
20
+ token = state.push('text', '', 0);
21
+ token.content = String.fromCharCode(marker);
22
+
23
+ state.delimiters.push({
24
+ // Char code of the starting marker (number).
25
+ //
26
+ marker: marker,
27
+
28
+ // Total length of these series of delimiters.
29
+ //
30
+ length: scanned.length,
31
+
32
+ // A position of the token this delimiter corresponds to.
33
+ //
34
+ token: state.tokens.length - 1,
35
+
36
+ // If this delimiter is matched as a valid opener, `end` will be
37
+ // equal to its position, otherwise it's `-1`.
38
+ //
39
+ end: -1,
40
+
41
+ // Boolean flags that determine if this delimiter could open or close
42
+ // an emphasis.
43
+ //
44
+ open: scanned.can_open,
45
+ close: scanned.can_close
46
+ });
47
+ }
48
+
49
+ state.pos += scanned.length;
50
+
51
+ return true;
52
+ };
53
+
54
+
55
+ function postProcess(state, delimiters) {
56
+ var i,
57
+ startDelim,
58
+ endDelim,
59
+ token,
60
+ ch,
61
+ isStrong,
62
+ max = delimiters.length;
63
+
64
+ for (i = max - 1; i >= 0; i--) {
65
+ startDelim = delimiters[i];
66
+
67
+ if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {
68
+ continue;
69
+ }
70
+
71
+ // Process only opening markers
72
+ if (startDelim.end === -1) {
73
+ continue;
74
+ }
75
+
76
+ endDelim = delimiters[startDelim.end];
77
+
78
+ // If the previous delimiter has the same marker and is adjacent to this one,
79
+ // merge those into one strong delimiter.
80
+ //
81
+ // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
82
+ //
83
+ isStrong = i > 0 &&
84
+ delimiters[i - 1].end === startDelim.end + 1 &&
85
+ // check that first two markers match and adjacent
86
+ delimiters[i - 1].marker === startDelim.marker &&
87
+ delimiters[i - 1].token === startDelim.token - 1 &&
88
+ // check that last two markers are adjacent (we can safely assume they match)
89
+ delimiters[startDelim.end + 1].token === endDelim.token + 1;
90
+
91
+ ch = String.fromCharCode(startDelim.marker);
92
+
93
+ token = state.tokens[startDelim.token];
94
+ token.type = isStrong ? 'strong_open' : 'em_open';
95
+ token.tag = isStrong ? 'strong' : 'em';
96
+ token.nesting = 1;
97
+ token.markup = isStrong ? ch + ch : ch;
98
+ token.content = '';
99
+
100
+ token = state.tokens[endDelim.token];
101
+ token.type = isStrong ? 'strong_close' : 'em_close';
102
+ token.tag = isStrong ? 'strong' : 'em';
103
+ token.nesting = -1;
104
+ token.markup = isStrong ? ch + ch : ch;
105
+ token.content = '';
106
+
107
+ if (isStrong) {
108
+ state.tokens[delimiters[i - 1].token].content = '';
109
+ state.tokens[delimiters[startDelim.end + 1].token].content = '';
110
+ i--;
111
+ }
112
+ }
113
+ }
114
+
115
+
116
+ // Walk through delimiter list and replace text tokens with tags
117
+ //
118
+ module.exports.postProcess = function emphasis(state) {
119
+ var curr,
120
+ tokens_meta = state.tokens_meta,
121
+ max = state.tokens_meta.length;
122
+
123
+ postProcess(state, state.delimiters);
124
+
125
+ for (curr = 0; curr < max; curr++) {
126
+ if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
127
+ postProcess(state, tokens_meta[curr].delimiters);
128
+ }
129
+ }
130
+ };
@@ -0,0 +1,55 @@
1
+ // Process html entity - &#123;, &#xAF;, &quot;, ...
2
+
3
+ 'use strict';
4
+
5
+ var entities = require('../common/entities');
6
+ var has = require('../common/utils').has;
7
+ var isValidEntityCode = require('../common/utils').isValidEntityCode;
8
+ var fromCodePoint = require('../common/utils').fromCodePoint;
9
+
10
+
11
+ var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
12
+ var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
13
+
14
+
15
+ module.exports = function entity(state, silent) {
16
+ var ch, code, match, token, pos = state.pos, max = state.posMax;
17
+
18
+ if (state.src.charCodeAt(pos) !== 0x26/* & */) return false;
19
+
20
+ if (pos + 1 >= max) return false;
21
+
22
+ ch = state.src.charCodeAt(pos + 1);
23
+
24
+ if (ch === 0x23 /* # */) {
25
+ match = state.src.slice(pos).match(DIGITAL_RE);
26
+ if (match) {
27
+ if (!silent) {
28
+ code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
29
+
30
+ token = state.push('text_special', '', 0);
31
+ token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
32
+ token.markup = match[0];
33
+ token.info = 'entity';
34
+ }
35
+ state.pos += match[0].length;
36
+ return true;
37
+ }
38
+ } else {
39
+ match = state.src.slice(pos).match(NAMED_RE);
40
+ if (match) {
41
+ if (has(entities, match[1])) {
42
+ if (!silent) {
43
+ token = state.push('text_special', '', 0);
44
+ token.content = entities[match[1]];
45
+ token.markup = match[0];
46
+ token.info = 'entity';
47
+ }
48
+ state.pos += match[0].length;
49
+ return true;
50
+ }
51
+ }
52
+ }
53
+
54
+ return false;
55
+ };
@@ -0,0 +1,71 @@
1
+ // Process escaped chars and hardbreaks
2
+
3
+ 'use strict';
4
+
5
+ var isSpace = require('../common/utils').isSpace;
6
+
7
+ var ESCAPED = [];
8
+
9
+ for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
10
+
11
+ '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
12
+ .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
13
+
14
+
15
+ module.exports = function escape(state, silent) {
16
+ var ch1, ch2, origStr, escapedStr, token, pos = state.pos, max = state.posMax;
17
+
18
+ if (state.src.charCodeAt(pos) !== 0x5C/* \ */) return false;
19
+ pos++;
20
+
21
+ // '\' at the end of the inline block
22
+ if (pos >= max) return false;
23
+
24
+ ch1 = state.src.charCodeAt(pos);
25
+
26
+ if (ch1 === 0x0A) {
27
+ if (!silent) {
28
+ state.push('hardbreak', 'br', 0);
29
+ }
30
+
31
+ pos++;
32
+ // skip leading whitespaces from next line
33
+ while (pos < max) {
34
+ ch1 = state.src.charCodeAt(pos);
35
+ if (!isSpace(ch1)) break;
36
+ pos++;
37
+ }
38
+
39
+ state.pos = pos;
40
+ return true;
41
+ }
42
+
43
+ escapedStr = state.src[pos];
44
+
45
+ if (ch1 >= 0xD800 && ch1 <= 0xDBFF && pos + 1 < max) {
46
+ ch2 = state.src.charCodeAt(pos + 1);
47
+
48
+ if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
49
+ escapedStr += state.src[pos + 1];
50
+ pos++;
51
+ }
52
+ }
53
+
54
+ origStr = '\\' + escapedStr;
55
+
56
+ if (!silent) {
57
+ token = state.push('text_special', '', 0);
58
+
59
+ if (ch1 < 256 && ESCAPED[ch1] !== 0) {
60
+ token.content = escapedStr;
61
+ } else {
62
+ token.content = origStr;
63
+ }
64
+
65
+ token.markup = origStr;
66
+ token.info = 'escape';
67
+ }
68
+
69
+ state.pos = pos + 1;
70
+ return true;
71
+ };
@@ -0,0 +1,41 @@
1
+ // Clean up tokens after emphasis and strikethrough postprocessing:
2
+ // merge adjacent text nodes into one and re-calculate all token levels
3
+ //
4
+ // This is necessary because initially emphasis delimiter markers (*, _, ~)
5
+ // are treated as their own separate text tokens. Then emphasis rule either
6
+ // leaves them as text (needed to merge with adjacent text) or turns them
7
+ // into opening/closing tags (which messes up levels inside).
8
+ //
9
+ 'use strict';
10
+
11
+
12
+ module.exports = function fragments_join(state) {
13
+ var curr, last,
14
+ level = 0,
15
+ tokens = state.tokens,
16
+ max = state.tokens.length;
17
+
18
+ for (curr = last = 0; curr < max; curr++) {
19
+ // re-calculate levels after emphasis/strikethrough turns some text nodes
20
+ // into opening/closing tags
21
+ if (tokens[curr].nesting < 0) level--; // closing tag
22
+ tokens[curr].level = level;
23
+ if (tokens[curr].nesting > 0) level++; // opening tag
24
+
25
+ if (tokens[curr].type === 'text' &&
26
+ curr + 1 < max &&
27
+ tokens[curr + 1].type === 'text') {
28
+
29
+ // collapse two adjacent text nodes
30
+ tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
31
+ } else {
32
+ if (curr !== last) { tokens[last] = tokens[curr]; }
33
+
34
+ last++;
35
+ }
36
+ }
37
+
38
+ if (curr !== last) {
39
+ tokens.length = last;
40
+ }
41
+ };
@@ -0,0 +1,58 @@
1
+ // Process html tags
2
+
3
+ 'use strict';
4
+
5
+
6
+ var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE;
7
+
8
+
9
+ function isLinkOpen(str) {
10
+ return /^<a[>\s]/i.test(str);
11
+ }
12
+ function isLinkClose(str) {
13
+ return /^<\/a\s*>/i.test(str);
14
+ }
15
+
16
+
17
+ function isLetter(ch) {
18
+ /*eslint no-bitwise:0*/
19
+ var lc = ch | 0x20; // to lower case
20
+ return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
21
+ }
22
+
23
+
24
+ module.exports = function html_inline(state, silent) {
25
+ var ch, match, max, token,
26
+ pos = state.pos;
27
+
28
+ if (!state.md.options.html) { return false; }
29
+
30
+ // Check start
31
+ max = state.posMax;
32
+ if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
33
+ pos + 2 >= max) {
34
+ return false;
35
+ }
36
+
37
+ // Quick fail on second char
38
+ ch = state.src.charCodeAt(pos + 1);
39
+ if (ch !== 0x21/* ! */ &&
40
+ ch !== 0x3F/* ? */ &&
41
+ ch !== 0x2F/* / */ &&
42
+ !isLetter(ch)) {
43
+ return false;
44
+ }
45
+
46
+ match = state.src.slice(pos).match(HTML_TAG_RE);
47
+ if (!match) { return false; }
48
+
49
+ if (!silent) {
50
+ token = state.push('html_inline', '', 0);
51
+ token.content = match[0];
52
+
53
+ if (isLinkOpen(token.content)) state.linkLevel++;
54
+ if (isLinkClose(token.content)) state.linkLevel--;
55
+ }
56
+ state.pos += match[0].length;
57
+ return true;
58
+ };
@@ -0,0 +1,152 @@
1
+ // Process ![image](<src> "title")
2
+
3
+ 'use strict';
4
+
5
+ var normalizeReference = require('../common/utils').normalizeReference;
6
+ var isSpace = require('../common/utils').isSpace;
7
+
8
+
9
+ module.exports = function image(state, silent) {
10
+ var attrs,
11
+ code,
12
+ content,
13
+ label,
14
+ labelEnd,
15
+ labelStart,
16
+ pos,
17
+ ref,
18
+ res,
19
+ title,
20
+ token,
21
+ tokens,
22
+ start,
23
+ href = '',
24
+ oldPos = state.pos,
25
+ max = state.posMax;
26
+
27
+ if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }
28
+ if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }
29
+
30
+ labelStart = state.pos + 2;
31
+ labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
32
+
33
+ // parser failed to find ']', so it's not a valid link
34
+ if (labelEnd < 0) { return false; }
35
+
36
+ pos = labelEnd + 1;
37
+ if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
38
+ //
39
+ // Inline link
40
+ //
41
+
42
+ // [link]( <href> "title" )
43
+ // ^^ skipping these spaces
44
+ pos++;
45
+ for (; pos < max; pos++) {
46
+ code = state.src.charCodeAt(pos);
47
+ if (!isSpace(code) && code !== 0x0A) { break; }
48
+ }
49
+ if (pos >= max) { return false; }
50
+
51
+ // [link]( <href> "title" )
52
+ // ^^^^^^ parsing link destination
53
+ start = pos;
54
+ res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
55
+ if (res.ok) {
56
+ href = state.md.normalizeLink(res.str);
57
+ if (state.md.validateLink(href)) {
58
+ pos = res.pos;
59
+ } else {
60
+ href = '';
61
+ }
62
+ }
63
+
64
+ // [link]( <href> "title" )
65
+ // ^^ skipping these spaces
66
+ start = pos;
67
+ for (; pos < max; pos++) {
68
+ code = state.src.charCodeAt(pos);
69
+ if (!isSpace(code) && code !== 0x0A) { break; }
70
+ }
71
+
72
+ // [link]( <href> "title" )
73
+ // ^^^^^^^ parsing link title
74
+ res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
75
+ if (pos < max && start !== pos && res.ok) {
76
+ title = res.str;
77
+ pos = res.pos;
78
+
79
+ // [link]( <href> "title" )
80
+ // ^^ skipping these spaces
81
+ for (; pos < max; pos++) {
82
+ code = state.src.charCodeAt(pos);
83
+ if (!isSpace(code) && code !== 0x0A) { break; }
84
+ }
85
+ } else {
86
+ title = '';
87
+ }
88
+
89
+ if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
90
+ state.pos = oldPos;
91
+ return false;
92
+ }
93
+ pos++;
94
+ } else {
95
+ //
96
+ // Link reference
97
+ //
98
+ if (typeof state.env.references === 'undefined') { return false; }
99
+
100
+ if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
101
+ start = pos + 1;
102
+ pos = state.md.helpers.parseLinkLabel(state, pos);
103
+ if (pos >= 0) {
104
+ label = state.src.slice(start, pos++);
105
+ } else {
106
+ pos = labelEnd + 1;
107
+ }
108
+ } else {
109
+ pos = labelEnd + 1;
110
+ }
111
+
112
+ // covers label === '' and label === undefined
113
+ // (collapsed reference link and shortcut reference link respectively)
114
+ if (!label) { label = state.src.slice(labelStart, labelEnd); }
115
+
116
+ ref = state.env.references[normalizeReference(label)];
117
+ if (!ref) {
118
+ state.pos = oldPos;
119
+ return false;
120
+ }
121
+ href = ref.href;
122
+ title = ref.title;
123
+ }
124
+
125
+ //
126
+ // We found the end of the link, and know for a fact it's a valid link;
127
+ // so all that's left to do is to call tokenizer.
128
+ //
129
+ if (!silent) {
130
+ content = state.src.slice(labelStart, labelEnd);
131
+
132
+ state.md.inline.parse(
133
+ content,
134
+ state.md,
135
+ state.env,
136
+ tokens = []
137
+ );
138
+
139
+ token = state.push('image', 'img', 0);
140
+ token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];
141
+ token.children = tokens;
142
+ token.content = content;
143
+
144
+ if (title) {
145
+ attrs.push([ 'title', title ]);
146
+ }
147
+ }
148
+
149
+ state.pos = pos;
150
+ state.posMax = max;
151
+ return true;
152
+ };
@@ -0,0 +1,150 @@
1
+ // Process [link](<to> "stuff")
2
+
3
+ 'use strict';
4
+
5
+ var normalizeReference = require('../common/utils').normalizeReference;
6
+ var isSpace = require('../common/utils').isSpace;
7
+
8
+
9
+ module.exports = function link(state, silent) {
10
+ var attrs,
11
+ code,
12
+ label,
13
+ labelEnd,
14
+ labelStart,
15
+ pos,
16
+ res,
17
+ ref,
18
+ token,
19
+ href = '',
20
+ title = '',
21
+ oldPos = state.pos,
22
+ max = state.posMax,
23
+ start = state.pos,
24
+ parseReference = true;
25
+
26
+ if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }
27
+
28
+ labelStart = state.pos + 1;
29
+ labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
30
+
31
+ // parser failed to find ']', so it's not a valid link
32
+ if (labelEnd < 0) { return false; }
33
+
34
+ pos = labelEnd + 1;
35
+ if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
36
+ //
37
+ // Inline link
38
+ //
39
+
40
+ // might have found a valid shortcut link, disable reference parsing
41
+ parseReference = false;
42
+
43
+ // [link]( <href> "title" )
44
+ // ^^ skipping these spaces
45
+ pos++;
46
+ for (; pos < max; pos++) {
47
+ code = state.src.charCodeAt(pos);
48
+ if (!isSpace(code) && code !== 0x0A) { break; }
49
+ }
50
+ if (pos >= max) { return false; }
51
+
52
+ // [link]( <href> "title" )
53
+ // ^^^^^^ parsing link destination
54
+ start = pos;
55
+ res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
56
+ if (res.ok) {
57
+ href = state.md.normalizeLink(res.str);
58
+ if (state.md.validateLink(href)) {
59
+ pos = res.pos;
60
+ } else {
61
+ href = '';
62
+ }
63
+
64
+ // [link]( <href> "title" )
65
+ // ^^ skipping these spaces
66
+ start = pos;
67
+ for (; pos < max; pos++) {
68
+ code = state.src.charCodeAt(pos);
69
+ if (!isSpace(code) && code !== 0x0A) { break; }
70
+ }
71
+
72
+ // [link]( <href> "title" )
73
+ // ^^^^^^^ parsing link title
74
+ res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
75
+ if (pos < max && start !== pos && res.ok) {
76
+ title = res.str;
77
+ pos = res.pos;
78
+
79
+ // [link]( <href> "title" )
80
+ // ^^ skipping these spaces
81
+ for (; pos < max; pos++) {
82
+ code = state.src.charCodeAt(pos);
83
+ if (!isSpace(code) && code !== 0x0A) { break; }
84
+ }
85
+ }
86
+ }
87
+
88
+ if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
89
+ // parsing a valid shortcut link failed, fallback to reference
90
+ parseReference = true;
91
+ }
92
+ pos++;
93
+ }
94
+
95
+ if (parseReference) {
96
+ //
97
+ // Link reference
98
+ //
99
+ if (typeof state.env.references === 'undefined') { return false; }
100
+
101
+ if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
102
+ start = pos + 1;
103
+ pos = state.md.helpers.parseLinkLabel(state, pos);
104
+ if (pos >= 0) {
105
+ label = state.src.slice(start, pos++);
106
+ } else {
107
+ pos = labelEnd + 1;
108
+ }
109
+ } else {
110
+ pos = labelEnd + 1;
111
+ }
112
+
113
+ // covers label === '' and label === undefined
114
+ // (collapsed reference link and shortcut reference link respectively)
115
+ if (!label) { label = state.src.slice(labelStart, labelEnd); }
116
+
117
+ ref = state.env.references[normalizeReference(label)];
118
+ if (!ref) {
119
+ state.pos = oldPos;
120
+ return false;
121
+ }
122
+ href = ref.href;
123
+ title = ref.title;
124
+ }
125
+
126
+ //
127
+ // We found the end of the link, and know for a fact it's a valid link;
128
+ // so all that's left to do is to call tokenizer.
129
+ //
130
+ if (!silent) {
131
+ state.pos = labelStart;
132
+ state.posMax = labelEnd;
133
+
134
+ token = state.push('link_open', 'a', 1);
135
+ token.attrs = attrs = [ [ 'href', href ] ];
136
+ if (title) {
137
+ attrs.push([ 'title', title ]);
138
+ }
139
+
140
+ state.linkLevel++;
141
+ state.md.inline.tokenize(state);
142
+ state.linkLevel--;
143
+
144
+ token = state.push('link_close', 'a', -1);
145
+ }
146
+
147
+ state.pos = pos;
148
+ state.posMax = max;
149
+ return true;
150
+ };