@alexlit/lint-kit 107.3.0 → 108.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/.eslintrc.cjs +7 -1
  2. package/.linthtmlrc.cjs +3 -1
  3. package/{.commitlintrc.cjs → commitlint.config.js} +1 -1
  4. package/package.json +5 -5
  5. package/packages/config-commitlint/LICENSE +20 -0
  6. package/packages/config-commitlint/README.md +5 -9
  7. package/packages/config-commitlint/index.js +1 -1
  8. package/packages/config-commitlint/package.json +4 -3
  9. package/packages/config-eslint/LICENSE +20 -0
  10. package/packages/config-eslint/index.js +12 -2
  11. package/packages/config-eslint/package.json +25 -25
  12. package/packages/config-eslint/plugins/typescript/index.js +1 -1
  13. package/packages/config-eslint/plugins/unicorn.js +2 -0
  14. package/packages/config-eslint/plugins/vue.js +34 -2
  15. package/packages/config-hooks/LICENSE +20 -0
  16. package/packages/config-hooks/README.md +18 -12
  17. package/packages/config-hooks/index.js +2 -0
  18. package/packages/config-hooks/lint-staged.js +1 -1
  19. package/packages/config-hooks/package.json +6 -5
  20. package/packages/config-htmllint/LICENSE +20 -0
  21. package/packages/config-markdownlint/LICENSE +20 -0
  22. package/packages/config-markdownlint/package.json +3 -3
  23. package/packages/config-npmlint/LICENSE +20 -0
  24. package/packages/config-npmlint/package.json +2 -2
  25. package/packages/config-prettier/LICENSE +20 -0
  26. package/packages/config-prettier/README.md +8 -3
  27. package/packages/config-prettier/index.js +14 -10
  28. package/packages/config-prettier/package.json +16 -12
  29. package/packages/config-prettier/plugins/jsdoc.js +1 -1
  30. package/packages/config-prettier/plugins/pug.js +1 -1
  31. package/packages/config-prettier/plugins/sort-json.js +1 -1
  32. package/packages/config-prettier/plugins/svelte.js +1 -1
  33. package/packages/config-prettier/plugins/tailwindcss.js +1 -1
  34. package/packages/config-prettier/plugins/xml.js +1 -1
  35. package/packages/config-stylelint/LICENSE +20 -0
  36. package/packages/config-stylelint/README.md +5 -4
  37. package/packages/config-stylelint/index.js +22 -25
  38. package/packages/config-stylelint/package.json +22 -18
  39. package/packages/config-stylelint/plugins/a11y.js +1 -1
  40. package/packages/config-stylelint/plugins/at-rule-no-children.js +1 -1
  41. package/packages/config-stylelint/plugins/color-format.js +1 -1
  42. package/packages/config-stylelint/plugins/declaration-block-no-ignored-properties.js +1 -1
  43. package/packages/config-stylelint/plugins/high-performance-animation.js +1 -1
  44. package/packages/config-stylelint/plugins/no-nested-media.js +1 -1
  45. package/packages/config-stylelint/plugins/no-unresolved-module.js +1 -1
  46. package/packages/config-stylelint/plugins/no-unsupported-browser-features.js +1 -1
  47. package/packages/config-stylelint/plugins/optional/gamut.js +1 -1
  48. package/packages/config-stylelint/plugins/optional/logical-css.js +1 -1
  49. package/packages/config-stylelint/plugins/optional/no-indistinguishable-colors.js +1 -1
  50. package/packages/config-stylelint/plugins/order.js +1 -1
  51. package/packages/config-stylelint/plugins/prettier.js +1 -1
  52. package/packages/config-stylelint/plugins/scss.js +1 -1
  53. package/packages/config-stylelint/plugins/selector-no-empty.js +1 -1
  54. package/packages/config-stylelint/plugins/use-nesting.js +1 -1
  55. package/packages/config-stylelint/plugins/vue.js +1 -1
  56. package/prettier.config.js +5 -0
  57. package/stylelint.config.js +14 -0
  58. package/.huskyrc.cjs +0 -3
  59. package/.lintstagedrc.cjs +0 -3
  60. package/.prettierrc.cjs +0 -3
  61. package/.stylelintrc.cjs +0 -4
  62. package/packages/config-hooks/husky.js +0 -6
  63. package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +0 -22
  64. package/packages/config-markdownlint/node_modules/markdown-it/README.md +0 -309
  65. package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +0 -117
  66. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +0 -8441
  67. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
  68. package/packages/config-markdownlint/node_modules/markdown-it/index.js +0 -4
  69. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +0 -6
  70. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +0 -70
  71. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +0 -28
  72. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +0 -317
  73. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +0 -7
  74. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +0 -80
  75. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +0 -48
  76. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +0 -55
  77. package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +0 -582
  78. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +0 -131
  79. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +0 -61
  80. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +0 -192
  81. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +0 -81
  82. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +0 -41
  83. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +0 -63
  84. package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +0 -341
  85. package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +0 -352
  86. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +0 -226
  87. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +0 -34
  88. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +0 -98
  89. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +0 -55
  90. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +0 -45
  91. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +0 -74
  92. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +0 -83
  93. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +0 -362
  94. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +0 -51
  95. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +0 -198
  96. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +0 -231
  97. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +0 -221
  98. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +0 -16
  99. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +0 -13
  100. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +0 -142
  101. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +0 -21
  102. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +0 -105
  103. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +0 -201
  104. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +0 -20
  105. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +0 -45
  106. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +0 -76
  107. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +0 -63
  108. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +0 -130
  109. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +0 -130
  110. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +0 -55
  111. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +0 -71
  112. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +0 -41
  113. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +0 -58
  114. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +0 -152
  115. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +0 -150
  116. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +0 -62
  117. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +0 -46
  118. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +0 -158
  119. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +0 -130
  120. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +0 -89
  121. package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +0 -201
  122. package/packages/config-markdownlint/node_modules/markdown-it/package.json +0 -87
  123. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -428
  124. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -92
  125. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
  126. package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1026
  127. package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +0 -6814
  128. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -376
  129. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +0 -27
  130. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +0 -20
  131. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +0 -2335
  132. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +0 -37
  133. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +0 -59
  134. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +0 -49
  135. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +0 -53
  136. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +0 -52
  137. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +0 -51
  138. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +0 -56
  139. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +0 -30
  140. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +0 -38
  141. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +0 -57
  142. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +0 -54
  143. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +0 -27
  144. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +0 -28
  145. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +0 -29
  146. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +0 -31
  147. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +0 -52
  148. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +0 -33
  149. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +0 -47
  150. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +0 -49
  151. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +0 -40
  152. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +0 -24
  153. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +0 -40
  154. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +0 -98
  155. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +0 -82
  156. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +0 -50
  157. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +0 -55
  158. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +0 -27
  159. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +0 -50
  160. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +0 -42
  161. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +0 -45
  162. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +0 -37
  163. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +0 -40
  164. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +0 -21
  165. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +0 -52
  166. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +0 -49
  167. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +0 -32
  168. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +0 -69
  169. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +0 -35
  170. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +0 -40
  171. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +0 -40
  172. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +0 -34
  173. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +0 -41
  174. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +0 -32
  175. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -32
  176. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -61
  177. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +0 -40
  178. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +0 -38
  179. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +0 -100
  180. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
  181. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -70
  182. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +0 -1025
  183. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +0 -426
  184. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +0 -26
  185. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +0 -10
  186. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +0 -21
  187. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +0 -1152
  188. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +0 -14
  189. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +0 -406
  190. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +0 -1476
  191. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +0 -22
  192. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +0 -42
  193. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +0 -76
  194. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +0 -73
  195. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +0 -86
  196. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +0 -86
  197. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +0 -60
  198. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +0 -46
  199. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +0 -32
  200. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +0 -96
  201. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +0 -53
  202. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +0 -34
  203. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +0 -39
  204. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +0 -62
  205. package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +0 -62
  206. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +0 -108
  207. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +0 -38
  208. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +0 -38
  209. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +0 -32
  210. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +0 -50
  211. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +0 -56
  212. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +0 -30
  213. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +0 -67
  214. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +0 -61
  215. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +0 -40
  216. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +0 -78
  217. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +0 -39
  218. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +0 -79
  219. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +0 -24
  220. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +0 -56
  221. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +0 -91
  222. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +0 -97
  223. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +0 -67
  224. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +0 -37
  225. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +0 -42
  226. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +0 -49
  227. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +0 -64
  228. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +0 -107
  229. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +0 -60
  230. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +0 -33
  231. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +0 -28
  232. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +0 -30
  233. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +0 -89
  234. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +0 -172
  235. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +0 -39
  236. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +0 -59
  237. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +0 -125
  238. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +0 -65
  239. package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -109
  240. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -297
  241. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -266
  242. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -1762
  243. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +0 -5
  244. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +0 -22
  245. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +0 -26
  246. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +0 -12
  247. /package/packages/config-eslint/plugins/{security.js → optional/security.js} +0 -0
