@openclaw/matrix 2026.7.2-beta.7 → 2026.7.34

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 (368) hide show
  1. package/README.md +1 -1
  2. package/dist/{account-selection-kqquRzCf.js → .setup/account-selection-BOQeTqax.mjs} +18 -17
  3. package/dist/{approval-handler.runtime-DSeaIsGa.js → .setup/approval-handler.runtime-CEXm9_-p.mjs} +18 -28
  4. package/dist/{approval-ids-BdJGPAJT.js → .setup/approval-ids-DdFnDB3h.mjs} +1 -1
  5. package/dist/{approval-reaction-auth-BjOpELxu.js → .setup/approval-reaction-auth-CREvd7S7.mjs} +2 -2
  6. package/dist/.setup/approval-reactions-Cltyp8nL.mjs +113 -0
  7. package/dist/.setup/async-lock-BcLS4KOc.mjs +19 -0
  8. package/dist/{channel-vj788dNZ.js → .setup/channel-an4umty1.mjs} +186 -144
  9. package/dist/{channel.runtime-CLoF2S9T.js → .setup/channel.runtime-GHcIBJ7H.mjs} +51 -45
  10. package/dist/{cli-DMqfDE-q.js → .setup/cli-B3WYmv5U.mjs} +882 -901
  11. package/dist/{cli-metadata-C7D53SND.js → .setup/cli-metadata-RUKCn0wJ.mjs} +1 -1
  12. package/dist/{client-6eRENr7k.js → .setup/client-Ct0bUHCo.mjs} +5 -5
  13. package/dist/{shared-CUMWxcMz.js → .setup/client-DFBQtzCe.mjs} +422 -179
  14. package/dist/.setup/client-bootstrap-Be8jvNle.mjs +74 -0
  15. package/dist/{config-schema-Djxw3C6b.js → .setup/config-schema-D9J_vUF6.mjs} +89 -70
  16. package/dist/.setup/credentials-BhZlA0kL.mjs +56 -0
  17. package/dist/.setup/credentials-read-CRHg6XPm.mjs +114 -0
  18. package/dist/{credentials-write.runtime-Be9zNSUw.js → .setup/credentials-write.runtime-dWuLafsk.mjs} +1 -1
  19. package/dist/{crypto-runtime-D9_6J5tZ.js → .setup/crypto-runtime-D-cZa8P0.mjs} +81 -35
  20. package/dist/.setup/crypto-state-store-B43k3z3W.mjs +352 -0
  21. package/dist/{deps-CcVJfvRM.js → .setup/deps-Dy6yreL4.mjs} +92 -25
  22. package/dist/{device-health-B4-YXtJR.js → .setup/device-health-D4LBxuPq.mjs} +1 -6
  23. package/dist/{directory-live-C8dVBiCc.js → .setup/directory-live-BTEYxMwy.mjs} +10 -9
  24. package/dist/.setup/doctor-BGnvMzOR.mjs +169 -0
  25. package/dist/.setup/doctor-contract-DNJw0fdq.mjs +246 -0
  26. package/dist/{draft-stream-CtvOXq0Z.js → .setup/draft-stream-C-_OhpE8.mjs} +1 -6
  27. package/dist/{encryption-guidance-CbEFe38F.js → .setup/encryption-guidance-CpuuwmjL.mjs} +4 -3
  28. package/dist/{env-auth-CQsYbz-p.js → .setup/env-auth-CYJL1jNl.mjs} +2 -2
  29. package/dist/{env-vars-B0NxQnPk.js → .setup/env-vars-KzaYveuy.mjs} +1 -3
  30. package/dist/{exec-approval-resolver-BCgqRtZS.js → .setup/exec-approval-resolver-f9j6staN.mjs} +1 -2
  31. package/dist/{file-sync-store-DiiFsayX.js → .setup/file-sync-store-DU0cnYAz.mjs} +30 -25
  32. package/dist/{http-client-CycYxU9-.js → .setup/http-client-C954In2D.mjs} +45 -25
  33. package/dist/{idb-persistence-B6x7dMsF.js → .setup/idb-persistence-_HKTXkVC.mjs} +76 -78
  34. package/dist/{idb-persistence-lock-DAJ49nZX.js → .setup/idb-persistence-lock-B3fZXyF_.mjs} +1 -1
  35. package/dist/.setup/legacy-crypto-inspector-Byp8LCys.mjs +42 -0
  36. package/dist/.setup/legacy-crypto-restore-YQVoK1B2.mjs +93 -0
  37. package/dist/{logger-D0GCSDQq.js → .setup/logger-DpoogOgz.mjs} +1 -1
  38. package/dist/{logging-DV-p52N0.js → .setup/logging-CgxQOJJP.mjs} +2 -9
  39. package/dist/.setup/matrix-migration.runtime-BDH5c3fN.mjs +530 -0
  40. package/dist/{media-text-BTwzADS_.js → .setup/media-text-Cib-dxkn.mjs} +1 -1
  41. package/dist/{messages-DxQJkhxs.js → .setup/messages-D4DYGHYX.mjs} +15 -67
  42. package/dist/.setup/migration-snapshot-backup-CpgYhiUp.mjs +70 -0
  43. package/dist/.setup/migration-snapshot.runtime-O8qkMVaC.mjs +2 -0
  44. package/dist/{monitor-VyWlSLwo.js → .setup/monitor-DNcW_oAN.mjs} +2525 -2361
  45. package/dist/.setup/probe.runtime-CMPh0mFk.mjs +2 -0
  46. package/dist/{profile-update-CffmyW_4.js → .setup/profile-update-DzOL3Wiw.mjs} +5 -4
  47. package/dist/{reaction-events-B00WSi98.js → .setup/reaction-events-BcvgXxHb.mjs} +14 -64
  48. package/dist/{resolve-targets-nm2L48sh.js → .setup/resolve-targets-Bq80X9Sn.mjs} +3 -3
  49. package/dist/{resolver.runtime-DS6uPaEe.js → .setup/resolver.runtime-CeBHR9-T.mjs} +1 -1
  50. package/dist/{runtime-api-D1xI_cvh.js → .setup/runtime-api-CEsWNdil.mjs} +4 -4
  51. package/dist/.setup/runtime-setter-api-DGMubGUq.mjs +3 -0
  52. package/dist/{sdk-bUytQHx7.js → .setup/sdk-He1quVAq.mjs} +592 -261
  53. package/dist/.setup/secret-contract-api-CiTJ7pd5.mjs +3 -0
  54. package/dist/{secret-contract-M3hRmGO-.js → .setup/secret-contract-phPvlNfV.mjs} +53 -28
  55. package/dist/{send-BldGYG8g.js → .setup/send-CGgl0uTn.mjs} +133 -660
  56. package/dist/{setup-bootstrap-Deleiibz.js → .setup/setup-bootstrap-DUXBC8X2.mjs} +4 -4
  57. package/dist/{setup-core-BVfBv2ai.js → .setup/setup-core-bhdcEo7v.mjs} +239 -189
  58. package/dist/.setup/setup-plugin-api-CAwZ_Bi7.mjs +43 -0
  59. package/dist/.setup/setup-plugin-api-DIFVsOs3.mjs +2 -0
  60. package/dist/{setup-surface-BBq3WeqX.js → .setup/setup-surface-05_G-MnT.mjs} +149 -92
  61. package/dist/{startup-verification-wm3_i88s.js → .setup/startup-verification-BTwIGu1J.mjs} +7 -6
  62. package/dist/.setup/storage-NGZq5zet.mjs +432 -0
  63. package/dist/{storage-paths-gUmSydsW.js → .setup/storage-paths-BWo_ZEMC.mjs} +13 -2
  64. package/dist/{subagent-hooks-dkPAF6Et.js → .setup/subagent-hooks-BSWPJEmo.mjs} +2 -2
  65. package/dist/{thread-binding-api-DRbBZlhS.js → .setup/thread-binding-api-B7UaOoKv.mjs} +1 -1
  66. package/dist/{thread-bindings-DGbl3vDW.js → .setup/thread-bindings-DqmjG2on.mjs} +8 -8
  67. package/dist/{tool-actions.runtime-uu9blSqO.js → .setup/tool-actions.runtime-CXDLk2jg.mjs} +196 -332
  68. package/dist/{verification-DYMQ1QpI.js → .setup/verification-DeWOtZJr.mjs} +4 -3
  69. package/dist/api.js +9 -9
  70. package/dist/auth-presence.js +21 -13
  71. package/dist/channel-plugin-api.js +1 -1
  72. package/dist/cli-metadata.js +1 -1
  73. package/dist/contract-api.js +2 -2
  74. package/dist/doctor-contract-api.js +99 -524
  75. package/dist/helper-api.js +4 -4
  76. package/dist/index.js +1 -1
  77. package/dist/plugin-entry.handlers.runtime.js +2 -2
  78. package/dist/runtime-api.js +8 -8
  79. package/dist/runtime-heavy-api.js +3 -0
  80. package/dist/runtime-setter-api.js +1 -1
  81. package/dist/secret-contract-api.js +1 -1
  82. package/dist/session-binding-contract-api.js +3 -3
  83. package/dist/setup-entry.js +4 -3
  84. package/dist/setup-plugin-api.js +1 -44
  85. package/dist/subagent-hooks-api.js +1 -1
  86. package/dist/thread-binding-api.js +1 -1
  87. package/dist/thread-bindings-runtime.js +1 -1
  88. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
  89. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +2 -14
  90. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +384 -409
  91. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +224 -246
  92. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
  93. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -59
  94. package/node_modules/markdown-it/README.md +18 -294
  95. package/node_modules/markdown-it/bin/markdown-it.mjs +2 -2
  96. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +3013 -0
  97. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -0
  98. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +14 -0
  99. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -0
  100. package/node_modules/markdown-it/dist/markdown-it.cjs.js +4420 -0
  101. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -0
  102. package/node_modules/markdown-it/dist/markdown-it.d.cts +19 -0
  103. package/node_modules/markdown-it/dist/markdown-it.d.mts +950 -0
  104. package/node_modules/markdown-it/dist/{index.cjs.js → markdown-it.mjs} +1504 -1525
  105. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -0
  106. package/node_modules/markdown-it/node_modules/argparse/LICENSE +1 -208
  107. package/node_modules/markdown-it/node_modules/argparse/README.md +46 -41
  108. package/node_modules/markdown-it/node_modules/argparse/lib/_colorize.js +72 -0
  109. package/node_modules/markdown-it/node_modules/argparse/lib/argparse.d.ts +292 -0
  110. package/node_modules/markdown-it/node_modules/argparse/{argparse.js → lib/argparse.js} +1142 -1029
  111. package/node_modules/markdown-it/node_modules/argparse/lib/difflib.js +190 -0
  112. package/node_modules/markdown-it/node_modules/argparse/lib/sub.js +4 -4
  113. package/node_modules/markdown-it/node_modules/argparse/lib/textwrap.js +28 -28
  114. package/node_modules/markdown-it/node_modules/argparse/package.json +18 -11
  115. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts +8 -0
  116. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
  117. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js +46 -0
  118. package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js.map +1 -0
  119. package/node_modules/markdown-it/node_modules/entities/{lib → dist}/decode.d.ts +28 -45
  120. package/node_modules/markdown-it/node_modules/entities/dist/decode.d.ts.map +1 -0
  121. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.js +189 -141
  122. package/node_modules/markdown-it/node_modules/entities/dist/decode.js.map +1 -0
  123. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/encode.d.ts +4 -2
  124. package/node_modules/markdown-it/node_modules/entities/dist/encode.d.ts.map +1 -0
  125. package/node_modules/markdown-it/node_modules/entities/dist/encode.js +90 -0
  126. package/node_modules/markdown-it/node_modules/entities/dist/encode.js.map +1 -0
  127. package/node_modules/markdown-it/node_modules/entities/{lib → dist}/escape.d.ts +15 -10
  128. package/node_modules/markdown-it/node_modules/entities/dist/escape.d.ts.map +1 -0
  129. package/node_modules/markdown-it/node_modules/entities/dist/escape.js +132 -0
  130. package/node_modules/markdown-it/node_modules/entities/dist/escape.js.map +1 -0
  131. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
  132. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
  133. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js +5 -0
  134. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
  135. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
  136. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
  137. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js +5 -0
  138. package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
  139. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts +5 -0
  140. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
  141. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js +12 -0
  142. package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js.map +1 -0
  143. package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/index.d.ts +14 -21
  144. package/node_modules/markdown-it/node_modules/entities/dist/index.d.ts.map +1 -0
  145. package/node_modules/markdown-it/node_modules/entities/dist/index.js +91 -0
  146. package/node_modules/markdown-it/node_modules/entities/dist/index.js.map +1 -0
  147. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts +17 -0
  148. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
  149. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js +18 -0
  150. package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
  151. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts +7 -0
  152. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
  153. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js +17 -0
  154. package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
  155. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts +33 -0
  156. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts.map +1 -0
  157. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js +93 -0
  158. package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js.map +1 -0
  159. package/node_modules/markdown-it/node_modules/entities/package.json +63 -70
  160. package/node_modules/markdown-it/node_modules/entities/readme.md +54 -45
  161. package/node_modules/markdown-it/node_modules/entities/src/decode-codepoint.ts +50 -0
  162. package/node_modules/markdown-it/node_modules/entities/src/decode.ts +671 -0
  163. package/node_modules/markdown-it/node_modules/entities/src/encode.ts +95 -0
  164. package/node_modules/markdown-it/node_modules/entities/src/escape.ts +160 -0
  165. package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-html.ts +7 -0
  166. package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
  167. package/node_modules/markdown-it/node_modules/entities/src/generated/encode-html.ts +18 -0
  168. package/node_modules/markdown-it/node_modules/entities/src/index.ts +162 -0
  169. package/node_modules/markdown-it/node_modules/entities/src/internal/bin-trie-flags.ts +16 -0
  170. package/node_modules/markdown-it/node_modules/entities/src/internal/decode-shared.ts +18 -0
  171. package/node_modules/markdown-it/node_modules/entities/src/internal/encode-shared.ts +123 -0
  172. package/node_modules/markdown-it/node_modules/linkify-it/README.md +49 -86
  173. package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js +636 -825
  174. package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js.map +1 -0
  175. package/node_modules/markdown-it/node_modules/linkify-it/build/index.d.ts +236 -0
  176. package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs +538 -0
  177. package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs.map +1 -0
  178. package/node_modules/markdown-it/node_modules/linkify-it/package.json +23 -20
  179. package/node_modules/markdown-it/node_modules/uc.micro/README.md +18 -1
  180. package/node_modules/markdown-it/node_modules/uc.micro/build/index.cjs.js +13 -18
  181. package/node_modules/markdown-it/node_modules/uc.micro/build/index.d.ts +6 -0
  182. package/node_modules/markdown-it/node_modules/uc.micro/build/index.mjs +8 -0
  183. package/node_modules/markdown-it/node_modules/uc.micro/package.json +12 -17
  184. package/node_modules/markdown-it/package.json +47 -30
  185. package/node_modules/matrix-js-sdk/CHANGELOG.md +0 -11
  186. package/node_modules/matrix-js-sdk/package.json +1 -1
  187. package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
  188. package/node_modules/music-metadata/lib/common/Util.js +1 -7
  189. package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +3 -23
  190. package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
  191. package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
  192. package/node_modules/music-metadata/lib/mp4/AtomToken.js +13 -38
  193. package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
  194. package/node_modules/music-metadata/package.json +6 -6
  195. package/node_modules/typebox/build/compile/validator.d.mts +4 -1
  196. package/node_modules/typebox/build/guard/guard.d.mts +1 -1
  197. package/node_modules/typebox/build/guard/guard.mjs +2 -5
  198. package/node_modules/typebox/build/guard/string.mjs +4 -16
  199. package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
  200. package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
  201. package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
  202. package/node_modules/typebox/build/typebox.d.mts +1 -1
  203. package/node_modules/typebox/build/typebox.mjs +1 -1
  204. package/node_modules/typebox/package.json +1 -1
  205. package/node_modules/typebox/readme.md +32 -29
  206. package/openclaw.plugin.json +146 -152
  207. package/package.json +31 -114
  208. package/dist/accounts-DfngqebB.js +0 -130
  209. package/dist/active-client-DXvz2gCo.js +0 -20
  210. package/dist/approval-reactions-D-BxBK_L.js +0 -202
  211. package/dist/client-Dbso3-0V.js +0 -30
  212. package/dist/client-bootstrap-XsIkHNt0.js +0 -110
  213. package/dist/create-client-BmSU-q-D.js +0 -61
  214. package/dist/credentials-W2EmwRhu.js +0 -65
  215. package/dist/credentials-read-DVmFCm7X.js +0 -77
  216. package/dist/doctor-CM8ijNpW.js +0 -64
  217. package/dist/doctor-contract-BMSJkkAE.js +0 -167
  218. package/dist/inbound-dedupe-CaBLblef.js +0 -48
  219. package/dist/probe.runtime-BuieqmS3.js +0 -3
  220. package/dist/record-shared-CWWx6fvI.js +0 -2
  221. package/dist/recovery-key-store-BNnHvXdk.js +0 -275
  222. package/dist/room-info-CAFZ3Z9J.js +0 -87
  223. package/dist/route-DY6at4qJ.js +0 -161
  224. package/dist/storage-BvAkgzvT.js +0 -685
  225. package/node_modules/markdown-it/dist/index.cjs.js.map +0 -1
  226. package/node_modules/markdown-it/dist/markdown-it.js +0 -3975
  227. package/node_modules/markdown-it/dist/markdown-it.js.map +0 -1
  228. package/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
  229. package/node_modules/markdown-it/dist/markdown-it.min.js.map +0 -1
  230. package/node_modules/markdown-it/index.mjs +0 -1
  231. package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
  232. package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
  233. package/node_modules/markdown-it/lib/common/utils.mjs +0 -324
  234. package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
  235. package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
  236. package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
  237. package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
  238. package/node_modules/markdown-it/lib/index.mjs +0 -565
  239. package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
  240. package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
  241. package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
  242. package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
  243. package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
  244. package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
  245. package/node_modules/markdown-it/lib/renderer.mjs +0 -322
  246. package/node_modules/markdown-it/lib/ruler.mjs +0 -340
  247. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
  248. package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
  249. package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
  250. package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
  251. package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
  252. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -80
  253. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -85
  254. package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
  255. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -48
  256. package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
  257. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
  258. package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
  259. package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
  260. package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
  261. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
  262. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
  263. package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
  264. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -209
  265. package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
  266. package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
  267. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
  268. package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
  269. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
  270. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
  271. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
  272. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -83
  273. package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
  274. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
  275. package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
  276. package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
  277. package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
  278. package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
  279. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -154
  280. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
  281. package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
  282. package/node_modules/markdown-it/lib/token.mjs +0 -191
  283. package/node_modules/markdown-it/node_modules/argparse/CHANGELOG.md +0 -216
  284. package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts.map +0 -1
  285. package/node_modules/markdown-it/node_modules/entities/lib/decode.js +0 -536
  286. package/node_modules/markdown-it/node_modules/entities/lib/decode.js.map +0 -1
  287. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
  288. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
  289. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js +0 -76
  290. package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js.map +0 -1
  291. package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts +0 -22
  292. package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts.map +0 -1
  293. package/node_modules/markdown-it/node_modules/entities/lib/encode.js +0 -77
  294. package/node_modules/markdown-it/node_modules/entities/lib/encode.js.map +0 -1
  295. package/node_modules/markdown-it/node_modules/entities/lib/escape.d.ts.map +0 -1
  296. package/node_modules/markdown-it/node_modules/entities/lib/escape.js +0 -122
  297. package/node_modules/markdown-it/node_modules/entities/lib/escape.js.map +0 -1
  298. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts +0 -211
  299. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
  300. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.js.map +0 -1
  301. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
  302. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
  303. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
  304. package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
  305. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
  306. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js +0 -69
  307. package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js.map +0 -1
  308. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts +0 -43
  309. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
  310. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js +0 -116
  311. package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js.map +0 -1
  312. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
  313. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
  314. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
  315. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
  316. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
  317. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
  318. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
  319. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
  320. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
  321. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
  322. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
  323. package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
  324. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts.map +0 -1
  325. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js +0 -99
  326. package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js.map +0 -1
  327. package/node_modules/markdown-it/node_modules/entities/lib/esm/package.json +0 -1
  328. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
  329. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
  330. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js +0 -9
  331. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
  332. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
  333. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
  334. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
  335. package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
  336. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
  337. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
  338. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js +0 -12
  339. package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js.map +0 -1
  340. package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts +0 -96
  341. package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts.map +0 -1
  342. package/node_modules/markdown-it/node_modules/entities/lib/index.js +0 -126
  343. package/node_modules/markdown-it/node_modules/entities/lib/index.js.map +0 -1
  344. package/node_modules/markdown-it/node_modules/linkify-it/index.mjs +0 -646
  345. package/node_modules/markdown-it/node_modules/linkify-it/lib/re.mjs +0 -193
  346. package/node_modules/markdown-it/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
  347. package/node_modules/markdown-it/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
  348. package/node_modules/markdown-it/node_modules/uc.micro/categories/P/regex.mjs +0 -1
  349. package/node_modules/markdown-it/node_modules/uc.micro/categories/S/regex.mjs +0 -1
  350. package/node_modules/markdown-it/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
  351. package/node_modules/markdown-it/node_modules/uc.micro/index.mjs +0 -8
  352. package/node_modules/markdown-it/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
  353. /package/dist/{account-config-BZWN9tGS.js → .setup/account-config-BZWN9tGS.mjs} +0 -0
  354. /package/dist/{backup-health-Dm_YMVFT.js → .setup/backup-health-Dm_YMVFT.mjs} +0 -0
  355. /package/dist/{config-paths-CnREYb1Y.js → .setup/config-paths-CnREYb1Y.mjs} +0 -0
  356. /package/dist/{config-secret-input.runtime-CwsP3--c.js → .setup/config-secret-input.runtime-CwsP3--c.mjs} +0 -0
  357. /package/dist/{crypto-node.runtime-6Aj_ltHQ.js → .setup/crypto-node.runtime-6Aj_ltHQ.mjs} +0 -0
  358. /package/dist/{errors-C47hvAF8.js → .setup/errors-C47hvAF8.mjs} +0 -0
  359. /package/dist/{preflight-audio.runtime-BZxxQsxY.js → .setup/preflight-audio.runtime-BZxxQsxY.mjs} +0 -0
  360. /package/dist/{reaction-common-DkrQdBSZ.js → .setup/reaction-common-DkrQdBSZ.mjs} +0 -0
  361. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  362. /package/dist/{runtime-6S3DNFNv.js → .setup/runtime-6S3DNFNv.mjs} +0 -0
  363. /package/dist/{runtime-BefyhPWv.js → .setup/runtime-BefyhPWv.mjs} +0 -0
  364. /package/dist/{sync-state-CWbp0QSY.js → .setup/sync-state-CWbp0QSY.mjs} +0 -0
  365. /package/dist/{target-ids-B-5aQxwn.js → .setup/target-ids-B-5aQxwn.mjs} +0 -0
  366. /package/dist/{thread-bindings-shared-CKnY4LSd.js → .setup/thread-bindings-shared-CKnY4LSd.mjs} +0 -0
  367. /package/dist/{timeout-abort-signal-DMrgRFIy.js → .setup/timeout-abort-signal-DMrgRFIy.mjs} +0 -0
  368. /package/dist/{url-validation-GRHde6lq.js → .setup/url-validation-GRHde6lq.mjs} +0 -0
