@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,105 @@
1
+ // Simple typographic replacements
2
+ //
3
+ // (c) (C) → ©
4
+ // (tm) (TM) → ™
5
+ // (r) (R) → ®
6
+ // +- → ±
7
+ // ... → … (also ?.... → ?.., !.... → !..)
8
+ // ???????? → ???, !!!!! → !!!, `,,` → `,`
9
+ // -- → –, --- → —
10
+ //
11
+ 'use strict';
12
+
13
+ // TODO:
14
+ // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
15
+ // - multiplications 2 x 4 -> 2 × 4
16
+
17
+ var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
18
+
19
+ // Workaround for phantomjs - need regex without /g flag,
20
+ // or root check will fail every second time
21
+ var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
22
+
23
+ var SCOPED_ABBR_RE = /\((c|tm|r)\)/ig;
24
+ var SCOPED_ABBR = {
25
+ c: '©',
26
+ r: '®',
27
+ tm: '™'
28
+ };
29
+
30
+ function replaceFn(match, name) {
31
+ return SCOPED_ABBR[name.toLowerCase()];
32
+ }
33
+
34
+ function replace_scoped(inlineTokens) {
35
+ var i, token, inside_autolink = 0;
36
+
37
+ for (i = inlineTokens.length - 1; i >= 0; i--) {
38
+ token = inlineTokens[i];
39
+
40
+ if (token.type === 'text' && !inside_autolink) {
41
+ token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
42
+ }
43
+
44
+ if (token.type === 'link_open' && token.info === 'auto') {
45
+ inside_autolink--;
46
+ }
47
+
48
+ if (token.type === 'link_close' && token.info === 'auto') {
49
+ inside_autolink++;
50
+ }
51
+ }
52
+ }
53
+
54
+ function replace_rare(inlineTokens) {
55
+ var i, token, inside_autolink = 0;
56
+
57
+ for (i = inlineTokens.length - 1; i >= 0; i--) {
58
+ token = inlineTokens[i];
59
+
60
+ if (token.type === 'text' && !inside_autolink) {
61
+ if (RARE_RE.test(token.content)) {
62
+ token.content = token.content
63
+ .replace(/\+-/g, '±')
64
+ // .., ..., ....... -> …
65
+ // but ?..... & !..... -> ?.. & !..
66
+ .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
67
+ .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
68
+ // em-dash
69
+ .replace(/(^|[^-])---(?=[^-]|$)/mg, '$1\u2014')
70
+ // en-dash
71
+ .replace(/(^|\s)--(?=\s|$)/mg, '$1\u2013')
72
+ .replace(/(^|[^-\s])--(?=[^-\s]|$)/mg, '$1\u2013');
73
+ }
74
+ }
75
+
76
+ if (token.type === 'link_open' && token.info === 'auto') {
77
+ inside_autolink--;
78
+ }
79
+
80
+ if (token.type === 'link_close' && token.info === 'auto') {
81
+ inside_autolink++;
82
+ }
83
+ }
84
+ }
85
+
86
+
87
+ module.exports = function replace(state) {
88
+ var blkIdx;
89
+
90
+ if (!state.md.options.typographer) { return; }
91
+
92
+ for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
93
+
94
+ if (state.tokens[blkIdx].type !== 'inline') { continue; }
95
+
96
+ if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
97
+ replace_scoped(state.tokens[blkIdx].children);
98
+ }
99
+
100
+ if (RARE_RE.test(state.tokens[blkIdx].content)) {
101
+ replace_rare(state.tokens[blkIdx].children);
102
+ }
103
+
104
+ }
105
+ };
@@ -0,0 +1,201 @@
1
+ // Convert straight quotation marks to typographic ones
2
+ //
3
+ 'use strict';
4
+
5
+
6
+ var isWhiteSpace = require('../common/utils').isWhiteSpace;
7
+ var isPunctChar = require('../common/utils').isPunctChar;
8
+ var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
9
+
10
+ var QUOTE_TEST_RE = /['"]/;
11
+ var QUOTE_RE = /['"]/g;
12
+ var APOSTROPHE = '\u2019'; /* ’ */
13
+
14
+
15
+ function replaceAt(str, index, ch) {
16
+ return str.slice(0, index) + ch + str.slice(index + 1);
17
+ }
18
+
19
+ function process_inlines(tokens, state) {
20
+ var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,
21
+ isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,
22
+ canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
23
+
24
+ stack = [];
25
+
26
+ for (i = 0; i < tokens.length; i++) {
27
+ token = tokens[i];
28
+
29
+ thisLevel = tokens[i].level;
30
+
31
+ for (j = stack.length - 1; j >= 0; j--) {
32
+ if (stack[j].level <= thisLevel) { break; }
33
+ }
34
+ stack.length = j + 1;
35
+
36
+ if (token.type !== 'text') { continue; }
37
+
38
+ text = token.content;
39
+ pos = 0;
40
+ max = text.length;
41
+
42
+ /*eslint no-labels:0,block-scoped-var:0*/
43
+ OUTER:
44
+ while (pos < max) {
45
+ QUOTE_RE.lastIndex = pos;
46
+ t = QUOTE_RE.exec(text);
47
+ if (!t) { break; }
48
+
49
+ canOpen = canClose = true;
50
+ pos = t.index + 1;
51
+ isSingle = (t[0] === "'");
52
+
53
+ // Find previous character,
54
+ // default to space if it's the beginning of the line
55
+ //
56
+ lastChar = 0x20;
57
+
58
+ if (t.index - 1 >= 0) {
59
+ lastChar = text.charCodeAt(t.index - 1);
60
+ } else {
61
+ for (j = i - 1; j >= 0; j--) {
62
+ if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
63
+ if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'
64
+
65
+ lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
66
+ break;
67
+ }
68
+ }
69
+
70
+ // Find next character,
71
+ // default to space if it's the end of the line
72
+ //
73
+ nextChar = 0x20;
74
+
75
+ if (pos < max) {
76
+ nextChar = text.charCodeAt(pos);
77
+ } else {
78
+ for (j = i + 1; j < tokens.length; j++) {
79
+ if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
80
+ if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'
81
+
82
+ nextChar = tokens[j].content.charCodeAt(0);
83
+ break;
84
+ }
85
+ }
86
+
87
+ isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
88
+ isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
89
+
90
+ isLastWhiteSpace = isWhiteSpace(lastChar);
91
+ isNextWhiteSpace = isWhiteSpace(nextChar);
92
+
93
+ if (isNextWhiteSpace) {
94
+ canOpen = false;
95
+ } else if (isNextPunctChar) {
96
+ if (!(isLastWhiteSpace || isLastPunctChar)) {
97
+ canOpen = false;
98
+ }
99
+ }
100
+
101
+ if (isLastWhiteSpace) {
102
+ canClose = false;
103
+ } else if (isLastPunctChar) {
104
+ if (!(isNextWhiteSpace || isNextPunctChar)) {
105
+ canClose = false;
106
+ }
107
+ }
108
+
109
+ if (nextChar === 0x22 /* " */ && t[0] === '"') {
110
+ if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {
111
+ // special case: 1"" - count first quote as an inch
112
+ canClose = canOpen = false;
113
+ }
114
+ }
115
+
116
+ if (canOpen && canClose) {
117
+ // Replace quotes in the middle of punctuation sequence, but not
118
+ // in the middle of the words, i.e.:
119
+ //
120
+ // 1. foo " bar " baz - not replaced
121
+ // 2. foo-"-bar-"-baz - replaced
122
+ // 3. foo"bar"baz - not replaced
123
+ //
124
+ canOpen = isLastPunctChar;
125
+ canClose = isNextPunctChar;
126
+ }
127
+
128
+ if (!canOpen && !canClose) {
129
+ // middle of word
130
+ if (isSingle) {
131
+ token.content = replaceAt(token.content, t.index, APOSTROPHE);
132
+ }
133
+ continue;
134
+ }
135
+
136
+ if (canClose) {
137
+ // this could be a closing quote, rewind the stack to get a match
138
+ for (j = stack.length - 1; j >= 0; j--) {
139
+ item = stack[j];
140
+ if (stack[j].level < thisLevel) { break; }
141
+ if (item.single === isSingle && stack[j].level === thisLevel) {
142
+ item = stack[j];
143
+
144
+ if (isSingle) {
145
+ openQuote = state.md.options.quotes[2];
146
+ closeQuote = state.md.options.quotes[3];
147
+ } else {
148
+ openQuote = state.md.options.quotes[0];
149
+ closeQuote = state.md.options.quotes[1];
150
+ }
151
+
152
+ // replace token.content *before* tokens[item.token].content,
153
+ // because, if they are pointing at the same token, replaceAt
154
+ // could mess up indices when quote length != 1
155
+ token.content = replaceAt(token.content, t.index, closeQuote);
156
+ tokens[item.token].content = replaceAt(
157
+ tokens[item.token].content, item.pos, openQuote);
158
+
159
+ pos += closeQuote.length - 1;
160
+ if (item.token === i) { pos += openQuote.length - 1; }
161
+
162
+ text = token.content;
163
+ max = text.length;
164
+
165
+ stack.length = j;
166
+ continue OUTER;
167
+ }
168
+ }
169
+ }
170
+
171
+ if (canOpen) {
172
+ stack.push({
173
+ token: i,
174
+ pos: t.index,
175
+ single: isSingle,
176
+ level: thisLevel
177
+ });
178
+ } else if (canClose && isSingle) {
179
+ token.content = replaceAt(token.content, t.index, APOSTROPHE);
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+
186
+ module.exports = function smartquotes(state) {
187
+ /*eslint max-depth:0*/
188
+ var blkIdx;
189
+
190
+ if (!state.md.options.typographer) { return; }
191
+
192
+ for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
193
+
194
+ if (state.tokens[blkIdx].type !== 'inline' ||
195
+ !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
196
+ continue;
197
+ }
198
+
199
+ process_inlines(state.tokens[blkIdx].children, state);
200
+ }
201
+ };
@@ -0,0 +1,20 @@
1
+ // Core state object
2
+ //
3
+ 'use strict';
4
+
5
+ var Token = require('../token');
6
+
7
+
8
+ function StateCore(src, md, env) {
9
+ this.src = src;
10
+ this.env = env;
11
+ this.tokens = [];
12
+ this.inlineMode = false;
13
+ this.md = md; // link to parser instance
14
+ }
15
+
16
+ // re-export Token class to use in core rules
17
+ StateCore.prototype.Token = Token;
18
+
19
+
20
+ module.exports = StateCore;
@@ -0,0 +1,45 @@
1
+ // Join raw text tokens with the rest of the text
2
+ //
3
+ // This is set as a separate rule to provide an opportunity for plugins
4
+ // to run text replacements after text join, but before escape join.
5
+ //
6
+ // For example, `\:)` shouldn't be replaced with an emoji.
7
+ //
8
+ 'use strict';
9
+
10
+
11
+ module.exports = function text_join(state) {
12
+ var j, l, tokens, curr, max, last,
13
+ blockTokens = state.tokens;
14
+
15
+ for (j = 0, l = blockTokens.length; j < l; j++) {
16
+ if (blockTokens[j].type !== 'inline') continue;
17
+
18
+ tokens = blockTokens[j].children;
19
+ max = tokens.length;
20
+
21
+ for (curr = 0; curr < max; curr++) {
22
+ if (tokens[curr].type === 'text_special') {
23
+ tokens[curr].type = 'text';
24
+ }
25
+ }
26
+
27
+ for (curr = last = 0; curr < max; curr++) {
28
+ if (tokens[curr].type === 'text' &&
29
+ curr + 1 < max &&
30
+ tokens[curr + 1].type === 'text') {
31
+
32
+ // collapse two adjacent text nodes
33
+ tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
34
+ } else {
35
+ if (curr !== last) { tokens[last] = tokens[curr]; }
36
+
37
+ last++;
38
+ }
39
+ }
40
+
41
+ if (curr !== last) {
42
+ tokens.length = last;
43
+ }
44
+ }
45
+ };
@@ -0,0 +1,76 @@
1
+ // Process autolinks '<protocol:...>'
2
+
3
+ 'use strict';
4
+
5
+
6
+ /*eslint max-len:0*/
7
+ var EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;
8
+ var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;
9
+
10
+
11
+ module.exports = function autolink(state, silent) {
12
+ var url, fullUrl, token, ch, start, max,
13
+ pos = state.pos;
14
+
15
+ if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
16
+
17
+ start = state.pos;
18
+ max = state.posMax;
19
+
20
+ for (;;) {
21
+ if (++pos >= max) return false;
22
+
23
+ ch = state.src.charCodeAt(pos);
24
+
25
+ if (ch === 0x3C /* < */) return false;
26
+ if (ch === 0x3E /* > */) break;
27
+ }
28
+
29
+ url = state.src.slice(start + 1, pos);
30
+
31
+ if (AUTOLINK_RE.test(url)) {
32
+ fullUrl = state.md.normalizeLink(url);
33
+ if (!state.md.validateLink(fullUrl)) { return false; }
34
+
35
+ if (!silent) {
36
+ token = state.push('link_open', 'a', 1);
37
+ token.attrs = [ [ 'href', fullUrl ] ];
38
+ token.markup = 'autolink';
39
+ token.info = 'auto';
40
+
41
+ token = state.push('text', '', 0);
42
+ token.content = state.md.normalizeLinkText(url);
43
+
44
+ token = state.push('link_close', 'a', -1);
45
+ token.markup = 'autolink';
46
+ token.info = 'auto';
47
+ }
48
+
49
+ state.pos += url.length + 2;
50
+ return true;
51
+ }
52
+
53
+ if (EMAIL_RE.test(url)) {
54
+ fullUrl = state.md.normalizeLink('mailto:' + url);
55
+ if (!state.md.validateLink(fullUrl)) { return false; }
56
+
57
+ if (!silent) {
58
+ token = state.push('link_open', 'a', 1);
59
+ token.attrs = [ [ 'href', fullUrl ] ];
60
+ token.markup = 'autolink';
61
+ token.info = 'auto';
62
+
63
+ token = state.push('text', '', 0);
64
+ token.content = state.md.normalizeLinkText(url);
65
+
66
+ token = state.push('link_close', 'a', -1);
67
+ token.markup = 'autolink';
68
+ token.info = 'auto';
69
+ }
70
+
71
+ state.pos += url.length + 2;
72
+ return true;
73
+ }
74
+
75
+ return false;
76
+ };
@@ -0,0 +1,63 @@
1
+ // Parse backticks
2
+
3
+ 'use strict';
4
+
5
+
6
+ module.exports = function backtick(state, silent) {
7
+ var start, max, marker, token, matchStart, matchEnd, openerLength, closerLength,
8
+ pos = state.pos,
9
+ ch = state.src.charCodeAt(pos);
10
+
11
+ if (ch !== 0x60/* ` */) { return false; }
12
+
13
+ start = pos;
14
+ pos++;
15
+ max = state.posMax;
16
+
17
+ // scan marker length
18
+ while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
19
+
20
+ marker = state.src.slice(start, pos);
21
+ openerLength = marker.length;
22
+
23
+ if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
24
+ if (!silent) state.pending += marker;
25
+ state.pos += openerLength;
26
+ return true;
27
+ }
28
+
29
+ matchEnd = pos;
30
+
31
+ // Nothing found in the cache, scan until the end of the line (or until marker is found)
32
+ while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
33
+ matchEnd = matchStart + 1;
34
+
35
+ // scan marker length
36
+ while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
37
+
38
+ closerLength = matchEnd - matchStart;
39
+
40
+ if (closerLength === openerLength) {
41
+ // Found matching closer length.
42
+ if (!silent) {
43
+ token = state.push('code_inline', 'code', 0);
44
+ token.markup = marker;
45
+ token.content = state.src.slice(pos, matchStart)
46
+ .replace(/\n/g, ' ')
47
+ .replace(/^ (.+) $/, '$1');
48
+ }
49
+ state.pos = matchEnd;
50
+ return true;
51
+ }
52
+
53
+ // Some different length found, put it in cache as upper limit of where closer can be found
54
+ state.backticks[closerLength] = matchStart;
55
+ }
56
+
57
+ // Scanned through the end, didn't find anything
58
+ state.backticksScanned = true;
59
+
60
+ if (!silent) state.pending += marker;
61
+ state.pos += openerLength;
62
+ return true;
63
+ };
@@ -0,0 +1,130 @@
1
+ // For each opening emphasis-like marker find a matching closing one
2
+ //
3
+ 'use strict';
4
+
5
+
6
+ function processDelimiters(delimiters) {
7
+ var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx,
8
+ isOddMatch, lastJump,
9
+ openersBottom = {},
10
+ max = delimiters.length;
11
+
12
+ if (!max) return;
13
+
14
+ // headerIdx is the first delimiter of the current (where closer is) delimiter run
15
+ var headerIdx = 0;
16
+ var lastTokenIdx = -2; // needs any value lower than -1
17
+ var jumps = [];
18
+
19
+ for (closerIdx = 0; closerIdx < max; closerIdx++) {
20
+ closer = delimiters[closerIdx];
21
+
22
+ jumps.push(0);
23
+
24
+ // markers belong to same delimiter run if:
25
+ // - they have adjacent tokens
26
+ // - AND markers are the same
27
+ //
28
+ if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {
29
+ headerIdx = closerIdx;
30
+ }
31
+
32
+ lastTokenIdx = closer.token;
33
+
34
+ // Length is only used for emphasis-specific "rule of 3",
35
+ // if it's not defined (in strikethrough or 3rd party plugins),
36
+ // we can default it to 0 to disable those checks.
37
+ //
38
+ closer.length = closer.length || 0;
39
+
40
+ if (!closer.close) continue;
41
+
42
+ // Previously calculated lower bounds (previous fails)
43
+ // for each marker, each delimiter length modulo 3,
44
+ // and for whether this closer can be an opener;
45
+ // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
46
+ if (!openersBottom.hasOwnProperty(closer.marker)) {
47
+ openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ];
48
+ }
49
+
50
+ minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)];
51
+
52
+ openerIdx = headerIdx - jumps[headerIdx] - 1;
53
+
54
+ newMinOpenerIdx = openerIdx;
55
+
56
+ for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
57
+ opener = delimiters[openerIdx];
58
+
59
+ if (opener.marker !== closer.marker) continue;
60
+
61
+ if (opener.open && opener.end < 0) {
62
+
63
+ isOddMatch = false;
64
+
65
+ // from spec:
66
+ //
67
+ // If one of the delimiters can both open and close emphasis, then the
68
+ // sum of the lengths of the delimiter runs containing the opening and
69
+ // closing delimiters must not be a multiple of 3 unless both lengths
70
+ // are multiples of 3.
71
+ //
72
+ if (opener.close || closer.open) {
73
+ if ((opener.length + closer.length) % 3 === 0) {
74
+ if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {
75
+ isOddMatch = true;
76
+ }
77
+ }
78
+ }
79
+
80
+ if (!isOddMatch) {
81
+ // If previous delimiter cannot be an opener, we can safely skip
82
+ // the entire sequence in future checks. This is required to make
83
+ // sure algorithm has linear complexity (see *_*_*_*_*_... case).
84
+ //
85
+ lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ?
86
+ jumps[openerIdx - 1] + 1 :
87
+ 0;
88
+
89
+ jumps[closerIdx] = closerIdx - openerIdx + lastJump;
90
+ jumps[openerIdx] = lastJump;
91
+
92
+ closer.open = false;
93
+ opener.end = closerIdx;
94
+ opener.close = false;
95
+ newMinOpenerIdx = -1;
96
+ // treat next token as start of run,
97
+ // it optimizes skips in **<...>**a**<...>** pathological case
98
+ lastTokenIdx = -2;
99
+ break;
100
+ }
101
+ }
102
+ }
103
+
104
+ if (newMinOpenerIdx !== -1) {
105
+ // If match for this delimiter run failed, we want to set lower bound for
106
+ // future lookups. This is required to make sure algorithm has linear
107
+ // complexity.
108
+ //
109
+ // See details here:
110
+ // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
111
+ //
112
+ openersBottom[closer.marker][(closer.open ? 3 : 0) + ((closer.length || 0) % 3)] = newMinOpenerIdx;
113
+ }
114
+ }
115
+ }
116
+
117
+
118
+ module.exports = function link_pairs(state) {
119
+ var curr,
120
+ tokens_meta = state.tokens_meta,
121
+ max = state.tokens_meta.length;
122
+
123
+ processDelimiters(state.delimiters);
124
+
125
+ for (curr = 0; curr < max; curr++) {
126
+ if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
127
+ processDelimiters(tokens_meta[curr].delimiters);
128
+ }
129
+ }
130
+ };