@@ -1,341 +0,0 @@
1
- /**
2
- * class Renderer
3
- *
4
- * Generates HTML from parsed token stream. Each instance has independent
5
- * copy of rules. Those can be rewritten with ease. Also, you can add new
6
- * rules if you create plugin and adds new token types.
7
- **/
8
- 'use strict';
9
-
10
-
11
- var assign = require('./common/utils').assign;
12
- var unescapeAll = require('./common/utils').unescapeAll;
13
- var escapeHtml = require('./common/utils').escapeHtml;
14
-
15
-
16
- ////////////////////////////////////////////////////////////////////////////////
17
-
18
- var default_rules = {};
19
-
20
-
21
- default_rules.code_inline = function (tokens, idx, options, env, slf) {
22
- var token = tokens[idx];
23
-
24
- return '<code' + slf.renderAttrs(token) + '>' +
25
- escapeHtml(token.content) +
26
- '</code>';
27
- };
28
-
29
-
30
- default_rules.code_block = function (tokens, idx, options, env, slf) {
31
- var token = tokens[idx];
32
-
33
- return '<pre' + slf.renderAttrs(token) + '><code>' +
34
- escapeHtml(tokens[idx].content) +
35
- '</code></pre>\n';
36
- };
37
-
38
-
39
- default_rules.fence = function (tokens, idx, options, env, slf) {
40
- var token = tokens[idx],
41
- info = token.info ? unescapeAll(token.info).trim() : '',
42
- langName = '',
43
- langAttrs = '',
44
- highlighted, i, arr, tmpAttrs, tmpToken;
45
-
46
- if (info) {
47
- arr = info.split(/(\s+)/g);
48
- langName = arr[0];
49
- langAttrs = arr.slice(2).join('');
50
- }
51
-
52
- if (options.highlight) {
53
- highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
54
- } else {
55
- highlighted = escapeHtml(token.content);
56
- }
57
-
58
- if (highlighted.indexOf('<pre') === 0) {
59
- return highlighted + '\n';
60
- }
61
-
62
- // If language exists, inject class gently, without modifying original token.
63
- // May be, one day we will add .deepClone() for token and simplify this part, but
64
- // now we prefer to keep things local.
65
- if (info) {
66
- i = token.attrIndex('class');
67
- tmpAttrs = token.attrs ? token.attrs.slice() : [];
68
-
69
- if (i < 0) {
70
- tmpAttrs.push([ 'class', options.langPrefix + langName ]);
71
- } else {
72
- tmpAttrs[i] = tmpAttrs[i].slice();
73
- tmpAttrs[i][1] += ' ' + options.langPrefix + langName;
74
- }
75
-
76
- // Fake token just to render attributes
77
- tmpToken = {
78
- attrs: tmpAttrs
79
- };
80
-
81
- return '<pre><code' + slf.renderAttrs(tmpToken) + '>'
82
- + highlighted
83
- + '</code></pre>\n';
84
- }
85
-
86
-
87
- return '<pre><code' + slf.renderAttrs(token) + '>'
88
- + highlighted
89
- + '</code></pre>\n';
90
- };
91
-
92
-
93
- default_rules.image = function (tokens, idx, options, env, slf) {
94
- var token = tokens[idx];
95
-
96
- // "alt" attr MUST be set, even if empty. Because it's mandatory and
97
- // should be placed on proper position for tests.
98
- //
99
- // Replace content with actual value
100
-
101
- token.attrs[token.attrIndex('alt')][1] =
102
- slf.renderInlineAsText(token.children, options, env);
103
-
104
- return slf.renderToken(tokens, idx, options);
105
- };
106
-
107
-
108
- default_rules.hardbreak = function (tokens, idx, options /*, env */) {
109
- return options.xhtmlOut ? '<br />\n' : '<br>\n';
110
- };
111
- default_rules.softbreak = function (tokens, idx, options /*, env */) {
112
- return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
113
- };
114
-
115
-
116
- default_rules.text = function (tokens, idx /*, options, env */) {
117
- return escapeHtml(tokens[idx].content);
118
- };
119
-
120
-
121
- default_rules.html_block = function (tokens, idx /*, options, env */) {
122
- return tokens[idx].content;
123
- };
124
- default_rules.html_inline = function (tokens, idx /*, options, env */) {
125
- return tokens[idx].content;
126
- };
127
-
128
-
129
- /**
130
- * new Renderer()
131
- *
132
- * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
133
- **/
134
- function Renderer() {
135
-
136
- /**
137
- * Renderer#rules -> Object
138
- *
139
- * Contains render rules for tokens. Can be updated and extended.
140
- *
141
- * ##### Example
142
- *
143
- * ```javascript
144
- * var md = require('markdown-it')();
145
- *
146
- * md.renderer.rules.strong_open = function () { return '<b>'; };
147
- * md.renderer.rules.strong_close = function () { return '</b>'; };
148
- *
149
- * var result = md.renderInline(...);
150
- * ```
151
- *
152
- * Each rule is called as independent static function with fixed signature:
153
- *
154
- * ```javascript
155
- * function my_token_render(tokens, idx, options, env, renderer) {
156
- * // ...
157
- * return renderedHTML;
158
- * }
159
- * ```
160
- *
161
- * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
162
- * for more details and examples.
163
- **/
164
- this.rules = assign({}, default_rules);
165
- }
166
-
167
-
168
- /**
169
- * Renderer.renderAttrs(token) -> String
170
- *
171
- * Render token attributes to string.
172
- **/
173
- Renderer.prototype.renderAttrs = function renderAttrs(token) {
174
- var i, l, result;
175
-
176
- if (!token.attrs) { return ''; }
177
-
178
- result = '';
179
-
180
- for (i = 0, l = token.attrs.length; i < l; i++) {
181
- result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
182
- }
183
-
184
- return result;
185
- };
186
-
187
-
188
- /**
189
- * Renderer.renderToken(tokens, idx, options) -> String
190
- * - tokens (Array): list of tokens
191
- * - idx (Numbed): token index to render
192
- * - options (Object): params of parser instance
193
- *
194
- * Default token renderer. Can be overriden by custom function
195
- * in [[Renderer#rules]].
196
- **/
197
- Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
198
- var nextToken,
199
- result = '',
200
- needLf = false,
201
- token = tokens[idx];
202
-
203
- // Tight list paragraphs
204
- if (token.hidden) {
205
- return '';
206
- }
207
-
208
- // Insert a newline between hidden paragraph and subsequent opening
209
- // block-level tag.
210
- //
211
- // For example, here we should insert a newline before blockquote:
212
- // - a
213
- // >
214
- //
215
- if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
216
- result += '\n';
217
- }
218
-
219
- // Add token name, e.g. `<img`
220
- result += (token.nesting === -1 ? '</' : '<') + token.tag;
221
-
222
- // Encode attributes, e.g. `<img src="foo"`
223
- result += this.renderAttrs(token);
224
-
225
- // Add a slash for self-closing tags, e.g. `<img src="foo" /`
226
- if (token.nesting === 0 && options.xhtmlOut) {
227
- result += ' /';
228
- }
229
-
230
- // Check if we need to add a newline after this tag
231
- if (token.block) {
232
- needLf = true;
233
-
234
- if (token.nesting === 1) {
235
- if (idx + 1 < tokens.length) {
236
- nextToken = tokens[idx + 1];
237
-
238
- if (nextToken.type === 'inline' || nextToken.hidden) {
239
- // Block-level tag containing an inline tag.
240
- //
241
- needLf = false;
242
-
243
- } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
244
- // Opening tag + closing tag of the same type. E.g. `<li></li>`.
245
- //
246
- needLf = false;
247
- }
248
- }
249
- }
250
- }
251
-
252
- result += needLf ? '>\n' : '>';
253
-
254
- return result;
255
- };
256
-
257
-
258
- /**
259
- * Renderer.renderInline(tokens, options, env) -> String
260
- * - tokens (Array): list on block tokens to render
261
- * - options (Object): params of parser instance
262
- * - env (Object): additional data from parsed input (references, for example)
263
- *
264
- * The same as [[Renderer.render]], but for single token of `inline` type.
265
- **/
266
- Renderer.prototype.renderInline = function (tokens, options, env) {
267
- var type,
268
- result = '',
269
- rules = this.rules;
270
-
271
- for (var i = 0, len = tokens.length; i < len; i++) {
272
- type = tokens[i].type;
273
-
274
- if (typeof rules[type] !== 'undefined') {
275
- result += rules[type](tokens, i, options, env, this);
276
- } else {
277
- result += this.renderToken(tokens, i, options);
278
- }
279
- }
280
-
281
- return result;
282
- };
283
-
284
-
285
- /** internal
286
- * Renderer.renderInlineAsText(tokens, options, env) -> String
287
- * - tokens (Array): list on block tokens to render
288
- * - options (Object): params of parser instance
289
- * - env (Object): additional data from parsed input (references, for example)
290
- *
291
- * Special kludge for image `alt` attributes to conform CommonMark spec.
292
- * Don't try to use it! Spec requires to show `alt` content with stripped markup,
293
- * instead of simple escaping.
294
- **/
295
- Renderer.prototype.renderInlineAsText = function (tokens, options, env) {
296
- var result = '';
297
-
298
- for (var i = 0, len = tokens.length; i < len; i++) {
299
- if (tokens[i].type === 'text') {
300
- result += tokens[i].content;
301
- } else if (tokens[i].type === 'image') {
302
- result += this.renderInlineAsText(tokens[i].children, options, env);
303
- } else if (tokens[i].type === 'softbreak') {
304
- result += '\n';
305
- }
306
- }
307
-
308
- return result;
309
- };
310
-
311
-
312
- /**
313
- * Renderer.render(tokens, options, env) -> String
314
- * - tokens (Array): list on block tokens to render
315
- * - options (Object): params of parser instance
316
- * - env (Object): additional data from parsed input (references, for example)
317
- *
318
- * Takes token stream and generates HTML. Probably, you will never need to call
319
- * this method directly.
320
- **/
321
- Renderer.prototype.render = function (tokens, options, env) {
322
- var i, len, type,
323
- result = '',
324
- rules = this.rules;
325
-
326
- for (i = 0, len = tokens.length; i < len; i++) {
327
- type = tokens[i].type;
328
-
329
- if (type === 'inline') {
330
- result += this.renderInline(tokens[i].children, options, env);
331
- } else if (typeof rules[type] !== 'undefined') {
332
- result += rules[type](tokens, i, options, env, this);
333
- } else {
334
- result += this.renderToken(tokens, i, options, env);
335
- }
336
- }
337
-
338
- return result;
339
- };
340
-
341
- module.exports = Renderer;
@@ -1,352 +0,0 @@
1
- /**
2
- * class Ruler
3
- *
4
- * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
5
- * [[MarkdownIt#inline]] to manage sequences of functions (rules):
6
- *
7
- * - keep rules in defined order
8
- * - assign the name to each rule
9
- * - enable/disable rules
10
- * - add/replace rules
11
- * - allow assign rules to additional named chains (in the same)
12
- * - cacheing lists of active rules
13
- *
14
- * You will not need use this class directly until write plugins. For simple
15
- * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
16
- * [[MarkdownIt.use]].
17
- **/
18
- 'use strict';
19
-
20
-
21
- /**
22
- * new Ruler()
23
- **/
24
- function Ruler() {
25
- // List of added rules. Each element is:
26
- //
27
- // {
28
- // name: XXX,
29
- // enabled: Boolean,
30
- // fn: Function(),
31
- // alt: [ name2, name3 ]
32
- // }
33
- //
34
- this.__rules__ = [];
35
-
36
- // Cached rule chains.
37
- //
38
- // First level - chain name, '' for default.
39
- // Second level - diginal anchor for fast filtering by charcodes.
40
- //
41
- this.__cache__ = null;
42
- }
43
-
44
- ////////////////////////////////////////////////////////////////////////////////
45
- // Helper methods, should not be used directly
46
-
47
-
48
- // Find rule index by name
49
- //
50
- Ruler.prototype.__find__ = function (name) {
51
- for (var i = 0; i < this.__rules__.length; i++) {
52
- if (this.__rules__[i].name === name) {
53
- return i;
54
- }
55
- }
56
- return -1;
57
- };
58
-
59
-
60
- // Build rules lookup cache
61
- //
62
- Ruler.prototype.__compile__ = function () {
63
- var self = this;
64
- var chains = [ '' ];
65
-
66
- // collect unique names
67
- self.__rules__.forEach(function (rule) {
68
- if (!rule.enabled) { return; }
69
-
70
- rule.alt.forEach(function (altName) {
71
- if (chains.indexOf(altName) < 0) {
72
- chains.push(altName);
73
- }
74
- });
75
- });
76
-
77
- self.__cache__ = {};
78
-
79
- chains.forEach(function (chain) {
80
- self.__cache__[chain] = [];
81
- self.__rules__.forEach(function (rule) {
82
- if (!rule.enabled) { return; }
83
-
84
- if (chain && rule.alt.indexOf(chain) < 0) { return; }
85
-
86
- self.__cache__[chain].push(rule.fn);
87
- });
88
- });
89
- };
90
-
91
-
92
- /**
93
- * Ruler.at(name, fn [, options])
94
- * - name (String): rule name to replace.
95
- * - fn (Function): new rule function.
96
- * - options (Object): new rule options (not mandatory).
97
- *
98
- * Replace rule by name with new function & options. Throws error if name not
99
- * found.
100
- *
101
- * ##### Options:
102
- *
103
- * - __alt__ - array with names of "alternate" chains.
104
- *
105
- * ##### Example
106
- *
107
- * Replace existing typographer replacement rule with new one:
108
- *
109
- * ```javascript
110
- * var md = require('markdown-it')();
111
- *
112
- * md.core.ruler.at('replacements', function replace(state) {
113
- * //...
114
- * });
115
- * ```
116
- **/
117
- Ruler.prototype.at = function (name, fn, options) {
118
- var index = this.__find__(name);
119
- var opt = options || {};
120
-
121
- if (index === -1) { throw new Error('Parser rule not found: ' + name); }
122
-
123
- this.__rules__[index].fn = fn;
124
- this.__rules__[index].alt = opt.alt || [];
125
- this.__cache__ = null;
126
- };
127
-
128
-
129
- /**
130
- * Ruler.before(beforeName, ruleName, fn [, options])
131
- * - beforeName (String): new rule will be added before this one.
132
- * - ruleName (String): name of added rule.
133
- * - fn (Function): rule function.
134
- * - options (Object): rule options (not mandatory).
135
- *
136
- * Add new rule to chain before one with given name. See also
137
- * [[Ruler.after]], [[Ruler.push]].
138
- *
139
- * ##### Options:
140
- *
141
- * - __alt__ - array with names of "alternate" chains.
142
- *
143
- * ##### Example
144
- *
145
- * ```javascript
146
- * var md = require('markdown-it')();
147
- *
148
- * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
149
- * //...
150
- * });
151
- * ```
152
- **/
153
- Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
154
- var index = this.__find__(beforeName);
155
- var opt = options || {};
156
-
157
- if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }
158
-
159
- this.__rules__.splice(index, 0, {
160
- name: ruleName,
161
- enabled: true,
162
- fn: fn,
163
- alt: opt.alt || []
164
- });
165
-
166
- this.__cache__ = null;
167
- };
168
-
169
-
170
- /**
171
- * Ruler.after(afterName, ruleName, fn [, options])
172
- * - afterName (String): new rule will be added after this one.
173
- * - ruleName (String): name of added rule.
174
- * - fn (Function): rule function.
175
- * - options (Object): rule options (not mandatory).
176
- *
177
- * Add new rule to chain after one with given name. See also
178
- * [[Ruler.before]], [[Ruler.push]].
179
- *
180
- * ##### Options:
181
- *
182
- * - __alt__ - array with names of "alternate" chains.
183
- *
184
- * ##### Example
185
- *
186
- * ```javascript
187
- * var md = require('markdown-it')();
188
- *
189
- * md.inline.ruler.after('text', 'my_rule', function replace(state) {
190
- * //...
191
- * });
192
- * ```
193
- **/
194
- Ruler.prototype.after = function (afterName, ruleName, fn, options) {
195
- var index = this.__find__(afterName);
196
- var opt = options || {};
197
-
198
- if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }
199
-
200
- this.__rules__.splice(index + 1, 0, {
201
- name: ruleName,
202
- enabled: true,
203
- fn: fn,
204
- alt: opt.alt || []
205
- });
206
-
207
- this.__cache__ = null;
208
- };
209
-
210
- /**
211
- * Ruler.push(ruleName, fn [, options])
212
- * - ruleName (String): name of added rule.
213
- * - fn (Function): rule function.
214
- * - options (Object): rule options (not mandatory).
215
- *
216
- * Push new rule to the end of chain. See also
217
- * [[Ruler.before]], [[Ruler.after]].
218
- *
219
- * ##### Options:
220
- *
221
- * - __alt__ - array with names of "alternate" chains.
222
- *
223
- * ##### Example
224
- *
225
- * ```javascript
226
- * var md = require('markdown-it')();
227
- *
228
- * md.core.ruler.push('my_rule', function replace(state) {
229
- * //...
230
- * });
231
- * ```
232
- **/
233
- Ruler.prototype.push = function (ruleName, fn, options) {
234
- var opt = options || {};
235
-
236
- this.__rules__.push({
237
- name: ruleName,
238
- enabled: true,
239
- fn: fn,
240
- alt: opt.alt || []
241
- });
242
-
243
- this.__cache__ = null;
244
- };
245
-
246
-
247
- /**
248
- * Ruler.enable(list [, ignoreInvalid]) -> Array
249
- * - list (String|Array): list of rule names to enable.
250
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
251
- *
252
- * Enable rules with given names. If any rule name not found - throw Error.
253
- * Errors can be disabled by second param.
254
- *
255
- * Returns list of found rule names (if no exception happened).
256
- *
257
- * See also [[Ruler.disable]], [[Ruler.enableOnly]].
258
- **/
259
- Ruler.prototype.enable = function (list, ignoreInvalid) {
260
- if (!Array.isArray(list)) { list = [ list ]; }
261
-
262
- var result = [];
263
-
264
- // Search by name and enable
265
- list.forEach(function (name) {
266
- var idx = this.__find__(name);
267
-
268
- if (idx < 0) {
269
- if (ignoreInvalid) { return; }
270
- throw new Error('Rules manager: invalid rule name ' + name);
271
- }
272
- this.__rules__[idx].enabled = true;
273
- result.push(name);
274
- }, this);
275
-
276
- this.__cache__ = null;
277
- return result;
278
- };
279
-
280
-
281
- /**
282
- * Ruler.enableOnly(list [, ignoreInvalid])
283
- * - list (String|Array): list of rule names to enable (whitelist).
284
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
285
- *
286
- * Enable rules with given names, and disable everything else. If any rule name
287
- * not found - throw Error. Errors can be disabled by second param.
288
- *
289
- * See also [[Ruler.disable]], [[Ruler.enable]].
290
- **/
291
- Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
292
- if (!Array.isArray(list)) { list = [ list ]; }
293
-
294
- this.__rules__.forEach(function (rule) { rule.enabled = false; });
295
-
296
- this.enable(list, ignoreInvalid);
297
- };
298
-
299
-
300
- /**
301
- * Ruler.disable(list [, ignoreInvalid]) -> Array
302
- * - list (String|Array): list of rule names to disable.
303
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
304
- *
305
- * Disable rules with given names. If any rule name not found - throw Error.
306
- * Errors can be disabled by second param.
307
- *
308
- * Returns list of found rule names (if no exception happened).
309
- *
310
- * See also [[Ruler.enable]], [[Ruler.enableOnly]].
311
- **/
312
- Ruler.prototype.disable = function (list, ignoreInvalid) {
313
- if (!Array.isArray(list)) { list = [ list ]; }
314
-
315
- var result = [];
316
-
317
- // Search by name and disable
318
- list.forEach(function (name) {
319
- var idx = this.__find__(name);
320
-
321
- if (idx < 0) {
322
- if (ignoreInvalid) { return; }
323
- throw new Error('Rules manager: invalid rule name ' + name);
324
- }
325
- this.__rules__[idx].enabled = false;
326
- result.push(name);
327
- }, this);
328
-
329
- this.__cache__ = null;
330
- return result;
331
- };
332
-
333
-
334
- /**
335
- * Ruler.getRules(chainName) -> Array
336
- *
337
- * Return array of active functions (rules) for given chain name. It analyzes
338
- * rules configuration, compiles caches if not exists and returns result.
339
- *
340
- * Default chain name is `''` (empty string). It can't be skipped. That's
341
- * done intentionally, to keep signature monomorphic for high speed.
342
- **/
343
- Ruler.prototype.getRules = function (chainName) {
344
- if (this.__cache__ === null) {
345
- this.__compile__();
346
- }
347
-
348
- // Chain can be empty, if rules disabled. But we still have to return Array.
349
- return this.__cache__[chainName] || [];
350
- };
351
-
352
- module.exports = Ruler;