@@ -1,10 +1,11 @@
1
+ /*! markdown-it 15.0.2 https://github.com/markdown-it/markdown-it @license MIT */
2
+ import * as mdurl from "mdurl";
3
+ import * as ucmicro from "uc.micro";
4
+ import { decodeHTMLStrict } from "entities";
5
+ import { LinkifyIt } from "linkify-it";
6
+ import punycode from "punycode.js";
1
7
  //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
9
  var __exportAll = (all, no_symbols) => {
9
10
  let target = {};
10
11
  for (var name in all) __defProp(target, name, {
@@ -14,44 +15,24 @@ var __exportAll = (all, no_symbols) => {
14
15
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
16
  return target;
16
17
  };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
- key = keys[i];
20
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
- get: ((k) => from[k]).bind(null, key),
22
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
- });
24
- }
25
- return to;
26
- };
27
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
30
- }) : target, mod));
31
18
  //#endregion
32
- let mdurl = require("mdurl");
33
- mdurl = __toESM(mdurl, 1);
34
- let uc_micro = require("uc.micro");
35
- uc_micro = __toESM(uc_micro, 1);
36
- let entities = require("entities");
37
- let linkify_it = require("linkify-it");
38
- linkify_it = __toESM(linkify_it, 1);
39
- let punycode_js = require("punycode.js");
40
- punycode_js = __toESM(punycode_js, 1);
41
- //#region lib/common/utils.mjs
19
+ //#region src/common/utils.ts
20
+ /**
21
+ * Common utility functions exposed through `md.utils` for use by plugins.
22
+ *
23
+ * @module md.utils
24
+ */
42
25
  var utils_exports = /* @__PURE__ */ __exportAll({
43
26
  arrayReplaceAt: () => arrayReplaceAt,
44
27
  asciiTrim: () => asciiTrim,
45
- assign: () => assign,
28
+ callable: () => callable,
46
29
  escapeHtml: () => escapeHtml,
47
30
  escapeRE: () => escapeRE,
48
31
  fromCodePoint: () => fromCodePoint,
49
- has: () => has,
50
32
  isMdAsciiPunct: () => isMdAsciiPunct,
51
33
  isPunctChar: () => isPunctChar,
52
34
  isPunctCharCode: () => isPunctCharCode,
53
35
  isSpace: () => isSpace,
54
- isString: () => isString,
55
36
  isValidEntityCode: () => isValidEntityCode,
56
37
  isWhiteSpace: () => isWhiteSpace,
57
38
  lib: () => lib,
@@ -59,29 +40,24 @@ var utils_exports = /* @__PURE__ */ __exportAll({
59
40
  unescapeAll: () => unescapeAll,
60
41
  unescapeMd: () => unescapeMd
61
42
  });
62
- function _class(obj) {
63
- return Object.prototype.toString.call(obj);
64
- }
65
- function isString(obj) {
66
- return _class(obj) === "[object String]";
67
- }
68
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
69
- function has(object, key) {
70
- return _hasOwnProperty.call(object, key);
71
- }
72
- function assign(obj) {
73
- Array.prototype.slice.call(arguments, 1).forEach(function(source) {
74
- if (!source) return;
75
- if (typeof source !== "object") throw new TypeError(source + "must be object");
76
- Object.keys(source).forEach(function(key) {
77
- obj[key] = source[key];
78
- });
79
- });
80
- return obj;
43
+ function callable(cls) {
44
+ const wrapper = function(...args) {
45
+ return Reflect.construct(cls, args, new.target && new.target !== wrapper ? new.target : cls);
46
+ };
47
+ Object.defineProperty(wrapper, "name", { value: cls.name });
48
+ Object.setPrototypeOf(wrapper, cls);
49
+ wrapper.prototype = cls.prototype;
50
+ return wrapper;
81
51
  }
52
+ /**
53
+ * Returns a copy of a token array with the token at `pos` replaced by
54
+ * `newElements`. Used to transform token streams without modifying the
55
+ * original array.
56
+ */
82
57
  function arrayReplaceAt(src, pos, newElements) {
83
58
  return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
84
59
  }
60
+ /** Checks whether a code point can be decoded from a numeric HTML entity. */
85
61
  function isValidEntityCode(c) {
86
62
  if (c >= 55296 && c <= 57343) return false;
87
63
  if (c >= 64976 && c <= 65007) return false;
@@ -93,6 +69,10 @@ function isValidEntityCode(c) {
93
69
  if (c > 1114111) return false;
94
70
  return true;
95
71
  }
72
+ /**
73
+ * Converts a Unicode code point to a string, like `String.fromCodePoint()`,
74
+ * but does not throw for invalid input.
75
+ */
96
76
  function fromCodePoint(c) {
97
77
  if (c > 65535) {
98
78
  c -= 65536;
@@ -103,7 +83,7 @@ function fromCodePoint(c) {
103
83
  return String.fromCharCode(c);
104
84
  }
105
85
  var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;
106
- var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + "|" + /&([a-z#][a-z0-9]{1,31});/gi.source, "gi");
86
+ var UNESCAPE_ALL_RE = new RegExp(`${UNESCAPE_MD_RE.source}|${/&([a-z#][a-z0-9]{1,31});/gi.source}`, "gi");
107
87
  var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;
108
88
  function replaceEntityPattern(match, name) {
109
89
  if (name.charCodeAt(0) === 35 && DIGITAL_ENTITY_TEST_RE.test(name)) {
@@ -111,14 +91,19 @@ function replaceEntityPattern(match, name) {
111
91
  if (isValidEntityCode(code)) return fromCodePoint(code);
112
92
  return match;
113
93
  }
114
- const decoded = (0, entities.decodeHTML)(match);
94
+ const decoded = decodeHTMLStrict(match);
115
95
  if (decoded !== match) return decoded;
116
96
  return match;
117
97
  }
98
+ /** Decodes Markdown backslash escapes. */
118
99
  function unescapeMd(str) {
119
100
  if (str.indexOf("\\") < 0) return str;
120
101
  return str.replace(UNESCAPE_MD_RE, "$1");
121
102
  }
103
+ /**
104
+ * Decodes Markdown backslash escapes and HTML character references in link
105
+ * destinations, link titles, and fenced code info strings.
106
+ */
122
107
  function unescapeAll(str) {
123
108
  if (str.indexOf("\\") < 0 && str.indexOf("&") < 0) return str;
124
109
  return str.replace(UNESCAPE_ALL_RE, function(match, escaped, entity) {
@@ -137,14 +122,17 @@ var HTML_REPLACEMENTS = {
137
122
  function replaceUnsafeChar(ch) {
138
123
  return HTML_REPLACEMENTS[ch];
139
124
  }
125
+ /** Escapes HTML special characters in a string. */
140
126
  function escapeHtml(str) {
141
127
  if (HTML_ESCAPE_TEST_RE.test(str)) return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
142
128
  return str;
143
129
  }
144
130
  var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
131
+ /** Escapes regular expression metacharacters in a string. */
145
132
  function escapeRE(str) {
146
133
  return str.replace(REGEXP_ESCAPE_RE, "\\$&");
147
134
  }
135
+ /** Checks whether a character code is an ASCII space or tab. */
148
136
  function isSpace(code) {
149
137
  switch (code) {
150
138
  case 9:
@@ -152,6 +140,11 @@ function isSpace(code) {
152
140
  }
153
141
  return false;
154
142
  }
143
+ /**
144
+ * Checks whether a character code is whitespace recognized by Markdown.
145
+ *
146
+ * Matches the Unicode `Zs` category or `\t`, `\f`, `\v`, `\r`, `\n`.
147
+ */
155
148
  function isWhiteSpace(code) {
156
149
  if (code >= 8192 && code <= 8202) return true;
157
150
  switch (code) {
@@ -169,12 +162,29 @@ function isWhiteSpace(code) {
169
162
  }
170
163
  return false;
171
164
  }
165
+ /**
166
+ * Checks whether a character is Unicode punctuation or a symbol.
167
+ *
168
+ * Does not support astral characters.
169
+ */
172
170
  function isPunctChar(ch) {
173
- return uc_micro.P.test(ch) || uc_micro.S.test(ch);
171
+ return ucmicro.P.test(ch) || ucmicro.S.test(ch);
174
172
  }
173
+ /** Checks whether a Unicode code point is punctuation or a symbol. */
175
174
  function isPunctCharCode(code) {
176
175
  return isPunctChar(fromCodePoint(code));
177
176
  }
177
+ /**
178
+ * Markdown ASCII punctuation characters.
179
+ *
180
+ * !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @,
181
+ * [, \, ], ^, _, `, {, |, }, or ~
182
+ *
183
+ * http://spec.commonmark.org/0.15/#ascii-punctuation-character
184
+ *
185
+ * Don't confuse with Unicode punctuation. It lacks some characters in the
186
+ * ASCII range.
187
+ */
178
188
  function isMdAsciiPunct(ch) {
179
189
  switch (ch) {
180
190
  case 33:
@@ -212,16 +222,18 @@ function isMdAsciiPunct(ch) {
212
222
  default: return false;
213
223
  }
214
224
  }
225
+ /** Normalizes `[reference labels]` for case-insensitive lookup. */
215
226
  function normalizeReference(str) {
216
227
  str = str.trim().replace(/\s+/g, " ");
217
- if ("ẞ".toLowerCase() === "Ṿ")
218
- /* c8 ignore next 2 */
219
- str = str.replace(/ẞ/g, "ß");
220
228
  return str.toLowerCase().toUpperCase();
221
229
  }
222
230
  function isAsciiTrimmable(c) {
223
231
  return c === 32 || c === 9 || c === 10 || c === 13;
224
232
  }
233
+ /**
234
+ * "Light" `.trim()` for blocks (headings, paragraphs), where Unicode spaces
235
+ * should be preserved.
236
+ */
225
237
  function asciiTrim(str) {
226
238
  let start = 0;
227
239
  for (; start < str.length; start++) if (!isAsciiTrimmable(str.charCodeAt(start))) break;
@@ -229,12 +241,17 @@ function asciiTrim(str) {
229
241
  for (; end >= start; end--) if (!isAsciiTrimmable(str.charCodeAt(end))) break;
230
242
  return str.slice(start, end + 1);
231
243
  }
244
+ /**
245
+ * Libraries commonly used by markdown-it and its plugins, re-exported to
246
+ * reduce duplicate dependencies in browser bundles.
247
+ */
232
248
  var lib = {
233
249
  mdurl,
234
- ucmicro: uc_micro
250
+ ucmicro
235
251
  };
236
252
  //#endregion
237
- //#region lib/helpers/parse_link_label.mjs
253
+ //#region src/helpers/parse_link_label.ts
254
+ /** Finds the end of a link or image label (`[label]`). */
238
255
  function parseLinkLabel(state, start, disableNested) {
239
256
  let level, found, marker, prevPos;
240
257
  const max = state.posMax;
@@ -266,7 +283,8 @@ function parseLinkLabel(state, start, disableNested) {
266
283
  return labelEnd;
267
284
  }
268
285
  //#endregion
269
- //#region lib/helpers/parse_link_destination.mjs
286
+ //#region src/helpers/parse_link_destination.ts
287
+ /** Parses the destination in `[label](destination "title")`. */
270
288
  function parseLinkDestination(str, start, max) {
271
289
  let code;
272
290
  let pos = start;
@@ -301,7 +319,10 @@ function parseLinkDestination(str, start, max) {
301
319
  if (code === 32) break;
302
320
  if (code < 32 || code === 127) break;
303
321
  if (code === 92 && pos + 1 < max) {
304
- if (str.charCodeAt(pos + 1) === 32) break;
322
+ if (str.charCodeAt(pos + 1) === 32) {
323
+ pos++;
324
+ continue;
325
+ }
305
326
  pos += 2;
306
327
  continue;
307
328
  }
@@ -323,7 +344,13 @@ function parseLinkDestination(str, start, max) {
323
344
  return result;
324
345
  }
325
346
  //#endregion
326
- //#region lib/helpers/parse_link_title.mjs
347
+ //#region src/helpers/parse_link_title.ts
348
+ /**
349
+ * Parses the optional title in `[label](destination "title")` or
350
+ * `[label]: destination "title"`.
351
+ *
352
+ * `prev_state` continues a reference title on the next source line.
353
+ */
327
354
  function parseLinkTitle(str, start, max, prev_state) {
328
355
  let code;
329
356
  let pos = start;
@@ -362,29 +389,418 @@ function parseLinkTitle(str, start, max, prev_state) {
362
389
  return state;
363
390
  }
364
391
  //#endregion
365
- //#region lib/helpers/index.mjs
392
+ //#region src/helpers/index.ts
393
+ /**
394
+ * Functions used to parse links and images, split out of parser rules because
395
+ * of their size.
396
+ *
397
+ * @module md.helpers
398
+ */
366
399
  var helpers_exports = /* @__PURE__ */ __exportAll({
367
400
  parseLinkDestination: () => parseLinkDestination,
368
401
  parseLinkLabel: () => parseLinkLabel,
369
402
  parseLinkTitle: () => parseLinkTitle
370
403
  });
371
404
  //#endregion
372
- //#region lib/renderer.mjs
405
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
406
+ function _typeof(o) {
407
+ "@babel/helpers - typeof";
408
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
409
+ return typeof o;
410
+ } : function(o) {
411
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
412
+ }, _typeof(o);
413
+ }
414
+ //#endregion
415
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
416
+ function toPrimitive(t, r) {
417
+ if ("object" != _typeof(t) || !t) return t;
418
+ var e = t[Symbol.toPrimitive];
419
+ if (void 0 !== e) {
420
+ var i = e.call(t, r || "default");
421
+ if ("object" != _typeof(i)) return i;
422
+ throw new TypeError("@@toPrimitive must return a primitive value.");
423
+ }
424
+ return ("string" === r ? String : Number)(t);
425
+ }
426
+ //#endregion
427
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
428
+ function toPropertyKey(t) {
429
+ var i = toPrimitive(t, "string");
430
+ return "symbol" == _typeof(i) ? i : i + "";
431
+ }
432
+ //#endregion
433
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
434
+ function _defineProperty(e, r, t) {
435
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
436
+ value: t,
437
+ enumerable: !0,
438
+ configurable: !0,
439
+ writable: !0
440
+ }) : e[r] = t, e;
441
+ }
442
+ //#endregion
443
+ //#region src/token.ts
373
444
  /**
374
- * class Renderer
445
+ * Represents one item in the parsed token stream, storing parsed data and
446
+ * providing helpers for managing HTML attributes.
447
+ */
448
+ var Token = class {
449
+ constructor(type, tag, nesting) {
450
+ _defineProperty(
451
+ this,
452
+ /**
453
+ * Source map info. Format: `[ line_begin, line_end ]`
454
+ */
455
+ "map",
456
+ null
457
+ );
458
+ _defineProperty(
459
+ this,
460
+ /**
461
+ * nesting level, the same as `state.level`
462
+ */
463
+ "level",
464
+ 0
465
+ );
466
+ _defineProperty(
467
+ this,
468
+ /**
469
+ * An array of child nodes (inline and img tokens)
470
+ */
471
+ "children",
472
+ null
473
+ );
474
+ _defineProperty(
475
+ this,
476
+ /**
477
+ * In a case of self-closing tag (code, html, fence, etc.),
478
+ * it has contents of this tag.
479
+ */
480
+ "content",
481
+ ""
482
+ );
483
+ _defineProperty(
484
+ this,
485
+ /**
486
+ * '*' or '_' for emphasis, fence string for fence, etc.
487
+ */
488
+ "markup",
489
+ ""
490
+ );
491
+ _defineProperty(
492
+ this,
493
+ /**
494
+ * Additional information:
495
+ *
496
+ * - Info string for "fence" tokens
497
+ * - The value "auto" for autolink "link_open" and "link_close" tokens
498
+ * - The string value of the item marker for ordered-list "list_item_open" tokens
499
+ */
500
+ "info",
501
+ ""
502
+ );
503
+ _defineProperty(
504
+ this,
505
+ /**
506
+ * True for block-level tokens, false for inline tokens.
507
+ * Used in renderer to calculate line breaks
508
+ */
509
+ "block",
510
+ false
511
+ );
512
+ _defineProperty(
513
+ this,
514
+ /**
515
+ * If it's true, ignore this element when rendering. Used for tight lists
516
+ * to hide paragraphs.
517
+ */
518
+ "hidden",
519
+ false
520
+ );
521
+ this.type = type;
522
+ this.tag = tag;
523
+ this.attrs = null;
524
+ this.nesting = nesting;
525
+ this.meta = null;
526
+ }
527
+ /**
528
+ * Search attribute index by name.
529
+ */
530
+ attrIndex(name) {
531
+ if (!this.attrs) return -1;
532
+ const attrs = this.attrs;
533
+ for (let i = 0, len = attrs.length; i < len; i++) if (attrs[i][0] === name) return i;
534
+ return -1;
535
+ }
536
+ /**
537
+ * Add `[ name, value ]` attribute to list. Init attrs if necessary
538
+ */
539
+ attrPush(attrData) {
540
+ if (this.attrs) this.attrs.push(attrData);
541
+ else this.attrs = [attrData];
542
+ }
543
+ /**
544
+ * Set `name` attribute to `value`. Override old value if exists.
545
+ */
546
+ attrSet(name, value) {
547
+ const idx = this.attrIndex(name);
548
+ const attrData = [name, value];
549
+ if (idx < 0) this.attrPush(attrData);
550
+ else this.attrs[idx] = attrData;
551
+ }
552
+ /**
553
+ * Get the value of attribute `name`, or null if it does not exist.
554
+ */
555
+ attrGet(name) {
556
+ const idx = this.attrIndex(name);
557
+ let value = null;
558
+ if (idx >= 0) value = this.attrs[idx][1];
559
+ return value;
560
+ }
561
+ /**
562
+ * Join value to existing attribute via space. Or create new attribute if not
563
+ * exists. Useful to operate with token classes.
564
+ */
565
+ attrJoin(name, value) {
566
+ const idx = this.attrIndex(name);
567
+ if (idx < 0) this.attrPush([name, value]);
568
+ else this.attrs[idx][1] = `${this.attrs[idx][1]} ${value}`;
569
+ }
570
+ };
571
+ //#endregion
572
+ //#region src/ruler.ts
573
+ /**
574
+ * Helper class, used by {@link MarkdownIt.core}, {@link MarkdownIt.block} and
575
+ * {@link MarkdownIt.inline} to manage sequences of functions (rules):
375
576
  *
376
- * Generates HTML from parsed token stream. Each instance has independent
377
- * copy of rules. Those can be rewritten with ease. Also, you can add new
378
- * rules if you create plugin and adds new token types.
379
- **/
577
+ * - keep rules in defined order
578
+ * - assign the name to each rule
579
+ * - enable/disable rules
580
+ * - add/replace rules
581
+ * - allow assign rules to additional named chains (in the same)
582
+ * - cacheing lists of active rules
583
+ *
584
+ * You will not need use this class directly until write plugins. For simple
585
+ * rules control use {@link MarkdownIt.disable}, {@link MarkdownIt.enable} and
586
+ * {@link MarkdownIt.use}.
587
+ */
588
+ var Ruler = class {
589
+ constructor() {
590
+ _defineProperty(
591
+ this,
592
+ /** @internal */
593
+ "__rules__",
594
+ []
595
+ );
596
+ _defineProperty(
597
+ this,
598
+ /** @internal */
599
+ "__cache__",
600
+ null
601
+ );
602
+ }
603
+ /** @internal */
604
+ __find__(name) {
605
+ for (let i = 0; i < this.__rules__.length; i++) if (this.__rules__[i].name === name) return i;
606
+ return -1;
607
+ }
608
+ /** @internal */
609
+ __compile__() {
610
+ const chains = /* @__PURE__ */ new Set();
611
+ this.__rules__.forEach((rule) => {
612
+ if (!rule.enabled) return;
613
+ rule.alt.forEach((altName) => {
614
+ if (altName) chains.add(altName);
615
+ });
616
+ });
617
+ this.__cache__ = Object.create(null);
618
+ this.__cache__[""] = [];
619
+ this.__rules__.forEach((rule) => {
620
+ if (rule.enabled) this.__cache__[""].push(rule.fn);
621
+ });
622
+ chains.forEach((chain) => {
623
+ this.__cache__[chain] = [];
624
+ this.__rules__.forEach((rule) => {
625
+ if (rule.enabled && rule.alt.indexOf(chain) >= 0) this.__cache__[chain].push(rule.fn);
626
+ });
627
+ });
628
+ }
629
+ /**
630
+ * Replace rule by name with new function & options. Throws error if name not
631
+ * found.
632
+ *
633
+ * @example Replace existing typographer replacement rule with new one
634
+ * ```javascript
635
+ * import MarkdownIt from 'markdown-it'
636
+ * const md = new MarkdownIt()
637
+ *
638
+ * md.core.ruler.at('replacements', function replace(state) {
639
+ * //...
640
+ * });
641
+ * ```
642
+ */
643
+ at(name, fn, options = {}) {
644
+ const index = this.__find__(name);
645
+ if (index === -1) throw new Error(`Parser rule not found: ${name}`);
646
+ this.__rules__[index].fn = fn;
647
+ this.__rules__[index].alt = options.alt || [];
648
+ this.__cache__ = null;
649
+ }
650
+ /**
651
+ * Add new rule to chain before one with given name. See also
652
+ * {@link Ruler.after}, {@link Ruler.push}.
653
+ *
654
+ * @example
655
+ * ```javascript
656
+ * import MarkdownIt from 'markdown-it'
657
+ * const md = new MarkdownIt()
658
+ *
659
+ * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
660
+ * //...
661
+ * });
662
+ * ```
663
+ */
664
+ before(beforeName, ruleName, fn, options = {}) {
665
+ const index = this.__find__(beforeName);
666
+ if (index === -1) throw new Error(`Parser rule not found: ${beforeName}`);
667
+ this.__rules__.splice(index, 0, {
668
+ name: ruleName,
669
+ enabled: true,
670
+ fn,
671
+ alt: options.alt || []
672
+ });
673
+ this.__cache__ = null;
674
+ }
675
+ /**
676
+ * Add new rule to chain after one with given name. See also
677
+ * {@link Ruler.before}, {@link Ruler.push}.
678
+ *
679
+ * @example
680
+ * ```javascript
681
+ * import MarkdownIt from 'markdown-it'
682
+ * const md = new MarkdownIt()
683
+ *
684
+ * md.inline.ruler.after('text', 'my_rule', function replace(state) {
685
+ * //...
686
+ * });
687
+ * ```
688
+ */
689
+ after(afterName, ruleName, fn, options = {}) {
690
+ const index = this.__find__(afterName);
691
+ if (index === -1) throw new Error(`Parser rule not found: ${afterName}`);
692
+ this.__rules__.splice(index + 1, 0, {
693
+ name: ruleName,
694
+ enabled: true,
695
+ fn,
696
+ alt: options.alt || []
697
+ });
698
+ this.__cache__ = null;
699
+ }
700
+ /**
701
+ * Push new rule to the end of chain. See also
702
+ * {@link Ruler.before}, {@link Ruler.after}.
703
+ *
704
+ * @example
705
+ * ```javascript
706
+ * import MarkdownIt from 'markdown-it'
707
+ * const md = new MarkdownIt()
708
+ *
709
+ * md.core.ruler.push('my_rule', function replace(state) {
710
+ * //...
711
+ * });
712
+ * ```
713
+ */
714
+ push(ruleName, fn, options = {}) {
715
+ this.__rules__.push({
716
+ name: ruleName,
717
+ enabled: true,
718
+ fn,
719
+ alt: options.alt || []
720
+ });
721
+ this.__cache__ = null;
722
+ }
723
+ /**
724
+ * Enable rules with given names. If any rule name not found - throw Error.
725
+ * Errors can be disabled by second param.
726
+ *
727
+ * See also {@link Ruler.disable}, {@link Ruler.enableOnly}.
728
+ *
729
+ * Returns list of found rule names (if no exception happened).
730
+ */
731
+ enable(list, ignoreInvalid = false) {
732
+ if (!Array.isArray(list)) list = [list];
733
+ const result = [];
734
+ list.forEach((name) => {
735
+ const idx = this.__find__(name);
736
+ if (idx < 0) {
737
+ if (ignoreInvalid) return;
738
+ throw new Error(`Rules manager: invalid rule name ${name}`);
739
+ }
740
+ this.__rules__[idx].enabled = true;
741
+ result.push(name);
742
+ });
743
+ this.__cache__ = null;
744
+ return result;
745
+ }
746
+ /**
747
+ * Enable rules with given names, and disable everything else. If any rule name
748
+ * not found - throw Error. Errors can be disabled by second param.
749
+ *
750
+ * See also {@link Ruler.disable}, {@link Ruler.enable}.
751
+ */
752
+ enableOnly(list, ignoreInvalid = false) {
753
+ if (!Array.isArray(list)) list = [list];
754
+ this.__rules__.forEach((rule) => {
755
+ rule.enabled = false;
756
+ });
757
+ this.enable(list, ignoreInvalid);
758
+ }
759
+ /**
760
+ * Disable rules with given names. If any rule name not found - throw Error.
761
+ * Errors can be disabled by second param.
762
+ *
763
+ * See also {@link Ruler.enable}, {@link Ruler.enableOnly}.
764
+ *
765
+ * Returns list of found rule names (if no exception happened).
766
+ */
767
+ disable(list, ignoreInvalid = false) {
768
+ if (!Array.isArray(list)) list = [list];
769
+ const result = [];
770
+ list.forEach((name) => {
771
+ const idx = this.__find__(name);
772
+ if (idx < 0) {
773
+ if (ignoreInvalid) return;
774
+ throw new Error(`Rules manager: invalid rule name ${name}`);
775
+ }
776
+ this.__rules__[idx].enabled = false;
777
+ result.push(name);
778
+ });
779
+ this.__cache__ = null;
780
+ return result;
781
+ }
782
+ /**
783
+ * Return array of active functions (rules) for given chain name. It analyzes
784
+ * rules configuration, compiles caches if not exists and returns result.
785
+ *
786
+ * Default chain name is `''` (empty string). It can't be skipped. That's
787
+ * done intentionally, to keep signature monomorphic for high speed.
788
+ */
789
+ getRules(chainName) {
790
+ if (!this.__cache__) this.__compile__();
791
+ return this.__cache__[chainName] || [];
792
+ }
793
+ };
794
+ //#endregion
795
+ //#region src/renderer.ts
380
796
  var default_rules = {};
381
797
  default_rules.code_inline = function(tokens, idx, options, env, slf) {
382
798
  const token = tokens[idx];
383
- return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
799
+ return `<code${slf.renderAttrs(token)}>${escapeHtml(token.content)}</code>`;
384
800
  };
385
801
  default_rules.code_block = function(tokens, idx, options, env, slf) {
386
802
  const token = tokens[idx];
387
- return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
803
+ return `<pre${slf.renderAttrs(token)}><code>${escapeHtml(tokens[idx].content)}</code></pre>\n`;
388
804
  };
389
805
  default_rules.fence = function(tokens, idx, options, env, slf) {
390
806
  const token = tokens[idx];
@@ -403,10 +819,10 @@ default_rules.fence = function(tokens, idx, options, env, slf) {
403
819
  if (info) {
404
820
  const i = token.attrIndex("class");
405
821
  const tmpAttrs = token.attrs ? token.attrs.slice() : [];
406
- if (i < 0) tmpAttrs.push(["class", options.langPrefix + langName]);
822
+ if (i < 0) tmpAttrs.push(["class", `${options.langPrefix}${langName}`]);
407
823
  else {
408
- tmpAttrs[i] = tmpAttrs[i].slice();
409
- tmpAttrs[i][1] += " " + options.langPrefix + langName;
824
+ tmpAttrs[i] = [tmpAttrs[i][0], tmpAttrs[i][1]];
825
+ tmpAttrs[i][1] += ` ${options.langPrefix}${langName}`;
410
826
  }
411
827
  const tmpToken = { attrs: tmpAttrs };
412
828
  return `<pre><code${slf.renderAttrs(tmpToken)}>${highlighted}</code></pre>\n`;
@@ -434,600 +850,163 @@ default_rules.html_inline = function(tokens, idx) {
434
850
  return tokens[idx].content;
435
851
  };
436
852
  /**
437
- * new Renderer()
853
+ * Generates HTML from parsed token stream. Each instance has independent
854
+ * copy of rules. Those can be rewritten with ease. Also, you can add new
855
+ * rules if you create plugin and adds new token types.
438
856
  *
439
- * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
440
- **/
441
- function Renderer() {
857
+ * Creates new renderer instance and fills {@link Renderer.rules} with defaults.
858
+ */
859
+ var Renderer = class {
860
+ constructor() {
861
+ _defineProperty(
862
+ this,
863
+ /**
864
+ * Contains render rules for tokens. Can be updated and extended.
865
+ *
866
+ * See [source code](https://github.com/markdown-it/markdown-it/blob/master/src/renderer.ts)
867
+ * for more details and examples.
868
+ *
869
+ * @example Custom render rules
870
+ * ```javascript
871
+ * import MarkdownIt from 'markdown-it'
872
+ * const md = new MarkdownIt()
873
+ *
874
+ * md.renderer.rules.strong_open = function () { return '<b>'; };
875
+ * md.renderer.rules.strong_close = function () { return '</b>'; };
876
+ *
877
+ * const result = md.renderInline(...);
878
+ * ```
879
+ *
880
+ * @example Each rule is called as independent static function with fixed signature
881
+ * ```javascript
882
+ * function my_token_render(tokens, idx, options, env, renderer) {
883
+ * // ...
884
+ * return renderedHTML;
885
+ * }
886
+ * ```
887
+ */
888
+ "rules",
889
+ Object.assign({}, default_rules)
890
+ );
891
+ }
442
892
  /**
443
- * Renderer#rules -> Object
444
- *
445
- * Contains render rules for tokens. Can be updated and extended.
446
- *
447
- * ##### Example
448
- *
449
- * ```javascript
450
- * var md = require('markdown-it')();
451
- *
452
- * md.renderer.rules.strong_open = function () { return '<b>'; };
453
- * md.renderer.rules.strong_close = function () { return '</b>'; };
454
- *
455
- * var result = md.renderInline(...);
456
- * ```
457
- *
458
- * Each rule is called as independent static function with fixed signature:
459
- *
460
- * ```javascript
461
- * function my_token_render(tokens, idx, options, env, renderer) {
462
- * // ...
463
- * return renderedHTML;
464
- * }
465
- * ```
466
- *
467
- * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.mjs)
468
- * for more details and examples.
469
- **/
470
- this.rules = assign({}, default_rules);
471
- }
472
- /**
473
- * Renderer.renderAttrs(token) -> String
474
- *
475
- * Render token attributes to string.
476
- **/
477
- Renderer.prototype.renderAttrs = function renderAttrs(token) {
478
- let i, l, result;
479
- if (!token.attrs) return "";
480
- result = "";
481
- for (i = 0, l = token.attrs.length; i < l; i++) result += " " + escapeHtml(token.attrs[i][0]) + "=\"" + escapeHtml(token.attrs[i][1]) + "\"";
482
- return result;
483
- };
484
- /**
485
- * Renderer.renderToken(tokens, idx, options) -> String
486
- * - tokens (Array): list of tokens
487
- * - idx (Numbed): token index to render
488
- * - options (Object): params of parser instance
489
- *
490
- * Default token renderer. Can be overriden by custom function
491
- * in [[Renderer#rules]].
492
- **/
493
- Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
494
- const token = tokens[idx];
495
- let result = "";
496
- if (token.hidden) return "";
497
- if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) result += "\n";
498
- result += (token.nesting === -1 ? "</" : "<") + token.tag;
499
- result += this.renderAttrs(token);
500
- if (token.nesting === 0 && options.xhtmlOut) result += " /";
501
- let needLf = false;
502
- if (token.block) {
503
- needLf = true;
504
- if (token.nesting === 1) {
505
- if (idx + 1 < tokens.length) {
506
- const nextToken = tokens[idx + 1];
507
- if (nextToken.type === "inline" || nextToken.hidden) needLf = false;
508
- else if (nextToken.nesting === -1 && nextToken.tag === token.tag) needLf = false;
893
+ * Render token attributes to string.
894
+ */
895
+ renderAttrs(token) {
896
+ let i, l, result;
897
+ if (!token.attrs) return "";
898
+ result = "";
899
+ for (i = 0, l = token.attrs.length; i < l; i++) result += ` ${escapeHtml(token.attrs[i][0])}="${escapeHtml(String(token.attrs[i][1]))}"`;
900
+ return result;
901
+ }
902
+ /**
903
+ * Default token renderer. Can be overriden by custom function
904
+ * in {@link Renderer.rules}.
905
+ */
906
+ renderToken(tokens, idx, options) {
907
+ const token = tokens[idx];
908
+ let result = "";
909
+ if (token.hidden) return "";
910
+ let prev = idx - 1;
911
+ while (prev >= 0 && tokens[prev].hidden && tokens[prev].nesting === 0) prev--;
912
+ if (token.block && token.nesting !== -1 && prev >= 0 && tokens[prev].hidden && tokens[prev].nesting === -1) result += "\n";
913
+ result += (token.nesting === -1 ? "</" : "<") + token.tag;
914
+ result += this.renderAttrs(token);
915
+ if (token.nesting === 0 && options.xhtmlOut) result += " /";
916
+ let needLf = false;
917
+ if (token.block) {
918
+ needLf = true;
919
+ if (token.nesting === 1) {
920
+ let next = idx + 1;
921
+ while (next < tokens.length && tokens[next].hidden && tokens[next].nesting === 0) next++;
922
+ if (next < tokens.length) {
923
+ const nextToken = tokens[next];
924
+ if (nextToken.type === "inline" || nextToken.hidden) needLf = false;
925
+ else if (nextToken.nesting === -1 && nextToken.tag === token.tag) needLf = false;
926
+ }
509
927
  }
510
928
  }
929
+ result += needLf ? ">\n" : ">";
930
+ return result;
511
931
  }
512
- result += needLf ? ">\n" : ">";
513
- return result;
514
- };
515
- /**
516
- * Renderer.renderInline(tokens, options, env) -> String
517
- * - tokens (Array): list on block tokens to render
518
- * - options (Object): params of parser instance
519
- * - env (Object): additional data from parsed input (references, for example)
520
- *
521
- * The same as [[Renderer.render]], but for single token of `inline` type.
522
- **/
523
- Renderer.prototype.renderInline = function(tokens, options, env) {
524
- let result = "";
525
- const rules = this.rules;
526
- for (let i = 0, len = tokens.length; i < len; i++) {
527
- const type = tokens[i].type;
528
- if (typeof rules[type] !== "undefined") result += rules[type](tokens, i, options, env, this);
529
- else result += this.renderToken(tokens, i, options);
530
- }
531
- return result;
532
- };
533
- /** internal
534
- * Renderer.renderInlineAsText(tokens, options, env) -> String
535
- * - tokens (Array): list on block tokens to render
536
- * - options (Object): params of parser instance
537
- * - env (Object): additional data from parsed input (references, for example)
538
- *
539
- * Special kludge for image `alt` attributes to conform CommonMark spec.
540
- * Don't try to use it! Spec requires to show `alt` content with stripped markup,
541
- * instead of simple escaping.
542
- **/
543
- Renderer.prototype.renderInlineAsText = function(tokens, options, env) {
544
- let result = "";
545
- for (let i = 0, len = tokens.length; i < len; i++) switch (tokens[i].type) {
546
- case "text":
547
- result += tokens[i].content;
548
- break;
549
- case "image":
550
- result += this.renderInlineAsText(tokens[i].children, options, env);
551
- break;
552
- case "html_inline":
553
- case "html_block":
554
- result += tokens[i].content;
555
- break;
556
- case "softbreak":
557
- case "hardbreak":
558
- result += "\n";
559
- break;
560
- default:
561
- }
562
- return result;
563
- };
564
- /**
565
- * Renderer.render(tokens, options, env) -> String
566
- * - tokens (Array): list on block tokens to render
567
- * - options (Object): params of parser instance
568
- * - env (Object): additional data from parsed input (references, for example)
569
- *
570
- * Takes token stream and generates HTML. Probably, you will never need to call
571
- * this method directly.
572
- **/
573
- Renderer.prototype.render = function(tokens, options, env) {
574
- let result = "";
575
- const rules = this.rules;
576
- for (let i = 0, len = tokens.length; i < len; i++) {
577
- const type = tokens[i].type;
578
- if (type === "inline") result += this.renderInline(tokens[i].children, options, env);
579
- else if (typeof rules[type] !== "undefined") result += rules[type](tokens, i, options, env, this);
580
- else result += this.renderToken(tokens, i, options, env);
581
- }
582
- return result;
583
- };
584
- //#endregion
585
- //#region lib/ruler.mjs
586
- /**
587
- * class Ruler
588
- *
589
- * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
590
- * [[MarkdownIt#inline]] to manage sequences of functions (rules):
591
- *
592
- * - keep rules in defined order
593
- * - assign the name to each rule
594
- * - enable/disable rules
595
- * - add/replace rules
596
- * - allow assign rules to additional named chains (in the same)
597
- * - cacheing lists of active rules
598
- *
599
- * You will not need use this class directly until write plugins. For simple
600
- * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
601
- * [[MarkdownIt.use]].
602
- **/
603
- /**
604
- * new Ruler()
605
- **/
606
- function Ruler() {
607
- this.__rules__ = [];
608
- this.__cache__ = null;
609
- }
610
- Ruler.prototype.__find__ = function(name) {
611
- for (let i = 0; i < this.__rules__.length; i++) if (this.__rules__[i].name === name) return i;
612
- return -1;
613
- };
614
- Ruler.prototype.__compile__ = function() {
615
- const self = this;
616
- const chains = [""];
617
- self.__rules__.forEach(function(rule) {
618
- if (!rule.enabled) return;
619
- rule.alt.forEach(function(altName) {
620
- if (chains.indexOf(altName) < 0) chains.push(altName);
621
- });
622
- });
623
- self.__cache__ = {};
624
- chains.forEach(function(chain) {
625
- self.__cache__[chain] = [];
626
- self.__rules__.forEach(function(rule) {
627
- if (!rule.enabled) return;
628
- if (chain && rule.alt.indexOf(chain) < 0) return;
629
- self.__cache__[chain].push(rule.fn);
630
- });
631
- });
632
- };
633
- /**
634
- * Ruler.at(name, fn [, options])
635
- * - name (String): rule name to replace.
636
- * - fn (Function): new rule function.
637
- * - options (Object): new rule options (not mandatory).
638
- *
639
- * Replace rule by name with new function & options. Throws error if name not
640
- * found.
641
- *
642
- * ##### Options:
643
- *
644
- * - __alt__ - array with names of "alternate" chains.
645
- *
646
- * ##### Example
647
- *
648
- * Replace existing typographer replacement rule with new one:
649
- *
650
- * ```javascript
651
- * var md = require('markdown-it')();
652
- *
653
- * md.core.ruler.at('replacements', function replace(state) {
654
- * //...
655
- * });
656
- * ```
657
- **/
658
- Ruler.prototype.at = function(name, fn, options) {
659
- const index = this.__find__(name);
660
- const opt = options || {};
661
- if (index === -1) throw new Error("Parser rule not found: " + name);
662
- this.__rules__[index].fn = fn;
663
- this.__rules__[index].alt = opt.alt || [];
664
- this.__cache__ = null;
665
- };
666
- /**
667
- * Ruler.before(beforeName, ruleName, fn [, options])
668
- * - beforeName (String): new rule will be added before this one.
669
- * - ruleName (String): name of added rule.
670
- * - fn (Function): rule function.
671
- * - options (Object): rule options (not mandatory).
672
- *
673
- * Add new rule to chain before one with given name. See also
674
- * [[Ruler.after]], [[Ruler.push]].
675
- *
676
- * ##### Options:
677
- *
678
- * - __alt__ - array with names of "alternate" chains.
679
- *
680
- * ##### Example
681
- *
682
- * ```javascript
683
- * var md = require('markdown-it')();
684
- *
685
- * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
686
- * //...
687
- * });
688
- * ```
689
- **/
690
- Ruler.prototype.before = function(beforeName, ruleName, fn, options) {
691
- const index = this.__find__(beforeName);
692
- const opt = options || {};
693
- if (index === -1) throw new Error("Parser rule not found: " + beforeName);
694
- this.__rules__.splice(index, 0, {
695
- name: ruleName,
696
- enabled: true,
697
- fn,
698
- alt: opt.alt || []
699
- });
700
- this.__cache__ = null;
701
- };
702
- /**
703
- * Ruler.after(afterName, ruleName, fn [, options])
704
- * - afterName (String): new rule will be added after this one.
705
- * - ruleName (String): name of added rule.
706
- * - fn (Function): rule function.
707
- * - options (Object): rule options (not mandatory).
708
- *
709
- * Add new rule to chain after one with given name. See also
710
- * [[Ruler.before]], [[Ruler.push]].
711
- *
712
- * ##### Options:
713
- *
714
- * - __alt__ - array with names of "alternate" chains.
715
- *
716
- * ##### Example
717
- *
718
- * ```javascript
719
- * var md = require('markdown-it')();
720
- *
721
- * md.inline.ruler.after('text', 'my_rule', function replace(state) {
722
- * //...
723
- * });
724
- * ```
725
- **/
726
- Ruler.prototype.after = function(afterName, ruleName, fn, options) {
727
- const index = this.__find__(afterName);
728
- const opt = options || {};
729
- if (index === -1) throw new Error("Parser rule not found: " + afterName);
730
- this.__rules__.splice(index + 1, 0, {
731
- name: ruleName,
732
- enabled: true,
733
- fn,
734
- alt: opt.alt || []
735
- });
736
- this.__cache__ = null;
737
- };
738
- /**
739
- * Ruler.push(ruleName, fn [, options])
740
- * - ruleName (String): name of added rule.
741
- * - fn (Function): rule function.
742
- * - options (Object): rule options (not mandatory).
743
- *
744
- * Push new rule to the end of chain. See also
745
- * [[Ruler.before]], [[Ruler.after]].
746
- *
747
- * ##### Options:
748
- *
749
- * - __alt__ - array with names of "alternate" chains.
750
- *
751
- * ##### Example
752
- *
753
- * ```javascript
754
- * var md = require('markdown-it')();
755
- *
756
- * md.core.ruler.push('my_rule', function replace(state) {
757
- * //...
758
- * });
759
- * ```
760
- **/
761
- Ruler.prototype.push = function(ruleName, fn, options) {
762
- const opt = options || {};
763
- this.__rules__.push({
764
- name: ruleName,
765
- enabled: true,
766
- fn,
767
- alt: opt.alt || []
768
- });
769
- this.__cache__ = null;
770
- };
771
- /**
772
- * Ruler.enable(list [, ignoreInvalid]) -> Array
773
- * - list (String|Array): list of rule names to enable.
774
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
775
- *
776
- * Enable rules with given names. If any rule name not found - throw Error.
777
- * Errors can be disabled by second param.
778
- *
779
- * Returns list of found rule names (if no exception happened).
780
- *
781
- * See also [[Ruler.disable]], [[Ruler.enableOnly]].
782
- **/
783
- Ruler.prototype.enable = function(list, ignoreInvalid) {
784
- if (!Array.isArray(list)) list = [list];
785
- const result = [];
786
- list.forEach(function(name) {
787
- const idx = this.__find__(name);
788
- if (idx < 0) {
789
- if (ignoreInvalid) return;
790
- throw new Error("Rules manager: invalid rule name " + name);
791
- }
792
- this.__rules__[idx].enabled = true;
793
- result.push(name);
794
- }, this);
795
- this.__cache__ = null;
796
- return result;
797
- };
798
- /**
799
- * Ruler.enableOnly(list [, ignoreInvalid])
800
- * - list (String|Array): list of rule names to enable (whitelist).
801
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
802
- *
803
- * Enable rules with given names, and disable everything else. If any rule name
804
- * not found - throw Error. Errors can be disabled by second param.
805
- *
806
- * See also [[Ruler.disable]], [[Ruler.enable]].
807
- **/
808
- Ruler.prototype.enableOnly = function(list, ignoreInvalid) {
809
- if (!Array.isArray(list)) list = [list];
810
- this.__rules__.forEach(function(rule) {
811
- rule.enabled = false;
812
- });
813
- this.enable(list, ignoreInvalid);
814
- };
815
- /**
816
- * Ruler.disable(list [, ignoreInvalid]) -> Array
817
- * - list (String|Array): list of rule names to disable.
818
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
819
- *
820
- * Disable rules with given names. If any rule name not found - throw Error.
821
- * Errors can be disabled by second param.
822
- *
823
- * Returns list of found rule names (if no exception happened).
824
- *
825
- * See also [[Ruler.enable]], [[Ruler.enableOnly]].
826
- **/
827
- Ruler.prototype.disable = function(list, ignoreInvalid) {
828
- if (!Array.isArray(list)) list = [list];
829
- const result = [];
830
- list.forEach(function(name) {
831
- const idx = this.__find__(name);
832
- if (idx < 0) {
833
- if (ignoreInvalid) return;
834
- throw new Error("Rules manager: invalid rule name " + name);
835
- }
836
- this.__rules__[idx].enabled = false;
837
- result.push(name);
838
- }, this);
839
- this.__cache__ = null;
840
- return result;
841
- };
842
- /**
843
- * Ruler.getRules(chainName) -> Array
844
- *
845
- * Return array of active functions (rules) for given chain name. It analyzes
846
- * rules configuration, compiles caches if not exists and returns result.
847
- *
848
- * Default chain name is `''` (empty string). It can't be skipped. That's
849
- * done intentionally, to keep signature monomorphic for high speed.
850
- **/
851
- Ruler.prototype.getRules = function(chainName) {
852
- if (this.__cache__ === null) this.__compile__();
853
- return this.__cache__[chainName] || [];
854
- };
855
- //#endregion
856
- //#region lib/token.mjs
857
- /**
858
- * class Token
859
- **/
860
- /**
861
- * new Token(type, tag, nesting)
862
- *
863
- * Create new token and fill passed properties.
864
- **/
865
- function Token(type, tag, nesting) {
866
- /**
867
- * Token#type -> String
868
- *
869
- * Type of the token (string, e.g. "paragraph_open")
870
- **/
871
- this.type = type;
872
- /**
873
- * Token#tag -> String
874
- *
875
- * html tag name, e.g. "p"
876
- **/
877
- this.tag = tag;
878
- /**
879
- * Token#attrs -> Array
880
- *
881
- * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
882
- **/
883
- this.attrs = null;
884
- /**
885
- * Token#map -> Array
886
- *
887
- * Source map info. Format: `[ line_begin, line_end ]`
888
- **/
889
- this.map = null;
890
- /**
891
- * Token#nesting -> Number
892
- *
893
- * Level change (number in {-1, 0, 1} set), where:
894
- *
895
- * - `1` means the tag is opening
896
- * - `0` means the tag is self-closing
897
- * - `-1` means the tag is closing
898
- **/
899
- this.nesting = nesting;
900
- /**
901
- * Token#level -> Number
902
- *
903
- * nesting level, the same as `state.level`
904
- **/
905
- this.level = 0;
906
- /**
907
- * Token#children -> Array
908
- *
909
- * An array of child nodes (inline and img tokens)
910
- **/
911
- this.children = null;
912
- /**
913
- * Token#content -> String
914
- *
915
- * In a case of self-closing tag (code, html, fence, etc.),
916
- * it has contents of this tag.
917
- **/
918
- this.content = "";
919
- /**
920
- * Token#markup -> String
921
- *
922
- * '*' or '_' for emphasis, fence string for fence, etc.
923
- **/
924
- this.markup = "";
925
- /**
926
- * Token#info -> String
927
- *
928
- * Additional information:
929
- *
930
- * - Info string for "fence" tokens
931
- * - The value "auto" for autolink "link_open" and "link_close" tokens
932
- * - The string value of the item marker for ordered-list "list_item_open" tokens
933
- **/
934
- this.info = "";
935
- /**
936
- * Token#meta -> Object
937
- *
938
- * A place for plugins to store an arbitrary data
939
- **/
940
- this.meta = null;
941
932
  /**
942
- * Token#block -> Boolean
943
- *
944
- * True for block-level tokens, false for inline tokens.
945
- * Used in renderer to calculate line breaks
946
- **/
947
- this.block = false;
948
- /**
949
- * Token#hidden -> Boolean
950
- *
951
- * If it's true, ignore this element when rendering. Used for tight lists
952
- * to hide paragraphs.
953
- **/
954
- this.hidden = false;
955
- }
956
- /**
957
- * Token.attrIndex(name) -> Number
958
- *
959
- * Search attribute index by name.
960
- **/
961
- Token.prototype.attrIndex = function attrIndex(name) {
962
- if (!this.attrs) return -1;
963
- const attrs = this.attrs;
964
- for (let i = 0, len = attrs.length; i < len; i++) if (attrs[i][0] === name) return i;
965
- return -1;
966
- };
967
- /**
968
- * Token.attrPush(attrData)
969
- *
970
- * Add `[ name, value ]` attribute to list. Init attrs if necessary
971
- **/
972
- Token.prototype.attrPush = function attrPush(attrData) {
973
- if (this.attrs) this.attrs.push(attrData);
974
- else this.attrs = [attrData];
975
- };
976
- /**
977
- * Token.attrSet(name, value)
978
- *
979
- * Set `name` attribute to `value`. Override old value if exists.
980
- **/
981
- Token.prototype.attrSet = function attrSet(name, value) {
982
- const idx = this.attrIndex(name);
983
- const attrData = [name, value];
984
- if (idx < 0) this.attrPush(attrData);
985
- else this.attrs[idx] = attrData;
986
- };
987
- /**
988
- * Token.attrGet(name)
989
- *
990
- * Get the value of attribute `name`, or null if it does not exist.
991
- **/
992
- Token.prototype.attrGet = function attrGet(name) {
993
- const idx = this.attrIndex(name);
994
- let value = null;
995
- if (idx >= 0) value = this.attrs[idx][1];
996
- return value;
997
- };
998
- /**
999
- * Token.attrJoin(name, value)
1000
- *
1001
- * Join value to existing attribute via space. Or create new attribute if not
1002
- * exists. Useful to operate with token classes.
1003
- **/
1004
- Token.prototype.attrJoin = function attrJoin(name, value) {
1005
- const idx = this.attrIndex(name);
1006
- if (idx < 0) this.attrPush([name, value]);
1007
- else this.attrs[idx][1] = this.attrs[idx][1] + " " + value;
933
+ * The same as {@link Renderer.render}, but for single token of `inline` type.
934
+ */
935
+ renderInline(tokens, options, env) {
936
+ let result = "";
937
+ const rules = this.rules;
938
+ for (let i = 0, len = tokens.length; i < len; i++) {
939
+ const type = tokens[i].type;
940
+ if (typeof rules[type] !== "undefined") result += rules[type](tokens, i, options, env, this);
941
+ else result += this.renderToken(tokens, i, options);
942
+ }
943
+ return result;
944
+ }
945
+ /**
946
+ * Special kludge for image `alt` attributes to conform CommonMark spec.
947
+ * Don't try to use it! Spec requires to show `alt` content with stripped markup,
948
+ * instead of simple escaping.
949
+ */
950
+ renderInlineAsText(tokens, options, env) {
951
+ let result = "";
952
+ for (let i = 0, len = tokens.length; i < len; i++) switch (tokens[i].type) {
953
+ case "text":
954
+ case "code_inline":
955
+ result += tokens[i].content;
956
+ break;
957
+ case "image":
958
+ result += this.renderInlineAsText(tokens[i].children, options, env);
959
+ break;
960
+ case "html_inline":
961
+ case "html_block":
962
+ result += tokens[i].content;
963
+ break;
964
+ case "softbreak":
965
+ case "hardbreak": result += "\n";
966
+ }
967
+ return result;
968
+ }
969
+ /**
970
+ * Takes token stream and generates HTML. Probably, you will never need to call
971
+ * this method directly.
972
+ */
973
+ render(tokens, options, env) {
974
+ let result = "";
975
+ const rules = this.rules;
976
+ for (let i = 0, len = tokens.length; i < len; i++) {
977
+ const type = tokens[i].type;
978
+ if (type === "inline") result += this.renderInline(tokens[i].children, options, env);
979
+ else if (typeof rules[type] !== "undefined") result += rules[type](tokens, i, options, env, this);
980
+ else result += this.renderToken(tokens, i, options);
981
+ }
982
+ return result;
983
+ }
1008
984
  };
1009
985
  //#endregion
1010
- //#region lib/rules_core/state_core.mjs
1011
- function StateCore(src, md, env) {
1012
- this.src = src;
1013
- this.env = env;
1014
- this.tokens = [];
1015
- this.inlineMode = false;
1016
- this.md = md;
1017
- }
1018
- StateCore.prototype.Token = Token;
986
+ //#region src/rules_core/state_core.ts
987
+ /** Mutable state passed through the core rules chain. */
988
+ var StateCore = class {
989
+ constructor(src, md, env) {
990
+ _defineProperty(this, "tokens", []);
991
+ _defineProperty(this, "inlineMode", false);
992
+ _defineProperty(this, "Token", Token);
993
+ this.src = src;
994
+ this.env = env;
995
+ this.md = md;
996
+ }
997
+ };
1019
998
  //#endregion
1020
- //#region lib/rules_core/normalize.mjs
1021
- var NEWLINES_RE = /\r\n?|\n/g;
999
+ //#region src/rules_core/normalize.ts
1000
+ var UNNORMALIZED_NEWLINE_RE = /\r\n?/g;
1022
1001
  var NULL_RE = /\0/g;
1023
1002
  function normalize(state) {
1024
1003
  let str;
1025
- str = state.src.replace(NEWLINES_RE, "\n");
1004
+ str = state.src.replace(UNNORMALIZED_NEWLINE_RE, "\n");
1026
1005
  str = str.replace(NULL_RE, "�");
1027
1006
  state.src = str;
1028
1007
  }
1029
1008
  //#endregion
1030
- //#region lib/rules_core/block.mjs
1009
+ //#region src/rules_core/block.ts
1031
1010
  function block(state) {
1032
1011
  let token;
1033
1012
  if (state.inlineMode) {
@@ -1039,7 +1018,19 @@ function block(state) {
1039
1018
  } else state.md.block.parse(state.src, state.md, state.env, state.tokens);
1040
1019
  }
1041
1020
  //#endregion
1042
- //#region lib/rules_core/inline.mjs
1021
+ //#region src/rules_core/strip_references.ts
1022
+ function strip_references(state) {
1023
+ const tokens = state.tokens;
1024
+ let last = 0;
1025
+ for (let curr = 0; curr < tokens.length; curr++) {
1026
+ if (tokens[curr].type === "reference_definition") continue;
1027
+ if (curr !== last) tokens[last] = tokens[curr];
1028
+ last++;
1029
+ }
1030
+ if (tokens.length !== last) tokens.length = last;
1031
+ }
1032
+ //#endregion
1033
+ //#region src/rules_core/inline.ts
1043
1034
  function inline(state) {
1044
1035
  const tokens = state.tokens;
1045
1036
  for (let i = 0, l = tokens.length; i < l; i++) {
@@ -1048,7 +1039,7 @@ function inline(state) {
1048
1039
  }
1049
1040
  }
1050
1041
  //#endregion
1051
- //#region lib/rules_core/linkify.mjs
1042
+ //#region src/rules_core/linkify.ts
1052
1043
  function isLinkOpen$1(str) {
1053
1044
  return /^<a[>\s]/i.test(str);
1054
1045
  }
@@ -1059,8 +1050,9 @@ function linkify$1(state) {
1059
1050
  const blockTokens = state.tokens;
1060
1051
  if (!state.md.options.linkify) return;
1061
1052
  for (let j = 0, l = blockTokens.length; j < l; j++) {
1062
- if (blockTokens[j].type !== "inline" || !state.md.linkify.pretest(blockTokens[j].content)) continue;
1063
- let tokens = blockTokens[j].children;
1053
+ if (blockTokens[j].type !== "inline" || !state.md.linkify.test(blockTokens[j].content)) continue;
1054
+ const tokens = blockTokens[j].children;
1055
+ const replacements = [];
1064
1056
  let htmlLinkLevel = 0;
1065
1057
  for (let i = tokens.length - 1; i >= 0; i--) {
1066
1058
  const currentToken = tokens[i];
@@ -1086,8 +1078,8 @@ function linkify$1(state) {
1086
1078
  const fullUrl = state.md.normalizeLink(url);
1087
1079
  if (!state.md.validateLink(fullUrl)) continue;
1088
1080
  let urlText = links[ln].text;
1089
- if (!links[ln].schema) urlText = state.md.normalizeLinkText("http://" + urlText).replace(/^http:\/\//, "");
1090
- else if (links[ln].schema === "mailto:" && !/^mailto:/i.test(urlText)) urlText = state.md.normalizeLinkText("mailto:" + urlText).replace(/^mailto:/, "");
1081
+ if (!links[ln].schema) urlText = state.md.normalizeLinkText(`http://${urlText}`).replace(/^http:\/\//, "");
1082
+ else if (links[ln].schema === "mailto:" && !/^mailto:/i.test(urlText)) urlText = state.md.normalizeLinkText(`mailto:${urlText}`).replace(/^mailto:/, "");
1091
1083
  else urlText = state.md.normalizeLinkText(urlText);
1092
1084
  const pos = links[ln].index;
1093
1085
  if (pos > lastPos) {
@@ -1119,13 +1111,32 @@ function linkify$1(state) {
1119
1111
  token.level = level;
1120
1112
  nodes.push(token);
1121
1113
  }
1122
- blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
1114
+ replacements.push({
1115
+ index: i,
1116
+ nodes
1117
+ });
1123
1118
  }
1124
1119
  }
1120
+ if (replacements.length > 0) {
1121
+ let newTokensLength = tokens.length;
1122
+ for (const replacement of replacements) newTokensLength += replacement.nodes.length - 1;
1123
+ const newTokens = new Array(newTokensLength);
1124
+ let replacementIndex = 0;
1125
+ let newTokenIndex = 0;
1126
+ replacements.reverse();
1127
+ for (let i = 0; i < tokens.length; i++) {
1128
+ const replacement = replacements[replacementIndex];
1129
+ if ((replacement === null || replacement === void 0 ? void 0 : replacement.index) === i) {
1130
+ for (const node of replacement.nodes) newTokens[newTokenIndex++] = node;
1131
+ replacementIndex++;
1132
+ } else newTokens[newTokenIndex++] = tokens[i];
1133
+ }
1134
+ blockTokens[j].children = newTokens;
1135
+ }
1125
1136
  }
1126
1137
  }
1127
1138
  //#endregion
1128
- //#region lib/rules_core/replacements.mjs
1139
+ //#region src/rules_core/replacements.ts
1129
1140
  var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
1130
1141
  var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
1131
1142
  var SCOPED_ABBR_RE = /\((c|tm|r)\)/gi;
@@ -1167,10 +1178,18 @@ function replace(state) {
1167
1178
  }
1168
1179
  }
1169
1180
  //#endregion
1170
- //#region lib/rules_core/smartquotes.mjs
1181
+ //#region src/rules_core/smartquotes.ts
1171
1182
  var QUOTE_TEST_RE = /['"]/;
1172
1183
  var QUOTE_RE = /['"]/g;
1173
1184
  var APOSTROPHE = "’";
1185
+ var MAX_OPENERS = 1e3;
1186
+ function truncateStack(stack, heads, length) {
1187
+ while (stack.length > length) {
1188
+ const item = stack.pop();
1189
+ if (item.isSingleQuote) heads.single = item.prevSameQuoteIdx;
1190
+ else heads.double = item.prevSameQuoteIdx;
1191
+ }
1192
+ }
1174
1193
  function addReplacement(replacements, tokenIdx, pos, ch) {
1175
1194
  if (!replacements[tokenIdx]) replacements[tokenIdx] = [];
1176
1195
  replacements[tokenIdx].push({
@@ -1192,12 +1211,16 @@ function applyReplacements(str, replacements) {
1192
1211
  function process_inlines(tokens, state) {
1193
1212
  let j;
1194
1213
  const stack = [];
1214
+ const heads = {
1215
+ single: -1,
1216
+ double: -1
1217
+ };
1195
1218
  const replacements = {};
1196
1219
  for (let i = 0; i < tokens.length; i++) {
1197
1220
  const token = tokens[i];
1198
1221
  const thisLevel = tokens[i].level;
1199
1222
  for (j = stack.length - 1; j >= 0; j--) if (stack[j].level <= thisLevel) break;
1200
- stack.length = j + 1;
1223
+ truncateStack(stack, heads, j + 1);
1201
1224
  if (token.type !== "text") continue;
1202
1225
  const text = token.content;
1203
1226
  let pos = 0;
@@ -1249,11 +1272,10 @@ function process_inlines(tokens, state) {
1249
1272
  if (isSingle) addReplacement(replacements, i, t.index, APOSTROPHE);
1250
1273
  continue;
1251
1274
  }
1252
- if (canClose) for (j = stack.length - 1; j >= 0; j--) {
1253
- let item = stack[j];
1254
- if (stack[j].level < thisLevel) break;
1255
- if (item.single === isSingle && stack[j].level === thisLevel) {
1256
- item = stack[j];
1275
+ if (canClose) {
1276
+ j = isSingle ? heads.single : heads.double;
1277
+ if (j >= 0 && stack[j].level === thisLevel) {
1278
+ const item = stack[j];
1257
1279
  let openQuote;
1258
1280
  let closeQuote;
1259
1281
  if (isSingle) {
@@ -1264,22 +1286,28 @@ function process_inlines(tokens, state) {
1264
1286
  closeQuote = state.md.options.quotes[1];
1265
1287
  }
1266
1288
  addReplacement(replacements, i, t.index, closeQuote);
1267
- addReplacement(replacements, item.token, item.pos, openQuote);
1268
- stack.length = j;
1289
+ addReplacement(replacements, item.tokenIdx, item.contentPos, openQuote);
1290
+ truncateStack(stack, heads, j);
1269
1291
  continue OUTER;
1270
1292
  }
1271
1293
  }
1272
- if (canOpen) stack.push({
1273
- token: i,
1274
- pos: t.index,
1275
- single: isSingle,
1276
- level: thisLevel
1277
- });
1278
- else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE);
1294
+ if (canOpen) {
1295
+ if (stack.length >= MAX_OPENERS) return;
1296
+ stack.push({
1297
+ tokenIdx: i,
1298
+ contentPos: t.index,
1299
+ isSingleQuote: isSingle,
1300
+ level: thisLevel,
1301
+ prevSameQuoteIdx: isSingle ? heads.single : heads.double
1302
+ });
1303
+ if (isSingle) heads.single = stack.length - 1;
1304
+ else heads.double = stack.length - 1;
1305
+ } else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE);
1279
1306
  }
1280
1307
  }
1281
1308
  Object.keys(replacements).forEach(function(tokenIdx) {
1282
- tokens[tokenIdx].content = applyReplacements(tokens[tokenIdx].content, replacements[tokenIdx]);
1309
+ const idx = Number(tokenIdx);
1310
+ tokens[idx].content = applyReplacements(tokens[idx].content, replacements[tokenIdx]);
1283
1311
  });
1284
1312
  }
1285
1313
  function smartquotes(state) {
@@ -1290,7 +1318,18 @@ function smartquotes(state) {
1290
1318
  }
1291
1319
  }
1292
1320
  //#endregion
1293
- //#region lib/rules_core/text_join.mjs
1321
+ //#region src/rules_core/text_join.ts
1322
+ function join_alt(tokens) {
1323
+ let curr, last;
1324
+ const max = tokens.length;
1325
+ for (curr = 0; curr < max; curr++) if (tokens[curr].type === "text_special") tokens[curr].type = "text";
1326
+ for (curr = last = 0; curr < max; curr++) if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
1327
+ else {
1328
+ if (curr !== last) tokens[last] = tokens[curr];
1329
+ last++;
1330
+ }
1331
+ if (curr !== last) tokens.length = last;
1332
+ }
1294
1333
  function text_join(state) {
1295
1334
  let curr, last;
1296
1335
  const blockTokens = state.tokens;
@@ -1299,7 +1338,10 @@ function text_join(state) {
1299
1338
  if (blockTokens[j].type !== "inline") continue;
1300
1339
  const tokens = blockTokens[j].children;
1301
1340
  const max = tokens.length;
1302
- for (curr = 0; curr < max; curr++) if (tokens[curr].type === "text_special") tokens[curr].type = "text";
1341
+ for (curr = 0; curr < max; curr++) {
1342
+ if (tokens[curr].type === "text_special") tokens[curr].type = "text";
1343
+ if (tokens[curr].children) join_alt(tokens[curr].children);
1344
+ }
1303
1345
  for (curr = last = 0; curr < max; curr++) if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
1304
1346
  else {
1305
1347
  if (curr !== last) tokens[last] = tokens[curr];
@@ -1309,16 +1351,11 @@ function text_join(state) {
1309
1351
  }
1310
1352
  }
1311
1353
  //#endregion
1312
- //#region lib/parser_core.mjs
1313
- /** internal
1314
- * class Core
1315
- *
1316
- * Top-level rules executor. Glues block/inline parsers and does intermediate
1317
- * transformations.
1318
- **/
1354
+ //#region src/parser_core.ts
1319
1355
  var _rules$2 = [
1320
1356
  ["normalize", normalize],
1321
1357
  ["block", block],
1358
+ ["strip_references", strip_references],
1322
1359
  ["inline", inline],
1323
1360
  ["linkify", linkify$1],
1324
1361
  ["replacements", replace],
@@ -1326,136 +1363,141 @@ var _rules$2 = [
1326
1363
  ["text_join", text_join]
1327
1364
  ];
1328
1365
  /**
1329
- * new Core()
1330
- **/
1331
- function Core() {
1366
+ * Top-level rules executor. Glues block/inline parsers and does intermediate
1367
+ * transformations.
1368
+ */
1369
+ var ParserCore = class {
1370
+ constructor() {
1371
+ _defineProperty(
1372
+ this,
1373
+ /**
1374
+ * {@link Ruler} instance. Keep configuration of core rules.
1375
+ */
1376
+ "ruler",
1377
+ new Ruler()
1378
+ );
1379
+ _defineProperty(this, "State", StateCore);
1380
+ for (let i = 0; i < _rules$2.length; i++) this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
1381
+ }
1332
1382
  /**
1333
- * Core#ruler -> Ruler
1334
- *
1335
- * [[Ruler]] instance. Keep configuration of core rules.
1336
- **/
1337
- this.ruler = new Ruler();
1338
- for (let i = 0; i < _rules$2.length; i++) this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
1339
- }
1340
- /**
1341
- * Core.process(state)
1342
- *
1343
- * Executes core chain rules.
1344
- **/
1345
- Core.prototype.process = function(state) {
1346
- const rules = this.ruler.getRules("");
1347
- for (let i = 0, l = rules.length; i < l; i++) rules[i](state);
1383
+ * Executes core chain rules.
1384
+ */
1385
+ process(state) {
1386
+ const rules = this.ruler.getRules("");
1387
+ for (let i = 0, l = rules.length; i < l; i++) rules[i](state);
1388
+ }
1348
1389
  };
1349
- Core.prototype.State = StateCore;
1350
1390
  //#endregion
1351
- //#region lib/rules_block/state_block.mjs
1352
- function StateBlock(src, md, env, tokens) {
1353
- this.src = src;
1354
- this.md = md;
1355
- this.env = env;
1356
- this.tokens = tokens;
1357
- this.bMarks = [];
1358
- this.eMarks = [];
1359
- this.tShift = [];
1360
- this.sCount = [];
1361
- this.bsCount = [];
1362
- this.blkIndent = 0;
1363
- this.line = 0;
1364
- this.lineMax = 0;
1365
- this.tight = false;
1366
- this.ddIndent = -1;
1367
- this.listIndent = -1;
1368
- this.parentType = "root";
1369
- this.level = 0;
1370
- const s = this.src;
1371
- for (let start = 0, pos = 0, indent = 0, offset = 0, len = s.length, indent_found = false; pos < len; pos++) {
1372
- const ch = s.charCodeAt(pos);
1373
- if (!indent_found) if (isSpace(ch)) {
1374
- indent++;
1375
- if (ch === 9) offset += 4 - offset % 4;
1376
- else offset++;
1377
- continue;
1378
- } else indent_found = true;
1379
- if (ch === 10 || pos === len - 1) {
1380
- if (ch !== 10) pos++;
1381
- this.bMarks.push(start);
1382
- this.eMarks.push(pos);
1383
- this.tShift.push(indent);
1384
- this.sCount.push(offset);
1385
- this.bsCount.push(0);
1386
- indent_found = false;
1387
- indent = 0;
1388
- offset = 0;
1389
- start = pos + 1;
1391
+ //#region src/rules_block/state_block.ts
1392
+ /** Mutable state passed to block rules while tokenizing a source document. */
1393
+ var StateBlock = class {
1394
+ constructor(src, md, env, tokens) {
1395
+ _defineProperty(this, "bMarks", []);
1396
+ _defineProperty(this, "eMarks", []);
1397
+ _defineProperty(this, "tShift", []);
1398
+ _defineProperty(this, "sCount", []);
1399
+ _defineProperty(this, "bsCount", []);
1400
+ _defineProperty(this, "blkIndent", 0);
1401
+ _defineProperty(this, "line", 0);
1402
+ _defineProperty(this, "lineMax", 0);
1403
+ _defineProperty(this, "tight", false);
1404
+ _defineProperty(this, "listIndent", -1);
1405
+ _defineProperty(this, "parentType", "root");
1406
+ _defineProperty(this, "level", 0);
1407
+ _defineProperty(this, "Token", Token);
1408
+ this.src = src;
1409
+ this.md = md;
1410
+ this.env = env;
1411
+ this.tokens = tokens;
1412
+ const s = this.src;
1413
+ for (let start = 0, pos = 0, indent = 0, offset = 0, len = s.length, indent_found = false; pos < len; pos++) {
1414
+ const ch = s.charCodeAt(pos);
1415
+ if (!indent_found) if (isSpace(ch)) {
1416
+ indent++;
1417
+ if (ch === 9) offset += 4 - offset % 4;
1418
+ else offset++;
1419
+ continue;
1420
+ } else indent_found = true;
1421
+ if (ch === 10 || pos === len - 1) {
1422
+ if (ch !== 10) pos++;
1423
+ this.bMarks.push(start);
1424
+ this.eMarks.push(pos);
1425
+ this.tShift.push(indent);
1426
+ this.sCount.push(offset);
1427
+ this.bsCount.push(0);
1428
+ indent_found = false;
1429
+ indent = 0;
1430
+ offset = 0;
1431
+ start = pos + 1;
1432
+ }
1390
1433
  }
1391
- }
1392
- this.bMarks.push(s.length);
1393
- this.eMarks.push(s.length);
1394
- this.tShift.push(0);
1395
- this.sCount.push(0);
1396
- this.bsCount.push(0);
1397
- this.lineMax = this.bMarks.length - 1;
1398
- }
1399
- StateBlock.prototype.push = function(type, tag, nesting) {
1400
- const token = new Token(type, tag, nesting);
1401
- token.block = true;
1402
- if (nesting < 0) this.level--;
1403
- token.level = this.level;
1404
- if (nesting > 0) this.level++;
1405
- this.tokens.push(token);
1406
- return token;
1407
- };
1408
- StateBlock.prototype.isEmpty = function isEmpty(line) {
1409
- return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
1410
- };
1411
- StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
1412
- for (let max = this.lineMax; from < max; from++) if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) break;
1413
- return from;
1414
- };
1415
- StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
1416
- for (let max = this.src.length; pos < max; pos++) if (!isSpace(this.src.charCodeAt(pos))) break;
1417
- return pos;
1418
- };
1419
- StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
1420
- if (pos <= min) return pos;
1421
- while (pos > min) if (!isSpace(this.src.charCodeAt(--pos))) return pos + 1;
1422
- return pos;
1423
- };
1424
- StateBlock.prototype.skipChars = function skipChars(pos, code) {
1425
- for (let max = this.src.length; pos < max; pos++) if (this.src.charCodeAt(pos) !== code) break;
1426
- return pos;
1427
- };
1428
- StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
1429
- if (pos <= min) return pos;
1430
- while (pos > min) if (code !== this.src.charCodeAt(--pos)) return pos + 1;
1431
- return pos;
1432
- };
1433
- StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
1434
- if (begin >= end) return "";
1435
- const queue = new Array(end - begin);
1436
- for (let i = 0, line = begin; line < end; line++, i++) {
1437
- let lineIndent = 0;
1438
- const lineStart = this.bMarks[line];
1439
- let first = lineStart;
1440
- let last;
1441
- if (line + 1 < end || keepLastLF) last = this.eMarks[line] + 1;
1442
- else last = this.eMarks[line];
1443
- while (first < last && lineIndent < indent) {
1444
- const ch = this.src.charCodeAt(first);
1445
- if (isSpace(ch)) if (ch === 9) lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
1446
- else lineIndent++;
1447
- else if (first - lineStart < this.tShift[line]) lineIndent++;
1448
- else break;
1449
- first++;
1434
+ this.bMarks.push(s.length);
1435
+ this.eMarks.push(s.length);
1436
+ this.tShift.push(0);
1437
+ this.sCount.push(0);
1438
+ this.bsCount.push(0);
1439
+ this.lineMax = this.bMarks.length - 1;
1440
+ }
1441
+ push(type, tag, nesting) {
1442
+ const token = new Token(type, tag, nesting);
1443
+ token.block = true;
1444
+ if (nesting < 0) this.level--;
1445
+ token.level = this.level;
1446
+ if (nesting > 0) this.level++;
1447
+ this.tokens.push(token);
1448
+ return token;
1449
+ }
1450
+ isEmpty(line) {
1451
+ return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
1452
+ }
1453
+ skipEmptyLines(from) {
1454
+ for (let max = this.lineMax; from < max; from++) if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) break;
1455
+ return from;
1456
+ }
1457
+ skipSpaces(pos) {
1458
+ for (let max = this.src.length; pos < max; pos++) if (!isSpace(this.src.charCodeAt(pos))) break;
1459
+ return pos;
1460
+ }
1461
+ skipSpacesBack(pos, min) {
1462
+ if (pos <= min) return pos;
1463
+ while (pos > min) if (!isSpace(this.src.charCodeAt(--pos))) return pos + 1;
1464
+ return pos;
1465
+ }
1466
+ skipChars(pos, code) {
1467
+ for (let max = this.src.length; pos < max; pos++) if (this.src.charCodeAt(pos) !== code) break;
1468
+ return pos;
1469
+ }
1470
+ skipCharsBack(pos, code, min) {
1471
+ if (pos <= min) return pos;
1472
+ while (pos > min) if (code !== this.src.charCodeAt(--pos)) return pos + 1;
1473
+ return pos;
1474
+ }
1475
+ getLines(begin, end, indent, keepLastLF) {
1476
+ if (begin >= end) return "";
1477
+ const queue = new Array(end - begin);
1478
+ for (let i = 0, line = begin; line < end; line++, i++) {
1479
+ let lineIndent = 0;
1480
+ const lineStart = this.bMarks[line];
1481
+ let first = lineStart;
1482
+ let last;
1483
+ if (line + 1 < end || keepLastLF) last = this.eMarks[line] + 1;
1484
+ else last = this.eMarks[line];
1485
+ while (first < last && lineIndent < indent) {
1486
+ const ch = this.src.charCodeAt(first);
1487
+ if (isSpace(ch)) if (ch === 9) lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
1488
+ else lineIndent++;
1489
+ else if (first - lineStart < this.tShift[line]) lineIndent++;
1490
+ else break;
1491
+ first++;
1492
+ }
1493
+ if (lineIndent > indent) queue[i] = new Array(lineIndent - indent + 1).join(" ") + this.src.slice(first, last);
1494
+ else queue[i] = this.src.slice(first, last);
1450
1495
  }
1451
- if (lineIndent > indent) queue[i] = new Array(lineIndent - indent + 1).join(" ") + this.src.slice(first, last);
1452
- else queue[i] = this.src.slice(first, last);
1496
+ return queue.join("");
1453
1497
  }
1454
- return queue.join("");
1455
1498
  };
1456
- StateBlock.prototype.Token = Token;
1457
1499
  //#endregion
1458
- //#region lib/rules_block/table.mjs
1500
+ //#region src/rules_block/table.ts
1459
1501
  var MAX_AUTOCOMPLETED_CELLS = 65536;
1460
1502
  function getLine(state, line) {
1461
1503
  const pos = state.bMarks[line] + state.tShift[line];
@@ -1537,7 +1579,7 @@ function table(state, startLine, endLine, silent) {
1537
1579
  token_htro.map = [startLine, startLine + 1];
1538
1580
  for (let i = 0; i < columns.length; i++) {
1539
1581
  const token_ho = state.push("th_open", "th", 1);
1540
- if (aligns[i]) token_ho.attrs = [["style", "text-align:" + aligns[i]]];
1582
+ if (aligns[i]) token_ho.attrs = [["style", `text-align:${aligns[i]}`]];
1541
1583
  const token_il = state.push("inline", "", 0);
1542
1584
  token_il.content = columns[i].trim();
1543
1585
  token_il.children = [];
@@ -1571,7 +1613,7 @@ function table(state, startLine, endLine, silent) {
1571
1613
  token_tro.map = [nextLine, nextLine + 1];
1572
1614
  for (let i = 0; i < columnCount; i++) {
1573
1615
  const token_tdo = state.push("td_open", "td", 1);
1574
- if (aligns[i]) token_tdo.attrs = [["style", "text-align:" + aligns[i]]];
1616
+ if (aligns[i]) token_tdo.attrs = [["style", `text-align:${aligns[i]}`]];
1575
1617
  const token_il = state.push("inline", "", 0);
1576
1618
  token_il.content = columns[i] ? columns[i].trim() : "";
1577
1619
  token_il.children = [];
@@ -1590,7 +1632,7 @@ function table(state, startLine, endLine, silent) {
1590
1632
  return true;
1591
1633
  }
1592
1634
  //#endregion
1593
- //#region lib/rules_block/code.mjs
1635
+ //#region src/rules_block/code.ts
1594
1636
  function code(state, startLine, endLine) {
1595
1637
  if (state.sCount[startLine] - state.blkIndent < 4) return false;
1596
1638
  let nextLine = startLine + 1;
@@ -1614,7 +1656,7 @@ function code(state, startLine, endLine) {
1614
1656
  return true;
1615
1657
  }
1616
1658
  //#endregion
1617
- //#region lib/rules_block/fence.mjs
1659
+ //#region src/rules_block/fence.ts
1618
1660
  function fence(state, startLine, endLine, silent) {
1619
1661
  let pos = state.bMarks[startLine] + state.tShift[startLine];
1620
1662
  let max = state.eMarks[startLine];
@@ -1659,7 +1701,7 @@ function fence(state, startLine, endLine, silent) {
1659
1701
  return true;
1660
1702
  }
1661
1703
  //#endregion
1662
- //#region lib/rules_block/blockquote.mjs
1704
+ //#region src/rules_block/blockquote.ts
1663
1705
  function blockquote(state, startLine, endLine, silent) {
1664
1706
  let pos = state.bMarks[startLine] + state.tShift[startLine];
1665
1707
  let max = state.eMarks[startLine];
@@ -1762,7 +1804,7 @@ function blockquote(state, startLine, endLine, silent) {
1762
1804
  return true;
1763
1805
  }
1764
1806
  //#endregion
1765
- //#region lib/rules_block/hr.mjs
1807
+ //#region src/rules_block/hr.ts
1766
1808
  function hr(state, startLine, endLine, silent) {
1767
1809
  const max = state.eMarks[startLine];
1768
1810
  if (state.sCount[startLine] - state.blkIndent >= 4) return false;
@@ -1784,7 +1826,7 @@ function hr(state, startLine, endLine, silent) {
1784
1826
  return true;
1785
1827
  }
1786
1828
  //#endregion
1787
- //#region lib/rules_block/list.mjs
1829
+ //#region src/rules_block/list.ts
1788
1830
  function skipBulletListMarker(state, startLine) {
1789
1831
  const max = state.eMarks[startLine];
1790
1832
  let pos = state.bMarks[startLine] + state.tShift[startLine];
@@ -1896,7 +1938,7 @@ function list(state, startLine, endLine, silent) {
1896
1938
  state.tShift[nextLine] = contentStart - state.bMarks[nextLine];
1897
1939
  state.sCount[nextLine] = offset;
1898
1940
  if (contentStart >= max && state.isEmpty(nextLine + 1)) state.line = Math.min(state.line + 2, endLine);
1899
- else state.md.block.tokenize(state, nextLine, endLine, true);
1941
+ else state.md.block.tokenize(state, nextLine, endLine);
1900
1942
  if (!state.tight || prevEmptyEnd) tight = false;
1901
1943
  prevEmptyEnd = state.line - nextLine > 1 && state.isEmpty(state.line - 1);
1902
1944
  state.blkIndent = state.listIndent;
@@ -1937,7 +1979,7 @@ function list(state, startLine, endLine, silent) {
1937
1979
  return true;
1938
1980
  }
1939
1981
  //#endregion
1940
- //#region lib/rules_block/reference.mjs
1982
+ //#region src/rules_block/reference.ts
1941
1983
  function reference(state, startLine, _endLine, silent) {
1942
1984
  let pos = state.bMarks[startLine] + state.tShift[startLine];
1943
1985
  let max = state.eMarks[startLine];
@@ -2069,11 +2111,17 @@ function reference(state, startLine, _endLine, silent) {
2069
2111
  title,
2070
2112
  href
2071
2113
  };
2114
+ const token = state.push("reference_definition", "", 0);
2115
+ token.map = [startLine, nextLine];
2116
+ token.hidden = true;
2117
+ const meta = Object.create(null);
2118
+ meta.label = label;
2119
+ token.meta = meta;
2072
2120
  state.line = nextLine;
2073
2121
  return true;
2074
2122
  }
2075
2123
  //#endregion
2076
- //#region lib/common/html_blocks.mjs
2124
+ //#region src/common/html_blocks.ts
2077
2125
  var html_blocks_default = [
2078
2126
  "address",
2079
2127
  "article",
@@ -2139,11 +2187,13 @@ var html_blocks_default = [
2139
2187
  "ul"
2140
2188
  ];
2141
2189
  //#endregion
2142
- //#region lib/common/html_re.mjs
2143
- var HTML_TAG_RE = /* @__PURE__ */ new RegExp("^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)");
2144
- var HTML_OPEN_CLOSE_TAG_RE = /* @__PURE__ */ new RegExp("^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>)");
2190
+ //#region src/common/html_re.ts
2191
+ var open_tag = `<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`;
2192
+ var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";
2193
+ var HTML_TAG_RE = new RegExp(`^(?:${open_tag}|${close_tag}|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`);
2194
+ var HTML_OPEN_CLOSE_TAG_RE = new RegExp(`^(?:${open_tag}|${close_tag})`);
2145
2195
  //#endregion
2146
- //#region lib/rules_block/html_block.mjs
2196
+ //#region src/rules_block/html_block.ts
2147
2197
  var HTML_SEQUENCES = [
2148
2198
  [
2149
2199
  /^<(script|pre|style|textarea)(?=(\s|>|$))/i,
@@ -2161,7 +2211,7 @@ var HTML_SEQUENCES = [
2161
2211
  true
2162
2212
  ],
2163
2213
  [
2164
- /^<![A-Z]/,
2214
+ /^<![A-Za-z]/,
2165
2215
  />/,
2166
2216
  true
2167
2217
  ],
@@ -2171,12 +2221,12 @@ var HTML_SEQUENCES = [
2171
2221
  true
2172
2222
  ],
2173
2223
  [
2174
- new RegExp("^</?(" + html_blocks_default.join("|") + ")(?=(\\s|/?>|$))", "i"),
2224
+ new RegExp(`^</?(${html_blocks_default.join("|")})(?=(\\s|/?>|$))`, "i"),
2175
2225
  /^$/,
2176
2226
  true
2177
2227
  ],
2178
2228
  [
2179
- new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + "\\s*$"),
2229
+ new RegExp(`${HTML_OPEN_CLOSE_TAG_RE.source}\\s*$`),
2180
2230
  /^$/,
2181
2231
  false
2182
2232
  ]
@@ -2213,7 +2263,7 @@ function html_block(state, startLine, endLine, silent) {
2213
2263
  return true;
2214
2264
  }
2215
2265
  //#endregion
2216
- //#region lib/rules_block/heading.mjs
2266
+ //#region src/rules_block/heading.ts
2217
2267
  function heading(state, startLine, endLine, silent) {
2218
2268
  let pos = state.bMarks[startLine] + state.tShift[startLine];
2219
2269
  let max = state.eMarks[startLine];
@@ -2232,19 +2282,19 @@ function heading(state, startLine, endLine, silent) {
2232
2282
  const tmp = state.skipCharsBack(max, 35, pos);
2233
2283
  if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) max = tmp;
2234
2284
  state.line = startLine + 1;
2235
- const token_o = state.push("heading_open", "h" + String(level), 1);
2285
+ const token_o = state.push("heading_open", `h${level}`, 1);
2236
2286
  token_o.markup = "########".slice(0, level);
2237
2287
  token_o.map = [startLine, state.line];
2238
2288
  const token_i = state.push("inline", "", 0);
2239
2289
  token_i.content = asciiTrim(state.src.slice(pos, max));
2240
2290
  token_i.map = [startLine, state.line];
2241
2291
  token_i.children = [];
2242
- const token_c = state.push("heading_close", "h" + String(level), -1);
2292
+ const token_c = state.push("heading_close", `h${level}`, -1);
2243
2293
  token_c.markup = "########".slice(0, level);
2244
2294
  return true;
2245
2295
  }
2246
2296
  //#endregion
2247
- //#region lib/rules_block/lheading.mjs
2297
+ //#region src/rules_block/lheading.ts
2248
2298
  function lheading(state, startLine, endLine) {
2249
2299
  const terminatorRules = state.md.block.ruler.getRules("paragraph");
2250
2300
  if (state.sCount[startLine] - state.blkIndent >= 4) return false;
@@ -2284,20 +2334,20 @@ function lheading(state, startLine, endLine) {
2284
2334
  }
2285
2335
  const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
2286
2336
  state.line = nextLine + 1;
2287
- const token_o = state.push("heading_open", "h" + String(level), 1);
2337
+ const token_o = state.push("heading_open", `h${level}`, 1);
2288
2338
  token_o.markup = String.fromCharCode(marker);
2289
2339
  token_o.map = [startLine, state.line];
2290
2340
  const token_i = state.push("inline", "", 0);
2291
2341
  token_i.content = content;
2292
2342
  token_i.map = [startLine, state.line - 1];
2293
2343
  token_i.children = [];
2294
- const token_c = state.push("heading_close", "h" + String(level), -1);
2344
+ const token_c = state.push("heading_close", `h${level}`, -1);
2295
2345
  token_c.markup = String.fromCharCode(marker);
2296
2346
  state.parentType = oldParentType;
2297
2347
  return true;
2298
2348
  }
2299
2349
  //#endregion
2300
- //#region lib/rules_block/paragraph.mjs
2350
+ //#region src/rules_block/paragraph.ts
2301
2351
  function paragraph(state, startLine, endLine) {
2302
2352
  const terminatorRules = state.md.block.ruler.getRules("paragraph");
2303
2353
  const oldParentType = state.parentType;
@@ -2326,12 +2376,7 @@ function paragraph(state, startLine, endLine) {
2326
2376
  return true;
2327
2377
  }
2328
2378
  //#endregion
2329
- //#region lib/parser_block.mjs
2330
- /** internal
2331
- * class ParserBlock
2332
- *
2333
- * Block-level tokenizer.
2334
- **/
2379
+ //#region src/parser_block.ts
2335
2380
  var _rules$1 = [
2336
2381
  [
2337
2382
  "table",
@@ -2401,148 +2446,153 @@ var _rules$1 = [
2401
2446
  ["paragraph", paragraph]
2402
2447
  ];
2403
2448
  /**
2404
- * new ParserBlock()
2405
- **/
2406
- function ParserBlock() {
2407
- /**
2408
- * ParserBlock#ruler -> Ruler
2409
- *
2410
- * [[Ruler]] instance. Keep configuration of block rules.
2411
- **/
2412
- this.ruler = new Ruler();
2413
- for (let i = 0; i < _rules$1.length; i++) this.ruler.push(_rules$1[i][0], _rules$1[i][1], { alt: (_rules$1[i][2] || []).slice() });
2414
- }
2415
- ParserBlock.prototype.tokenize = function(state, startLine, endLine) {
2416
- const rules = this.ruler.getRules("");
2417
- const len = rules.length;
2418
- const maxNesting = state.md.options.maxNesting;
2419
- let line = startLine;
2420
- let hasEmptyLines = false;
2421
- while (line < endLine) {
2422
- state.line = line = state.skipEmptyLines(line);
2423
- if (line >= endLine) break;
2424
- if (state.sCount[line] < state.blkIndent) break;
2425
- if (state.level >= maxNesting) {
2426
- state.line = endLine;
2427
- break;
2428
- }
2429
- const prevLine = state.line;
2430
- let ok = false;
2431
- for (let i = 0; i < len; i++) {
2432
- ok = rules[i](state, line, endLine, false);
2433
- if (ok) {
2434
- if (prevLine >= state.line) throw new Error("block rule didn't increment state.line");
2449
+ * Block-level tokenizer.
2450
+ */
2451
+ var ParserBlock = class {
2452
+ constructor() {
2453
+ _defineProperty(
2454
+ this,
2455
+ /**
2456
+ * {@link Ruler} instance. Keep configuration of block rules.
2457
+ */
2458
+ "ruler",
2459
+ new Ruler()
2460
+ );
2461
+ _defineProperty(this, "State", StateBlock);
2462
+ for (let i = 0; i < _rules$1.length; i++) this.ruler.push(_rules$1[i][0], _rules$1[i][1], { alt: (_rules$1[i][2] || []).slice() });
2463
+ }
2464
+ tokenize(state, startLine, endLine) {
2465
+ const rules = this.ruler.getRules("");
2466
+ const len = rules.length;
2467
+ const maxNesting = state.md.options.maxNesting;
2468
+ let line = startLine;
2469
+ let hasEmptyLines = false;
2470
+ while (line < endLine) {
2471
+ state.line = line = state.skipEmptyLines(line);
2472
+ if (line >= endLine) break;
2473
+ if (state.sCount[line] < state.blkIndent) break;
2474
+ if (state.level >= maxNesting) {
2475
+ state.line = endLine;
2435
2476
  break;
2436
2477
  }
2437
- }
2438
- if (!ok) throw new Error("none of the block rules matched");
2439
- state.tight = !hasEmptyLines;
2440
- if (state.isEmpty(state.line - 1)) hasEmptyLines = true;
2441
- line = state.line;
2442
- if (line < endLine && state.isEmpty(line)) {
2443
- hasEmptyLines = true;
2444
- line++;
2445
- state.line = line;
2478
+ const prevLine = state.line;
2479
+ let ok = false;
2480
+ for (let i = 0; i < len; i++) {
2481
+ ok = rules[i](state, line, endLine, false);
2482
+ if (ok) {
2483
+ if (prevLine >= state.line) throw new Error("block rule didn't increment state.line");
2484
+ break;
2485
+ }
2486
+ }
2487
+ if (!ok) throw new Error("none of the block rules matched");
2488
+ state.tight = !hasEmptyLines;
2489
+ if (state.isEmpty(state.line - 1)) hasEmptyLines = true;
2490
+ line = state.line;
2491
+ if (line < endLine && state.isEmpty(line)) {
2492
+ hasEmptyLines = true;
2493
+ line++;
2494
+ state.line = line;
2495
+ }
2446
2496
  }
2447
2497
  }
2498
+ /**
2499
+ * Process input string and push block tokens into `outTokens`
2500
+ */
2501
+ parse(src, md, env, outTokens) {
2502
+ if (!src) return;
2503
+ const state = new this.State(src, md, env, outTokens);
2504
+ this.tokenize(state, state.line, state.lineMax);
2505
+ }
2448
2506
  };
2449
- /**
2450
- * ParserBlock.parse(str, md, env, outTokens)
2451
- *
2452
- * Process input string and push block tokens into `outTokens`
2453
- **/
2454
- ParserBlock.prototype.parse = function(src, md, env, outTokens) {
2455
- if (!src) return;
2456
- const state = new this.State(src, md, env, outTokens);
2457
- this.tokenize(state, state.line, state.lineMax);
2458
- };
2459
- ParserBlock.prototype.State = StateBlock;
2460
2507
  //#endregion
2461
- //#region lib/rules_inline/state_inline.mjs
2462
- function StateInline(src, md, env, outTokens) {
2463
- this.src = src;
2464
- this.env = env;
2465
- this.md = md;
2466
- this.tokens = outTokens;
2467
- this.tokens_meta = Array(outTokens.length);
2468
- this.pos = 0;
2469
- this.posMax = this.src.length;
2470
- this.level = 0;
2471
- this.pending = "";
2472
- this.pendingLevel = 0;
2473
- this.cache = {};
2474
- this.delimiters = [];
2475
- this._prev_delimiters = [];
2476
- this.backticks = {};
2477
- this.backticksScanned = false;
2478
- this.linkLevel = 0;
2479
- }
2480
- StateInline.prototype.pushPending = function() {
2481
- const token = new Token("text", "", 0);
2482
- token.content = this.pending;
2483
- token.level = this.pendingLevel;
2484
- this.tokens.push(token);
2485
- this.pending = "";
2486
- return token;
2487
- };
2488
- StateInline.prototype.push = function(type, tag, nesting) {
2489
- if (this.pending) this.pushPending();
2490
- const token = new Token(type, tag, nesting);
2491
- let token_meta = null;
2492
- if (nesting < 0) {
2493
- this.level--;
2494
- this.delimiters = this._prev_delimiters.pop();
2495
- }
2496
- token.level = this.level;
2497
- if (nesting > 0) {
2498
- this.level++;
2499
- this._prev_delimiters.push(this.delimiters);
2500
- this.delimiters = [];
2501
- token_meta = { delimiters: this.delimiters };
2502
- }
2503
- this.pendingLevel = this.level;
2504
- this.tokens.push(token);
2505
- this.tokens_meta.push(token_meta);
2506
- return token;
2507
- };
2508
- StateInline.prototype.scanDelims = function(start, canSplitWord) {
2509
- const max = this.posMax;
2510
- const marker = this.src.charCodeAt(start);
2511
- let lastChar;
2512
- if (start === 0) lastChar = 32;
2513
- else if (start === 1) {
2514
- lastChar = this.src.charCodeAt(0);
2515
- if ((lastChar & 63488) === 55296) lastChar = 65533;
2516
- } else {
2517
- lastChar = this.src.charCodeAt(start - 1);
2518
- if ((lastChar & 64512) === 56320) {
2519
- const highSurr = this.src.charCodeAt(start - 2);
2520
- lastChar = (highSurr & 64512) === 55296 ? 65536 + (highSurr - 55296 << 10) + (lastChar - 56320) : 65533;
2521
- } else if ((lastChar & 64512) === 55296) lastChar = 65533;
2508
+ //#region src/rules_inline/state_inline.ts
2509
+ /** Mutable state passed to inline rules while tokenizing inline content. */
2510
+ var StateInline = class {
2511
+ constructor(src, md, env, outTokens) {
2512
+ _defineProperty(this, "pos", 0);
2513
+ _defineProperty(this, "level", 0);
2514
+ _defineProperty(this, "pending", "");
2515
+ _defineProperty(this, "pendingLevel", 0);
2516
+ _defineProperty(this, "cache", {});
2517
+ _defineProperty(this, "backticks", {});
2518
+ _defineProperty(this, "backticksScanned", false);
2519
+ _defineProperty(this, "linkLevel", 0);
2520
+ _defineProperty(this, "delimiters", []);
2521
+ _defineProperty(this, "_prev_delimiters", []);
2522
+ _defineProperty(this, "Token", Token);
2523
+ this.src = src;
2524
+ this.env = env;
2525
+ this.md = md;
2526
+ this.tokens = outTokens;
2527
+ this.tokens_meta = Array(outTokens.length);
2528
+ this.posMax = this.src.length;
2529
+ }
2530
+ pushPending() {
2531
+ const token = new Token("text", "", 0);
2532
+ token.content = this.pending;
2533
+ token.level = this.pendingLevel;
2534
+ this.tokens.push(token);
2535
+ this.pending = "";
2536
+ return token;
2537
+ }
2538
+ push(type, tag, nesting) {
2539
+ if (this.pending) this.pushPending();
2540
+ const token = new Token(type, tag, nesting);
2541
+ let token_meta = void 0;
2542
+ if (nesting < 0) {
2543
+ this.level--;
2544
+ this.delimiters = this._prev_delimiters.pop();
2545
+ }
2546
+ token.level = this.level;
2547
+ if (nesting > 0) {
2548
+ this.level++;
2549
+ this._prev_delimiters.push(this.delimiters);
2550
+ this.delimiters = [];
2551
+ token_meta = { delimiters: this.delimiters };
2552
+ }
2553
+ this.pendingLevel = this.level;
2554
+ this.tokens.push(token);
2555
+ this.tokens_meta.push(token_meta);
2556
+ return token;
2557
+ }
2558
+ scanDelims(start, canSplitWord) {
2559
+ const max = this.posMax;
2560
+ const marker = this.src.charCodeAt(start);
2561
+ let lastChar;
2562
+ if (start === 0) lastChar = 32;
2563
+ else if (start === 1) {
2564
+ lastChar = this.src.charCodeAt(0);
2565
+ if ((lastChar & 63488) === 55296) lastChar = 65533;
2566
+ } else {
2567
+ lastChar = this.src.charCodeAt(start - 1);
2568
+ if ((lastChar & 64512) === 56320) {
2569
+ const highSurr = this.src.charCodeAt(start - 2);
2570
+ lastChar = (highSurr & 64512) === 55296 ? 65536 + (highSurr - 55296 << 10) + (lastChar - 56320) : 65533;
2571
+ } else if ((lastChar & 64512) === 55296) lastChar = 65533;
2572
+ }
2573
+ let pos = start;
2574
+ while (pos < max && this.src.charCodeAt(pos) === marker) pos++;
2575
+ const count = pos - start;
2576
+ let nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
2577
+ if ((nextChar & 64512) === 55296) {
2578
+ const lowSurr = this.src.charCodeAt(pos + 1);
2579
+ nextChar = (lowSurr & 64512) === 56320 ? 65536 + (nextChar - 55296 << 10) + (lowSurr - 56320) : 65533;
2580
+ } else if ((nextChar & 64512) === 56320) nextChar = 65533;
2581
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
2582
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
2583
+ const isLastWhiteSpace = isWhiteSpace(lastChar);
2584
+ const isNextWhiteSpace = isWhiteSpace(nextChar);
2585
+ const left_flanking = !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar);
2586
+ const right_flanking = !isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar);
2587
+ return {
2588
+ can_open: left_flanking && (canSplitWord || !right_flanking || isLastPunctChar),
2589
+ can_close: right_flanking && (canSplitWord || !left_flanking || isNextPunctChar),
2590
+ length: count
2591
+ };
2522
2592
  }
2523
- let pos = start;
2524
- while (pos < max && this.src.charCodeAt(pos) === marker) pos++;
2525
- const count = pos - start;
2526
- let nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
2527
- if ((nextChar & 64512) === 55296) {
2528
- const lowSurr = this.src.charCodeAt(pos + 1);
2529
- nextChar = (lowSurr & 64512) === 56320 ? 65536 + (nextChar - 55296 << 10) + (lowSurr - 56320) : 65533;
2530
- } else if ((nextChar & 64512) === 56320) nextChar = 65533;
2531
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
2532
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
2533
- const isLastWhiteSpace = isWhiteSpace(lastChar);
2534
- const isNextWhiteSpace = isWhiteSpace(nextChar);
2535
- const left_flanking = !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar);
2536
- const right_flanking = !isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar);
2537
- return {
2538
- can_open: left_flanking && (canSplitWord || !right_flanking || isLastPunctChar),
2539
- can_close: right_flanking && (canSplitWord || !left_flanking || isNextPunctChar),
2540
- length: count
2541
- };
2542
2593
  };
2543
- StateInline.prototype.Token = Token;
2544
2594
  //#endregion
2545
- //#region lib/rules_inline/text.mjs
2595
+ //#region src/rules_inline/text.ts
2546
2596
  function isTerminatorChar(ch) {
2547
2597
  switch (ch) {
2548
2598
  case 10:
@@ -2580,8 +2630,13 @@ function text(state, silent) {
2580
2630
  return true;
2581
2631
  }
2582
2632
  //#endregion
2583
- //#region lib/rules_inline/linkify.mjs
2584
- var SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;
2633
+ //#region src/rules_inline/linkify.ts
2634
+ function isAsciiAlpha(code) {
2635
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122;
2636
+ }
2637
+ function isSchemeChar(code) {
2638
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 45 || code === 46;
2639
+ }
2585
2640
  function linkify(state, silent) {
2586
2641
  if (!state.md.options.linkify) return false;
2587
2642
  if (state.linkLevel > 0) return false;
@@ -2591,20 +2646,22 @@ function linkify(state, silent) {
2591
2646
  if (state.src.charCodeAt(pos) !== 58) return false;
2592
2647
  if (state.src.charCodeAt(pos + 1) !== 47) return false;
2593
2648
  if (state.src.charCodeAt(pos + 2) !== 47) return false;
2594
- const match = state.pending.match(SCHEME_RE);
2595
- if (!match) return false;
2596
- const proto = match[1];
2597
- const link = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length));
2649
+ const protoMin = pos - Math.min(10, state.pending.length, pos);
2650
+ let protoStart = pos;
2651
+ while (protoStart > protoMin && isSchemeChar(state.src.charCodeAt(protoStart - 1))) protoStart--;
2652
+ if (protoStart === pos || !isAsciiAlpha(state.src.charCodeAt(protoStart))) return false;
2653
+ const protoLength = pos - protoStart;
2654
+ const link = state.md.linkify.matchAtStart(state.src.slice(protoStart));
2598
2655
  if (!link) return false;
2599
2656
  let url = link.url;
2600
- if (url.length <= proto.length) return false;
2657
+ if (url.length <= protoLength) return false;
2601
2658
  let urlEnd = url.length;
2602
2659
  while (urlEnd > 0 && url.charCodeAt(urlEnd - 1) === 42) urlEnd--;
2603
2660
  if (urlEnd !== url.length) url = url.slice(0, urlEnd);
2604
2661
  const fullUrl = state.md.normalizeLink(url);
2605
2662
  if (!state.md.validateLink(fullUrl)) return false;
2606
2663
  if (!silent) {
2607
- state.pending = state.pending.slice(0, -proto.length);
2664
+ state.pending = state.pending.slice(0, -protoLength);
2608
2665
  const token_o = state.push("link_open", "a", 1);
2609
2666
  token_o.attrs = [["href", fullUrl]];
2610
2667
  token_o.markup = "linkify";
@@ -2615,11 +2672,11 @@ function linkify(state, silent) {
2615
2672
  token_c.markup = "linkify";
2616
2673
  token_c.info = "auto";
2617
2674
  }
2618
- state.pos += url.length - proto.length;
2675
+ state.pos += url.length - protoLength;
2619
2676
  return true;
2620
2677
  }
2621
2678
  //#endregion
2622
- //#region lib/rules_inline/newline.mjs
2679
+ //#region src/rules_inline/newline.ts
2623
2680
  function newline(state, silent) {
2624
2681
  let pos = state.pos;
2625
2682
  if (state.src.charCodeAt(pos) !== 10) return false;
@@ -2641,7 +2698,7 @@ function newline(state, silent) {
2641
2698
  return true;
2642
2699
  }
2643
2700
  //#endregion
2644
- //#region lib/rules_inline/escape.mjs
2701
+ //#region src/rules_inline/escape.ts
2645
2702
  var ESCAPED = [];
2646
2703
  for (let i = 0; i < 256; i++) ESCAPED.push(0);
2647
2704
  "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(ch) {
@@ -2695,45 +2752,56 @@ function escape(state, silent) {
2695
2752
  return true;
2696
2753
  }
2697
2754
  //#endregion
2698
- //#region lib/rules_inline/backticks.mjs
2755
+ //#region src/rules_inline/backticks.ts
2756
+ function buildLastRuns(src) {
2757
+ const lastRuns = {};
2758
+ let pos = 0;
2759
+ while ((pos = src.indexOf("`", pos)) !== -1) {
2760
+ const start = pos;
2761
+ while (src.charCodeAt(++pos) === 96);
2762
+ lastRuns[pos - start] = start;
2763
+ }
2764
+ return lastRuns;
2765
+ }
2699
2766
  function backtick(state, silent) {
2700
- let pos = state.pos;
2701
- if (state.src.charCodeAt(pos) !== 96) return false;
2702
- const start = pos;
2703
- pos++;
2767
+ var _state$backticks$open;
2768
+ const start = state.pos;
2769
+ if (state.src.charCodeAt(start) !== 96) return false;
2704
2770
  const max = state.posMax;
2771
+ let pos = start + 1;
2705
2772
  while (pos < max && state.src.charCodeAt(pos) === 96) pos++;
2706
2773
  const marker = state.src.slice(start, pos);
2707
2774
  const openerLength = marker.length;
2708
- if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
2709
- if (!silent) state.pending += marker;
2710
- state.pos += openerLength;
2711
- return true;
2712
- }
2713
- let matchEnd = pos;
2714
- let matchStart;
2715
- while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1) {
2716
- matchEnd = matchStart + 1;
2717
- while (matchEnd < max && state.src.charCodeAt(matchEnd) === 96) matchEnd++;
2718
- const closerLength = matchEnd - matchStart;
2719
- if (closerLength === openerLength) {
2720
- if (!silent) {
2721
- const token = state.push("code_inline", "code", 0);
2722
- token.markup = marker;
2723
- token.content = state.src.slice(pos, matchStart).replace(/\n/g, " ").replace(/^ (.+) $/, "$1");
2775
+ if (!state.backticksScanned) {
2776
+ state.backticks = buildLastRuns(state.src);
2777
+ state.backticksScanned = true;
2778
+ }
2779
+ if (((_state$backticks$open = state.backticks[openerLength]) !== null && _state$backticks$open !== void 0 ? _state$backticks$open : -1) >= pos) {
2780
+ let matchEnd = pos;
2781
+ let matchStart;
2782
+ while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1 && matchStart < max) {
2783
+ matchEnd = matchStart + 1;
2784
+ while (state.src.charCodeAt(matchEnd) === 96) matchEnd++;
2785
+ if (matchEnd > max) break;
2786
+ if (matchEnd - matchStart === openerLength) {
2787
+ if (!silent) {
2788
+ const token = state.push("code_inline", "code", 0);
2789
+ token.markup = marker;
2790
+ let content = state.src.slice(pos, matchStart).replace(/\n/g, " ");
2791
+ if (content.startsWith(" ") && content.endsWith(" ") && /[^ ]/.test(content)) content = content.slice(1, -1);
2792
+ token.content = content;
2793
+ }
2794
+ state.pos = matchEnd;
2795
+ return true;
2724
2796
  }
2725
- state.pos = matchEnd;
2726
- return true;
2727
2797
  }
2728
- state.backticks[closerLength] = matchStart;
2729
2798
  }
2730
- state.backticksScanned = true;
2731
2799
  if (!silent) state.pending += marker;
2732
- state.pos += openerLength;
2800
+ state.pos = pos;
2733
2801
  return true;
2734
2802
  }
2735
2803
  //#endregion
2736
- //#region lib/rules_inline/strikethrough.mjs
2804
+ //#region src/rules_inline/strikethrough.ts
2737
2805
  function strikethrough_tokenize(state, silent) {
2738
2806
  const start = state.pos;
2739
2807
  const marker = state.src.charCodeAt(start);
@@ -2803,14 +2871,18 @@ function strikethrough_postProcess(state) {
2803
2871
  const tokens_meta = state.tokens_meta;
2804
2872
  const max = state.tokens_meta.length;
2805
2873
  postProcess$1(state, state.delimiters);
2806
- for (let curr = 0; curr < max; curr++) if (tokens_meta[curr] && tokens_meta[curr].delimiters) postProcess$1(state, tokens_meta[curr].delimiters);
2874
+ for (let curr = 0; curr < max; curr++) {
2875
+ var _tokens_meta$curr;
2876
+ const delimiters = (_tokens_meta$curr = tokens_meta[curr]) === null || _tokens_meta$curr === void 0 ? void 0 : _tokens_meta$curr.delimiters;
2877
+ if (delimiters) postProcess$1(state, delimiters);
2878
+ }
2807
2879
  }
2808
2880
  var strikethrough_default = {
2809
2881
  tokenize: strikethrough_tokenize,
2810
2882
  postProcess: strikethrough_postProcess
2811
2883
  };
2812
2884
  //#endregion
2813
- //#region lib/rules_inline/emphasis.mjs
2885
+ //#region src/rules_inline/emphasis.ts
2814
2886
  function emphasis_tokenize(state, silent) {
2815
2887
  const start = state.pos;
2816
2888
  const marker = state.src.charCodeAt(start);
@@ -2864,14 +2936,18 @@ function emphasis_post_process(state) {
2864
2936
  const tokens_meta = state.tokens_meta;
2865
2937
  const max = state.tokens_meta.length;
2866
2938
  postProcess(state, state.delimiters);
2867
- for (let curr = 0; curr < max; curr++) if (tokens_meta[curr] && tokens_meta[curr].delimiters) postProcess(state, tokens_meta[curr].delimiters);
2939
+ for (let curr = 0; curr < max; curr++) {
2940
+ var _tokens_meta$curr;
2941
+ const delimiters = (_tokens_meta$curr = tokens_meta[curr]) === null || _tokens_meta$curr === void 0 ? void 0 : _tokens_meta$curr.delimiters;
2942
+ if (delimiters) postProcess(state, delimiters);
2943
+ }
2868
2944
  }
2869
2945
  var emphasis_default = {
2870
2946
  tokenize: emphasis_tokenize,
2871
2947
  postProcess: emphasis_post_process
2872
2948
  };
2873
2949
  //#endregion
2874
- //#region lib/rules_inline/link.mjs
2950
+ //#region src/rules_inline/link.ts
2875
2951
  function link(state, silent) {
2876
2952
  let code, label, res, ref;
2877
2953
  let href = "";
@@ -2926,7 +3002,8 @@ function link(state, silent) {
2926
3002
  else pos = labelEnd + 1;
2927
3003
  } else pos = labelEnd + 1;
2928
3004
  if (!label) label = state.src.slice(labelStart, labelEnd);
2929
- ref = state.env.references[normalizeReference(label)];
3005
+ label = normalizeReference(label);
3006
+ ref = state.env.references[label];
2930
3007
  if (!ref) {
2931
3008
  state.pos = oldPos;
2932
3009
  return false;
@@ -2941,6 +3018,11 @@ function link(state, silent) {
2941
3018
  const attrs = [["href", href]];
2942
3019
  token_o.attrs = attrs;
2943
3020
  if (title) attrs.push(["title", title]);
3021
+ if (label) {
3022
+ const meta = Object.create(null);
3023
+ meta.label = label;
3024
+ token_o.meta = meta;
3025
+ }
2944
3026
  state.linkLevel++;
2945
3027
  state.md.inline.tokenize(state);
2946
3028
  state.linkLevel--;
@@ -2951,7 +3033,7 @@ function link(state, silent) {
2951
3033
  return true;
2952
3034
  }
2953
3035
  //#endregion
2954
- //#region lib/rules_inline/image.mjs
3036
+ //#region src/rules_inline/image.ts
2955
3037
  function image(state, silent) {
2956
3038
  let code, content, label, pos, ref, res, title, start;
2957
3039
  let href = "";
@@ -3005,7 +3087,8 @@ function image(state, silent) {
3005
3087
  else pos = labelEnd + 1;
3006
3088
  } else pos = labelEnd + 1;
3007
3089
  if (!label) label = state.src.slice(labelStart, labelEnd);
3008
- ref = state.env.references[normalizeReference(label)];
3090
+ label = normalizeReference(label);
3091
+ ref = state.env.references[label];
3009
3092
  if (!ref) {
3010
3093
  state.pos = oldPos;
3011
3094
  return false;
@@ -3023,13 +3106,18 @@ function image(state, silent) {
3023
3106
  token.children = tokens;
3024
3107
  token.content = content;
3025
3108
  if (title) attrs.push(["title", title]);
3109
+ if (label) {
3110
+ const meta = Object.create(null);
3111
+ meta.label = label;
3112
+ token.meta = meta;
3113
+ }
3026
3114
  }
3027
3115
  state.pos = pos;
3028
3116
  state.posMax = max;
3029
3117
  return true;
3030
3118
  }
3031
3119
  //#endregion
3032
- //#region lib/rules_inline/autolink.mjs
3120
+ //#region src/rules_inline/autolink.ts
3033
3121
  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])?)*)$/;
3034
3122
  var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;
3035
3123
  function autolink(state, silent) {
@@ -3062,7 +3150,7 @@ function autolink(state, silent) {
3062
3150
  return true;
3063
3151
  }
3064
3152
  if (EMAIL_RE.test(url)) {
3065
- const fullUrl = state.md.normalizeLink("mailto:" + url);
3153
+ const fullUrl = state.md.normalizeLink(`mailto:${url}`);
3066
3154
  if (!state.md.validateLink(fullUrl)) return false;
3067
3155
  if (!silent) {
3068
3156
  const token_o = state.push("link_open", "a", 1);
@@ -3081,7 +3169,7 @@ function autolink(state, silent) {
3081
3169
  return false;
3082
3170
  }
3083
3171
  //#endregion
3084
- //#region lib/rules_inline/html_inline.mjs
3172
+ //#region src/rules_inline/html_inline.ts
3085
3173
  function isLinkOpen(str) {
3086
3174
  return /^<a[>\s]/i.test(str);
3087
3175
  }
@@ -3111,7 +3199,7 @@ function html_inline(state, silent) {
3111
3199
  return true;
3112
3200
  }
3113
3201
  //#endregion
3114
- //#region lib/rules_inline/entity.mjs
3202
+ //#region src/rules_inline/entity.ts
3115
3203
  var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
3116
3204
  var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
3117
3205
  function entity(state, silent) {
@@ -3135,7 +3223,7 @@ function entity(state, silent) {
3135
3223
  } else {
3136
3224
  const match = state.src.slice(pos).match(NAMED_RE);
3137
3225
  if (match) {
3138
- const decoded = (0, entities.decodeHTMLStrict)(match[0]);
3226
+ const decoded = decodeHTMLStrict(match[0]);
3139
3227
  if (decoded !== match[0]) {
3140
3228
  if (!silent) {
3141
3229
  const token = state.push("text_special", "", 0);
@@ -3151,7 +3239,7 @@ function entity(state, silent) {
3151
3239
  return false;
3152
3240
  }
3153
3241
  //#endregion
3154
- //#region lib/rules_inline/balance_pairs.mjs
3242
+ //#region src/rules_inline/balance_pairs.ts
3155
3243
  function processDelimiters(delimiters) {
3156
3244
  const openersBottom = {};
3157
3245
  const max = delimiters.length;
@@ -3207,10 +3295,14 @@ function link_pairs(state) {
3207
3295
  const tokens_meta = state.tokens_meta;
3208
3296
  const max = state.tokens_meta.length;
3209
3297
  processDelimiters(state.delimiters);
3210
- for (let curr = 0; curr < max; curr++) if (tokens_meta[curr] && tokens_meta[curr].delimiters) processDelimiters(tokens_meta[curr].delimiters);
3298
+ for (let curr = 0; curr < max; curr++) {
3299
+ var _tokens_meta$curr;
3300
+ const delimiters = (_tokens_meta$curr = tokens_meta[curr]) === null || _tokens_meta$curr === void 0 ? void 0 : _tokens_meta$curr.delimiters;
3301
+ if (delimiters) processDelimiters(delimiters);
3302
+ }
3211
3303
  }
3212
3304
  //#endregion
3213
- //#region lib/rules_inline/fragments_join.mjs
3305
+ //#region src/rules_inline/fragments_join.ts
3214
3306
  function fragments_join(state) {
3215
3307
  let curr, last;
3216
3308
  let level = 0;
@@ -3229,12 +3321,7 @@ function fragments_join(state) {
3229
3321
  if (curr !== last) tokens.length = last;
3230
3322
  }
3231
3323
  //#endregion
3232
- //#region lib/parser_inline.mjs
3233
- /** internal
3234
- * class ParserInline
3235
- *
3236
- * Tokenizes paragraph content.
3237
- **/
3324
+ //#region src/parser_inline.ts
3238
3325
  var _rules = [
3239
3326
  ["text", text],
3240
3327
  ["linkify", linkify],
@@ -3256,87 +3343,91 @@ var _rules2 = [
3256
3343
  ["fragments_join", fragments_join]
3257
3344
  ];
3258
3345
  /**
3259
- * new ParserInline()
3260
- **/
3261
- function ParserInline() {
3262
- /**
3263
- * ParserInline#ruler -> Ruler
3264
- *
3265
- * [[Ruler]] instance. Keep configuration of inline rules.
3266
- **/
3267
- this.ruler = new Ruler();
3268
- for (let i = 0; i < _rules.length; i++) this.ruler.push(_rules[i][0], _rules[i][1]);
3269
- /**
3270
- * ParserInline#ruler2 -> Ruler
3271
- *
3272
- * [[Ruler]] instance. Second ruler used for post-processing
3273
- * (e.g. in emphasis-like rules).
3274
- **/
3275
- this.ruler2 = new Ruler();
3276
- for (let i = 0; i < _rules2.length; i++) this.ruler2.push(_rules2[i][0], _rules2[i][1]);
3277
- }
3278
- ParserInline.prototype.skipToken = function(state) {
3279
- const pos = state.pos;
3280
- const rules = this.ruler.getRules("");
3281
- const len = rules.length;
3282
- const maxNesting = state.md.options.maxNesting;
3283
- const cache = state.cache;
3284
- if (typeof cache[pos] !== "undefined") {
3285
- state.pos = cache[pos];
3286
- return;
3287
- }
3288
- let ok = false;
3289
- if (state.level < maxNesting) for (let i = 0; i < len; i++) {
3290
- state.level++;
3291
- ok = rules[i](state, true);
3292
- state.level--;
3293
- if (ok) {
3294
- if (pos >= state.pos) throw new Error("inline rule didn't increment state.pos");
3295
- break;
3346
+ * Tokenizes paragraph content.
3347
+ */
3348
+ var ParserInline = class {
3349
+ constructor() {
3350
+ _defineProperty(
3351
+ this,
3352
+ /**
3353
+ * {@link Ruler} instance. Keep configuration of inline rules.
3354
+ */
3355
+ "ruler",
3356
+ new Ruler()
3357
+ );
3358
+ _defineProperty(
3359
+ this,
3360
+ /**
3361
+ * {@link Ruler} instance. Second ruler used for post-processing
3362
+ * (e.g. in emphasis-like rules).
3363
+ */
3364
+ "ruler2",
3365
+ new Ruler()
3366
+ );
3367
+ _defineProperty(this, "State", StateInline);
3368
+ for (let i = 0; i < _rules.length; i++) this.ruler.push(_rules[i][0], _rules[i][1]);
3369
+ for (let i = 0; i < _rules2.length; i++) this.ruler2.push(_rules2[i][0], _rules2[i][1]);
3370
+ }
3371
+ skipToken(state) {
3372
+ const pos = state.pos;
3373
+ const rules = this.ruler.getRules("");
3374
+ const len = rules.length;
3375
+ const maxNesting = state.md.options.maxNesting;
3376
+ const cache = state.cache;
3377
+ if (typeof cache[pos] !== "undefined") {
3378
+ state.pos = cache[pos];
3379
+ return;
3296
3380
  }
3297
- }
3298
- else state.pos = state.posMax;
3299
- if (!ok) state.pos++;
3300
- cache[pos] = state.pos;
3301
- };
3302
- ParserInline.prototype.tokenize = function(state) {
3303
- const rules = this.ruler.getRules("");
3304
- const len = rules.length;
3305
- const end = state.posMax;
3306
- const maxNesting = state.md.options.maxNesting;
3307
- while (state.pos < end) {
3308
- const prevPos = state.pos;
3309
3381
  let ok = false;
3310
3382
  if (state.level < maxNesting) for (let i = 0; i < len; i++) {
3311
- ok = rules[i](state, false);
3383
+ state.level++;
3384
+ ok = rules[i](state, true);
3385
+ state.level--;
3312
3386
  if (ok) {
3313
- if (prevPos >= state.pos) throw new Error("inline rule didn't increment state.pos");
3387
+ if (pos >= state.pos) throw new Error("inline rule didn't increment state.pos");
3314
3388
  break;
3315
3389
  }
3316
3390
  }
3317
- if (ok) {
3318
- if (state.pos >= end) break;
3319
- continue;
3391
+ else state.pos = state.posMax;
3392
+ if (!ok) state.pos++;
3393
+ cache[pos] = state.pos;
3394
+ }
3395
+ tokenize(state) {
3396
+ const rules = this.ruler.getRules("");
3397
+ const len = rules.length;
3398
+ const end = state.posMax;
3399
+ const maxNesting = state.md.options.maxNesting;
3400
+ while (state.pos < end) {
3401
+ const prevPos = state.pos;
3402
+ let ok = false;
3403
+ if (state.level < maxNesting) for (let i = 0; i < len; i++) {
3404
+ ok = rules[i](state, false);
3405
+ if (ok) {
3406
+ if (prevPos >= state.pos) throw new Error("inline rule didn't increment state.pos");
3407
+ break;
3408
+ }
3409
+ }
3410
+ if (ok) {
3411
+ if (state.pos >= end) break;
3412
+ continue;
3413
+ }
3414
+ state.pending += state.src[state.pos++];
3320
3415
  }
3321
- state.pending += state.src[state.pos++];
3416
+ if (state.pending) state.pushPending();
3417
+ }
3418
+ /**
3419
+ * Process input string and push inline tokens into `outTokens`
3420
+ */
3421
+ parse(str, md, env, outTokens) {
3422
+ const state = new this.State(str, md, env, outTokens);
3423
+ this.tokenize(state);
3424
+ const rules = this.ruler2.getRules("");
3425
+ const len = rules.length;
3426
+ for (let i = 0; i < len; i++) rules[i](state);
3322
3427
  }
3323
- if (state.pending) state.pushPending();
3324
- };
3325
- /**
3326
- * ParserInline.parse(str, md, env, outTokens)
3327
- *
3328
- * Process input string and push inline tokens into `outTokens`
3329
- **/
3330
- ParserInline.prototype.parse = function(str, md, env, outTokens) {
3331
- const state = new this.State(str, md, env, outTokens);
3332
- this.tokenize(state);
3333
- const rules = this.ruler2.getRules("");
3334
- const len = rules.length;
3335
- for (let i = 0; i < len; i++) rules[i](state);
3336
3428
  };
3337
- ParserInline.prototype.State = StateInline;
3338
3429
  //#endregion
3339
- //#region lib/index.mjs
3430
+ //#region src/markdownit.ts
3340
3431
  var config = {
3341
3432
  default: {
3342
3433
  options: {
@@ -3372,6 +3463,7 @@ var config = {
3372
3463
  core: { rules: [
3373
3464
  "normalize",
3374
3465
  "block",
3466
+ "strip_references",
3375
3467
  "inline",
3376
3468
  "text_join"
3377
3469
  ] },
@@ -3398,6 +3490,7 @@ var config = {
3398
3490
  core: { rules: [
3399
3491
  "normalize",
3400
3492
  "block",
3493
+ "strip_references",
3401
3494
  "inline",
3402
3495
  "text_join"
3403
3496
  ] },
@@ -3437,465 +3530,351 @@ var config = {
3437
3530
  };
3438
3531
  var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
3439
3532
  var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
3440
- function validateLink(url) {
3441
- const str = url.trim().toLowerCase();
3442
- return BAD_PROTO_RE.test(str) ? GOOD_DATA_RE.test(str) : true;
3443
- }
3444
3533
  var RECODE_HOSTNAME_FOR = [
3445
3534
  "http:",
3446
3535
  "https:",
3447
3536
  "mailto:"
3448
3537
  ];
3449
- function normalizeLink(url) {
3450
- const parsed = mdurl.parse(url, true);
3451
- if (parsed.hostname) {
3452
- if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) try {
3453
- parsed.hostname = punycode_js.default.toASCII(parsed.hostname);
3454
- } catch (er) {}
3455
- }
3456
- return mdurl.encode(mdurl.format(parsed));
3457
- }
3458
- function normalizeLinkText(url) {
3459
- const parsed = mdurl.parse(url, true);
3460
- if (parsed.hostname) {
3461
- if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) try {
3462
- parsed.hostname = punycode_js.default.toUnicode(parsed.hostname);
3463
- } catch (er) {}
3464
- }
3465
- return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + "%");
3466
- }
3467
- /**
3468
- * class MarkdownIt
3469
- *
3470
- * Main parser/renderer class.
3471
- *
3472
- * ##### Usage
3473
- *
3474
- * ```javascript
3475
- * // node.js, "classic" way:
3476
- * var MarkdownIt = require('markdown-it'),
3477
- * md = new MarkdownIt();
3478
- * var result = md.render('# markdown-it rulezz!');
3479
- *
3480
- * // node.js, the same, but with sugar:
3481
- * var md = require('markdown-it')();
3482
- * var result = md.render('# markdown-it rulezz!');
3483
- *
3484
- * // browser without AMD, added to "window" on script load
3485
- * // Note, there are no dash.
3486
- * var md = window.markdownit();
3487
- * var result = md.render('# markdown-it rulezz!');
3488
- * ```
3489
- *
3490
- * Single line rendering, without paragraph wrap:
3491
- *
3492
- * ```javascript
3493
- * var md = require('markdown-it')();
3494
- * var result = md.renderInline('__markdown-it__ rulezz!');
3495
- * ```
3496
- **/
3497
3538
  /**
3498
- * new MarkdownIt([presetName, options])
3499
- * - presetName (String): optional, `commonmark` / `zero`
3500
- * - options (Object)
3501
- *
3502
- * Creates parser instanse with given config. Can be called without `new`.
3503
- *
3504
- * ##### presetName
3505
- *
3506
- * MarkdownIt provides named presets as a convenience to quickly
3507
- * enable/disable active syntax rules and options for common use cases.
3508
- *
3509
- * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.mjs) -
3510
- * configures parser to strict [CommonMark](http://commonmark.org/) mode.
3511
- * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.mjs) -
3512
- * similar to GFM, used when no preset name given. Enables all available rules,
3513
- * but still without html, typographer & autolinker.
3514
- * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.mjs) -
3515
- * all rules disabled. Useful to quickly setup your config via `.enable()`.
3516
- * For example, when you need only `bold` and `italic` markup and nothing else.
3517
- *
3518
- * ##### options:
3519
- *
3520
- * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
3521
- * That's not safe! You may need external sanitizer to protect output from XSS.
3522
- * It's better to extend features via plugins, instead of enabling HTML.
3523
- * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
3524
- * (`<br />`). This is needed only for full CommonMark compatibility. In real
3525
- * world you will need HTML output.
3526
- * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
3527
- * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
3528
- * Can be useful for external highlighters.
3529
- * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
3530
- * - __typographer__ - `false`. Set `true` to enable [some language-neutral
3531
- * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.mjs) +
3532
- * quotes beautification (smartquotes).
3533
- * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
3534
- * pairs, when typographer enabled and smartquotes on. For example, you can
3535
- * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
3536
- * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
3537
- * - __highlight__ - `null`. Highlighter function for fenced code blocks.
3538
- * Highlighter `function (str, lang)` should return escaped HTML. It can also
3539
- * return empty string if the source was not changed and should be escaped
3540
- * externaly. If result starts with <pre... internal wrapper is skipped.
3541
- *
3542
- * ##### Example
3543
- *
3544
- * ```javascript
3545
- * // commonmark mode
3546
- * var md = require('markdown-it')('commonmark');
3547
- *
3548
- * // default mode
3549
- * var md = require('markdown-it')();
3550
- *
3551
- * // enable everything
3552
- * var md = require('markdown-it')({
3553
- * html: true,
3554
- * linkify: true,
3555
- * typographer: true
3556
- * });
3557
- * ```
3558
- *
3559
- * ##### Syntax highlighting
3560
- *
3561
- * ```js
3562
- * var hljs = require('highlight.js') // https://highlightjs.org/
3539
+ * Parses Markdown into tokens and renders them to HTML.
3563
3540
  *
3564
- * var md = require('markdown-it')({
3565
- * highlight: function (str, lang) {
3566
- * if (lang && hljs.getLanguage(lang)) {
3567
- * try {
3568
- * return hljs.highlight(str, { language: lang, ignoreIllegals: true }).value;
3569
- * } catch (__) {}
3570
- * }
3571
- *
3572
- * return ''; // use external default escaping
3573
- * }
3574
- * });
3575
- * ```
3576
- *
3577
- * Or with full wrapper override (if you need assign class to `<pre>` or `<code>`):
3578
- *
3579
- * ```javascript
3580
- * var hljs = require('highlight.js') // https://highlightjs.org/
3581
- *
3582
- * // Actual default values
3583
- * var md = require('markdown-it')({
3584
- * highlight: function (str, lang) {
3585
- * if (lang && hljs.getLanguage(lang)) {
3586
- * try {
3587
- * return '<pre><code class="hljs">' +
3588
- * hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
3589
- * '</code></pre>';
3590
- * } catch (__) {}
3591
- * }
3592
- *
3593
- * return '<pre><code class="hljs">' + md.utils.escapeHtml(str) + '</code></pre>';
3594
- * }
3595
- * });
3596
- * ```
3597
- *
3598
- **/
3599
- function MarkdownIt(presetName, options) {
3600
- if (!(this instanceof MarkdownIt)) return new MarkdownIt(presetName, options);
3601
- if (!options) {
3602
- if (!isString(presetName)) {
3603
- options = presetName || {};
3604
- presetName = "default";
3605
- }
3606
- }
3541
+ * @category Main
3542
+ */
3543
+ var MarkdownIt = class {
3607
3544
  /**
3608
- * MarkdownIt#inline -> ParserInline
3545
+ * Link validation function. CommonMark allows too much in links. By default
3546
+ * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
3547
+ * except some embedded image types.
3609
3548
  *
3610
- * Instance of [[ParserInline]]. You may need it to add new rules when
3611
- * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
3612
- * [[MarkdownIt.enable]].
3613
- **/
3614
- this.inline = new ParserInline();
3615
- /**
3616
- * MarkdownIt#block -> ParserBlock
3549
+ * You can change this behaviour:
3617
3550
  *
3618
- * Instance of [[ParserBlock]]. You may need it to add new rules when
3619
- * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
3620
- * [[MarkdownIt.enable]].
3621
- **/
3622
- this.block = new ParserBlock();
3623
- /**
3624
- * MarkdownIt#core -> Core
3551
+ * @example
3552
+ * ```javascript
3553
+ * import MarkdownIt from 'markdown-it'
3554
+ * const md = new MarkdownIt()
3625
3555
  *
3626
- * Instance of [[Core]] chain executor. You may need it to add new rules when
3627
- * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
3628
- * [[MarkdownIt.enable]].
3629
- **/
3630
- this.core = new Core();
3556
+ * // enable everything
3557
+ * md.validateLink = function () { return true; }
3558
+ * ```
3559
+ */
3560
+ validateLink(url) {
3561
+ const str = url.trim().toLowerCase();
3562
+ return BAD_PROTO_RE.test(str) ? GOOD_DATA_RE.test(str) : true;
3563
+ }
3631
3564
  /**
3632
- * MarkdownIt#renderer -> Renderer
3633
- *
3634
- * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
3635
- * rules for new token types, generated by plugins.
3565
+ * Function used to encode link url to a machine-readable format,
3566
+ * which includes url-encoding, punycode, etc.
3567
+ */
3568
+ normalizeLink(url) {
3569
+ const parsed = mdurl.parse(url, true);
3570
+ if (parsed.hostname) {
3571
+ if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) try {
3572
+ parsed.hostname = punycode.toASCII(parsed.hostname);
3573
+ } catch (er) {}
3574
+ }
3575
+ if (parsed.auth) parsed.auth = mdurl.encode(parsed.auth);
3576
+ if (parsed.hostname) parsed.hostname = mdurl.encode(parsed.hostname);
3577
+ if (parsed.pathname) parsed.pathname = mdurl.encode(parsed.pathname);
3578
+ if (parsed.search) parsed.search = mdurl.encode(parsed.search);
3579
+ if (parsed.hash) parsed.hash = mdurl.encode(parsed.hash);
3580
+ return mdurl.format(parsed);
3581
+ }
3582
+ /**
3583
+ * Function used to decode link url to a human-readable format`
3584
+ */
3585
+ normalizeLinkText(url) {
3586
+ const parsed = mdurl.parse(url, true);
3587
+ if (parsed.hostname) {
3588
+ if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) try {
3589
+ parsed.hostname = punycode.toUnicode(parsed.hostname);
3590
+ } catch (er) {}
3591
+ }
3592
+ return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + "%");
3593
+ }
3594
+ constructor(...args) {
3595
+ _defineProperty(
3596
+ this,
3597
+ /**
3598
+ * Instance of {@link ParserInline}. You may need it to add new rules when
3599
+ * writing plugins. For simple rules control use {@link MarkdownIt.disable}
3600
+ * and {@link MarkdownIt.enable}.
3601
+ */
3602
+ "inline",
3603
+ new ParserInline()
3604
+ );
3605
+ _defineProperty(
3606
+ this,
3607
+ /**
3608
+ * Instance of {@link ParserBlock}. You may need it to add new rules when
3609
+ * writing plugins. For simple rules control use {@link MarkdownIt.disable}
3610
+ * and {@link MarkdownIt.enable}.
3611
+ */
3612
+ "block",
3613
+ new ParserBlock()
3614
+ );
3615
+ _defineProperty(
3616
+ this,
3617
+ /**
3618
+ * Instance of {@link ParserCore} chain executor. You may need it to add new
3619
+ * rules when writing plugins. For simple rules control use
3620
+ * {@link MarkdownIt.disable} and {@link MarkdownIt.enable}.
3621
+ */
3622
+ "core",
3623
+ new ParserCore()
3624
+ );
3625
+ _defineProperty(
3626
+ this,
3627
+ /**
3628
+ * Instance of {@link Renderer}. Use it to modify output look. Or to add rendering
3629
+ * rules for new token types, generated by plugins.
3630
+ *
3631
+ * See {@link Renderer} docs and
3632
+ * [source code](https://github.com/markdown-it/markdown-it/blob/master/src/renderer.ts).
3633
+ *
3634
+ * @example
3635
+ * ```javascript
3636
+ * import MarkdownIt from 'markdown-it'
3637
+ * const md = new MarkdownIt()
3638
+ *
3639
+ * function myToken(tokens, idx, options, env, self) {
3640
+ * //...
3641
+ * return result;
3642
+ * };
3643
+ *
3644
+ * md.renderer.rules['my_token'] = myToken
3645
+ * ```
3646
+ */
3647
+ "renderer",
3648
+ new Renderer()
3649
+ );
3650
+ _defineProperty(
3651
+ this,
3652
+ /**
3653
+ * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
3654
+ * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/src/rules_core/linkify.ts)
3655
+ * rule.
3656
+ */
3657
+ "linkify",
3658
+ new LinkifyIt()
3659
+ );
3660
+ _defineProperty(
3661
+ this,
3662
+ /**
3663
+ * Assorted utility functions, useful to write plugins. See details
3664
+ * [here](https://github.com/markdown-it/markdown-it/blob/master/src/common/utils.ts).
3665
+ */
3666
+ "utils",
3667
+ utils_exports
3668
+ );
3669
+ _defineProperty(
3670
+ this,
3671
+ /**
3672
+ * Link components parser functions, useful to write plugins. See details
3673
+ * [here](https://github.com/markdown-it/markdown-it/blob/master/src/helpers).
3674
+ */
3675
+ "helpers",
3676
+ Object.assign({}, helpers_exports)
3677
+ );
3678
+ const [presetNameOrOptions, options] = args;
3679
+ if (typeof presetNameOrOptions === "string") {
3680
+ this.configure(presetNameOrOptions);
3681
+ if (options) this.set(options);
3682
+ } else {
3683
+ this.configure("default");
3684
+ this.set(presetNameOrOptions || {});
3685
+ }
3686
+ }
3687
+ /**
3688
+ * Set parser options (in the same format as in constructor). Probably, you
3689
+ * will never need it, but you can change options after constructor call.
3636
3690
  *
3637
- * ##### Example
3691
+ * __Note:__ To achieve the best possible performance, don't modify a
3692
+ * `markdown-it` instance options on the fly. If you need multiple configurations
3693
+ * it's best to create multiple instances and initialize each with separate
3694
+ * config.
3638
3695
  *
3696
+ * @example
3639
3697
  * ```javascript
3640
- * var md = require('markdown-it')();
3641
- *
3642
- * function myToken(tokens, idx, options, env, self) {
3643
- * //...
3644
- * return result;
3645
- * };
3698
+ * import MarkdownIt from 'markdown-it'
3646
3699
  *
3647
- * md.renderer.rules['my_token'] = myToken
3700
+ * const md = new MarkdownIt()
3701
+ * .set({ html: true, breaks: true })
3702
+ * .set({ typographer: true })
3648
3703
  * ```
3649
- *
3650
- * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.mjs).
3651
- **/
3652
- this.renderer = new Renderer();
3704
+ */
3705
+ set(options) {
3706
+ Object.assign(this.options, options);
3707
+ return this;
3708
+ }
3653
3709
  /**
3654
- * MarkdownIt#linkify -> LinkifyIt
3710
+ * Batch load of all options and compenent settings. This is internal method,
3711
+ * and you probably will not need it. But if you will - see available presets
3712
+ * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/src/presets)
3655
3713
  *
3656
- * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
3657
- * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.mjs)
3658
- * rule.
3659
- **/
3660
- this.linkify = new linkify_it.default();
3714
+ * We strongly recommend to use presets instead of direct config loads. That
3715
+ * will give better compatibility with next versions.
3716
+ */
3717
+ configure(presets) {
3718
+ let p;
3719
+ if (typeof presets === "string") {
3720
+ const presetName = presets;
3721
+ p = config[presetName];
3722
+ if (!p) throw new Error(`Wrong 'markdown-it' preset "${presetName}", check name`);
3723
+ } else p = presets;
3724
+ if (!p) throw new Error("Wrong `markdown-it` preset, can't be empty");
3725
+ if (p.options) this.options = { ...p.options };
3726
+ const components = p.components;
3727
+ if (components) {
3728
+ var _components$inline;
3729
+ [
3730
+ "core",
3731
+ "block",
3732
+ "inline"
3733
+ ].forEach((name) => {
3734
+ var _components$name;
3735
+ const rules = (_components$name = components[name]) === null || _components$name === void 0 ? void 0 : _components$name.rules;
3736
+ if (rules) this[name].ruler.enableOnly(rules);
3737
+ });
3738
+ const rules2 = (_components$inline = components.inline) === null || _components$inline === void 0 ? void 0 : _components$inline.rules2;
3739
+ if (rules2) this.inline.ruler2.enableOnly(rules2);
3740
+ }
3741
+ return this;
3742
+ }
3661
3743
  /**
3662
- * MarkdownIt#validateLink(url) -> Boolean
3744
+ * Enable list or rules. It will automatically find appropriate components,
3745
+ * containing rules with given names. If rule not found, and `ignoreInvalid`
3746
+ * not set - throws exception.
3663
3747
  *
3664
- * Link validation function. CommonMark allows too much in links. By default
3665
- * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
3666
- * except some embedded image types.
3748
+ * @example
3749
+ * ```javascript
3750
+ * import MarkdownIt from 'markdown-it'
3667
3751
  *
3668
- * You can change this behaviour:
3752
+ * const md = new MarkdownIt()
3753
+ * .enable(['sub', 'sup'])
3754
+ * .disable('smartquotes')
3755
+ * ```
3756
+ */
3757
+ enable(list, ignoreInvalid = false) {
3758
+ let result = [];
3759
+ if (!Array.isArray(list)) list = [list];
3760
+ [
3761
+ "core",
3762
+ "block",
3763
+ "inline"
3764
+ ].forEach((chain) => {
3765
+ result = result.concat(this[chain].ruler.enable(list, true));
3766
+ });
3767
+ result = result.concat(this.inline.ruler2.enable(list, true));
3768
+ const missed = list.filter((name) => result.indexOf(name) < 0);
3769
+ if (missed.length && !ignoreInvalid) throw new Error(`MarkdownIt. Failed to enable unknown rule(s): ${missed}`);
3770
+ return this;
3771
+ }
3772
+ /**
3773
+ * The same as {@link MarkdownIt.enable}, but turn specified rules off.
3774
+ */
3775
+ disable(list, ignoreInvalid = false) {
3776
+ let result = [];
3777
+ if (!Array.isArray(list)) list = [list];
3778
+ [
3779
+ "core",
3780
+ "block",
3781
+ "inline"
3782
+ ].forEach((chain) => {
3783
+ result = result.concat(this[chain].ruler.disable(list, true));
3784
+ });
3785
+ result = result.concat(this.inline.ruler2.disable(list, true));
3786
+ const missed = list.filter((name) => result.indexOf(name) < 0);
3787
+ if (missed.length && !ignoreInvalid) throw new Error(`MarkdownIt. Failed to disable unknown rule(s): ${missed}`);
3788
+ return this;
3789
+ }
3790
+ /**
3791
+ * Load specified plugin with given params into current parser instance.
3792
+ * It's just a sugar to call `plugin(md, params)` with curring.
3669
3793
  *
3794
+ * @example
3670
3795
  * ```javascript
3671
- * var md = require('markdown-it')();
3672
- * // enable everything
3673
- * md.validateLink = function () { return true; }
3796
+ * import MarkdownIt from 'markdown-it'
3797
+ * import iterator from 'markdown-it-for-inline'
3798
+ *
3799
+ * const md = new MarkdownIt()
3800
+ * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
3801
+ * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar')
3802
+ * })
3674
3803
  * ```
3675
- **/
3676
- this.validateLink = validateLink;
3804
+ */
3805
+ use(plugin, ...params) {
3806
+ plugin.apply(plugin, [this, ...params]);
3807
+ return this;
3808
+ }
3677
3809
  /**
3678
- * MarkdownIt#normalizeLink(url) -> String
3810
+ * Parse input string and return list of block tokens (special token type
3811
+ * "inline" will contain list of inline tokens). You should not call this
3812
+ * method directly, until you write custom renderer (for example, to produce
3813
+ * AST).
3679
3814
  *
3680
- * Function used to encode link url to a machine-readable format,
3681
- * which includes url-encoding, punycode, etc.
3682
- **/
3683
- this.normalizeLink = normalizeLink;
3815
+ * `env` is used to pass data between "distributed" rules and return additional
3816
+ * metadata like reference info, needed for the renderer. It also can be used to
3817
+ * inject data in specific cases. Usually, you will be ok to pass `{}`,
3818
+ * and then pass updated object to renderer.
3819
+ */
3820
+ parse(src, env) {
3821
+ if (typeof src !== "string") throw new Error("Input data should be a String");
3822
+ const state = new this.core.State(src, this, env);
3823
+ this.core.process(state);
3824
+ return state.tokens;
3825
+ }
3684
3826
  /**
3685
- * MarkdownIt#normalizeLinkText(url) -> String
3827
+ * Render markdown string into html. It does all magic for you :).
3686
3828
  *
3687
- * Function used to decode link url to a human-readable format`
3688
- **/
3689
- this.normalizeLinkText = normalizeLinkText;
3829
+ * `env` can be used to inject additional metadata (`{}` by default).
3830
+ * But you will not need it with high probability. See also comment
3831
+ * in {@link MarkdownIt.parse}.
3832
+ */
3833
+ render(src, env = {}) {
3834
+ return this.renderer.render(this.parse(src, env), this.options, env);
3835
+ }
3690
3836
  /**
3691
- * MarkdownIt#utils -> utils
3692
- *
3693
- * Assorted utility functions, useful to write plugins. See details
3694
- * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.mjs).
3695
- **/
3696
- this.utils = utils_exports;
3837
+ * The same as {@link MarkdownIt.parse} but skip all block rules. It returns
3838
+ * the block tokens list with the single `inline` element, containing parsed
3839
+ * inline tokens in `children` property. Also updates `env` object.
3840
+ */
3841
+ parseInline(src, env) {
3842
+ const state = new this.core.State(src, this, env);
3843
+ state.inlineMode = true;
3844
+ this.core.process(state);
3845
+ return state.tokens;
3846
+ }
3697
3847
  /**
3698
- * MarkdownIt#helpers -> helpers
3699
- *
3700
- * Link components parser functions, useful to write plugins. See details
3701
- * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
3702
- **/
3703
- this.helpers = assign({}, helpers_exports);
3704
- this.options = {};
3705
- this.configure(presetName);
3706
- if (options) this.set(options);
3707
- }
3708
- /** chainable
3709
- * MarkdownIt.set(options)
3710
- *
3711
- * Set parser options (in the same format as in constructor). Probably, you
3712
- * will never need it, but you can change options after constructor call.
3713
- *
3714
- * ##### Example
3715
- *
3716
- * ```javascript
3717
- * var md = require('markdown-it')()
3718
- * .set({ html: true, breaks: true })
3719
- * .set({ typographer: true });
3720
- * ```
3721
- *
3722
- * __Note:__ To achieve the best possible performance, don't modify a
3723
- * `markdown-it` instance options on the fly. If you need multiple configurations
3724
- * it's best to create multiple instances and initialize each with separate
3725
- * config.
3726
- **/
3727
- MarkdownIt.prototype.set = function(options) {
3728
- assign(this.options, options);
3729
- return this;
3730
- };
3731
- /** chainable, internal
3732
- * MarkdownIt.configure(presets)
3733
- *
3734
- * Batch load of all options and compenent settings. This is internal method,
3735
- * and you probably will not need it. But if you will - see available presets
3736
- * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
3737
- *
3738
- * We strongly recommend to use presets instead of direct config loads. That
3739
- * will give better compatibility with next versions.
3740
- **/
3741
- MarkdownIt.prototype.configure = function(presets) {
3742
- const self = this;
3743
- if (isString(presets)) {
3744
- const presetName = presets;
3745
- presets = config[presetName];
3746
- if (!presets) throw new Error("Wrong `markdown-it` preset \"" + presetName + "\", check name");
3747
- }
3748
- if (!presets) throw new Error("Wrong `markdown-it` preset, can't be empty");
3749
- if (presets.options) self.set(presets.options);
3750
- if (presets.components) Object.keys(presets.components).forEach(function(name) {
3751
- if (presets.components[name].rules) self[name].ruler.enableOnly(presets.components[name].rules);
3752
- if (presets.components[name].rules2) self[name].ruler2.enableOnly(presets.components[name].rules2);
3753
- });
3754
- return this;
3755
- };
3756
- /** chainable
3757
- * MarkdownIt.enable(list, ignoreInvalid)
3758
- * - list (String|Array): rule name or list of rule names to enable
3759
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
3760
- *
3761
- * Enable list or rules. It will automatically find appropriate components,
3762
- * containing rules with given names. If rule not found, and `ignoreInvalid`
3763
- * not set - throws exception.
3764
- *
3765
- * ##### Example
3766
- *
3767
- * ```javascript
3768
- * var md = require('markdown-it')()
3769
- * .enable(['sub', 'sup'])
3770
- * .disable('smartquotes');
3771
- * ```
3772
- **/
3773
- MarkdownIt.prototype.enable = function(list, ignoreInvalid) {
3774
- let result = [];
3775
- if (!Array.isArray(list)) list = [list];
3776
- [
3777
- "core",
3778
- "block",
3779
- "inline"
3780
- ].forEach(function(chain) {
3781
- result = result.concat(this[chain].ruler.enable(list, true));
3782
- }, this);
3783
- result = result.concat(this.inline.ruler2.enable(list, true));
3784
- const missed = list.filter(function(name) {
3785
- return result.indexOf(name) < 0;
3786
- });
3787
- if (missed.length && !ignoreInvalid) throw new Error("MarkdownIt. Failed to enable unknown rule(s): " + missed);
3788
- return this;
3789
- };
3790
- /** chainable
3791
- * MarkdownIt.disable(list, ignoreInvalid)
3792
- * - list (String|Array): rule name or list of rule names to disable.
3793
- * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
3794
- *
3795
- * The same as [[MarkdownIt.enable]], but turn specified rules off.
3796
- **/
3797
- MarkdownIt.prototype.disable = function(list, ignoreInvalid) {
3798
- let result = [];
3799
- if (!Array.isArray(list)) list = [list];
3800
- [
3801
- "core",
3802
- "block",
3803
- "inline"
3804
- ].forEach(function(chain) {
3805
- result = result.concat(this[chain].ruler.disable(list, true));
3806
- }, this);
3807
- result = result.concat(this.inline.ruler2.disable(list, true));
3808
- const missed = list.filter(function(name) {
3809
- return result.indexOf(name) < 0;
3810
- });
3811
- if (missed.length && !ignoreInvalid) throw new Error("MarkdownIt. Failed to disable unknown rule(s): " + missed);
3812
- return this;
3813
- };
3814
- /** chainable
3815
- * MarkdownIt.use(plugin, params)
3816
- *
3817
- * Load specified plugin with given params into current parser instance.
3818
- * It's just a sugar to call `plugin(md, params)` with curring.
3819
- *
3820
- * ##### Example
3821
- *
3822
- * ```javascript
3823
- * var iterator = require('markdown-it-for-inline');
3824
- * var md = require('markdown-it')()
3825
- * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
3826
- * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
3827
- * });
3828
- * ```
3829
- **/
3830
- MarkdownIt.prototype.use = function(plugin) {
3831
- const args = [this].concat(Array.prototype.slice.call(arguments, 1));
3832
- plugin.apply(plugin, args);
3833
- return this;
3834
- };
3835
- /** internal
3836
- * MarkdownIt.parse(src, env) -> Array
3837
- * - src (String): source string
3838
- * - env (Object): environment sandbox
3839
- *
3840
- * Parse input string and return list of block tokens (special token type
3841
- * "inline" will contain list of inline tokens). You should not call this
3842
- * method directly, until you write custom renderer (for example, to produce
3843
- * AST).
3844
- *
3845
- * `env` is used to pass data between "distributed" rules and return additional
3846
- * metadata like reference info, needed for the renderer. It also can be used to
3847
- * inject data in specific cases. Usually, you will be ok to pass `{}`,
3848
- * and then pass updated object to renderer.
3849
- **/
3850
- MarkdownIt.prototype.parse = function(src, env) {
3851
- if (typeof src !== "string") throw new Error("Input data should be a String");
3852
- const state = new this.core.State(src, this, env);
3853
- this.core.process(state);
3854
- return state.tokens;
3848
+ * Similar to {@link MarkdownIt.render} but for single paragraph content.
3849
+ * Result will NOT be wrapped into `<p>` tags.
3850
+ */
3851
+ renderInline(src, env = {}) {
3852
+ return this.renderer.render(this.parseInline(src, env), this.options, env);
3853
+ }
3855
3854
  };
3855
+ _defineProperty(MarkdownIt, "Token", Token);
3856
+ _defineProperty(MarkdownIt, "Ruler", Ruler);
3857
+ _defineProperty(MarkdownIt, "Renderer", Renderer);
3858
+ _defineProperty(MarkdownIt, "ParserCore", ParserCore);
3859
+ _defineProperty(MarkdownIt, "StateCore", StateCore);
3860
+ _defineProperty(MarkdownIt, "ParserBlock", ParserBlock);
3861
+ _defineProperty(MarkdownIt, "StateBlock", StateBlock);
3862
+ _defineProperty(MarkdownIt, "ParserInline", ParserInline);
3863
+ _defineProperty(MarkdownIt, "StateInline", StateInline);
3864
+ //#endregion
3865
+ //#region src/index.ts
3856
3866
  /**
3857
- * MarkdownIt.render(src [, env]) -> String
3858
- * - src (String): source string
3859
- * - env (Object): environment sandbox
3860
- *
3861
- * Render markdown string into html. It does all magic for you :).
3862
- *
3863
- * `env` can be used to inject additional metadata (`{}` by default).
3864
- * But you will not need it with high probability. See also comment
3865
- * in [[MarkdownIt.parse]].
3866
- **/
3867
- MarkdownIt.prototype.render = function(src, env) {
3868
- env = env || {};
3869
- return this.renderer.render(this.parse(src, env), this.options, env);
3870
- };
3871
- /** internal
3872
- * MarkdownIt.parseInline(src, env) -> Array
3873
- * - src (String): source string
3874
- * - env (Object): environment sandbox
3867
+ * Default package export.
3875
3868
  *
3876
- * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
3877
- * block tokens list with the single `inline` element, containing parsed inline
3878
- * tokens in `children` property. Also updates `env` object.
3879
- **/
3880
- MarkdownIt.prototype.parseInline = function(src, env) {
3881
- const state = new this.core.State(src, this, env);
3882
- state.inlineMode = true;
3883
- this.core.process(state);
3884
- return state.tokens;
3885
- };
3886
- /**
3887
- * MarkdownIt.renderInline(src [, env]) -> String
3888
- * - src (String): source string
3889
- * - env (Object): environment sandbox
3869
+ * For backward compatibility, the {@link MarkdownIt} class is wrapped so
3870
+ * legacy code can call it without `new`. New code should instantiate it as a
3871
+ * regular class with `new`. The compatibility wrapper may be removed in a
3872
+ * future release.
3890
3873
  *
3891
- * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
3892
- * will NOT be wrapped into `<p>` tags.
3893
- **/
3894
- MarkdownIt.prototype.renderInline = function(src, env) {
3895
- env = env || {};
3896
- return this.renderer.render(this.parseInline(src, env), this.options, env);
3897
- };
3874
+ * @category Main
3875
+ */
3876
+ var MarkdownItCallable = callable(MarkdownIt);
3898
3877
  //#endregion
3899
- module.exports = MarkdownIt;
3878
+ export { MarkdownItCallable as default };
3900
3879
 
3901
- //# sourceMappingURL=index.cjs.js.map
3880
+ //# sourceMappingURL=markdown-it.mjs.map