@milkdown/crepe 7.3.6 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (827) hide show
  1. package/lib/cjs/_view-TbSIR42F.js +27 -0
  2. package/lib/cjs/_view-TbSIR42F.js.map +1 -0
  3. package/lib/cjs/apl-99bWvYTf.js +145 -0
  4. package/lib/cjs/apl-99bWvYTf.js.map +1 -0
  5. package/lib/cjs/asciiarmor-cf0JLIr_.js +59 -0
  6. package/lib/cjs/asciiarmor-cf0JLIr_.js.map +1 -0
  7. package/lib/cjs/asn1-H4XzAvBS.js +195 -0
  8. package/lib/cjs/asn1-H4XzAvBS.js.map +1 -0
  9. package/lib/cjs/asterisk-0FgJEfZB.js +190 -0
  10. package/lib/cjs/asterisk-0FgJEfZB.js.map +1 -0
  11. package/lib/cjs/brainfuck-JX7vRZy7.js +73 -0
  12. package/lib/cjs/brainfuck-JX7vRZy7.js.map +1 -0
  13. package/lib/cjs/clike-ueXlMQy5.js +1034 -0
  14. package/lib/cjs/clike-ueXlMQy5.js.map +1 -0
  15. package/lib/cjs/clojure-6iDAG5oi.js +277 -0
  16. package/lib/cjs/clojure-6iDAG5oi.js.map +1 -0
  17. package/lib/cjs/clsx-7JLENl8W.js +62 -0
  18. package/lib/cjs/clsx-7JLENl8W.js.map +1 -0
  19. package/lib/cjs/cmake-L0RIBnfc.js +84 -0
  20. package/lib/cjs/cmake-L0RIBnfc.js.map +1 -0
  21. package/lib/cjs/cobol-oxkMh1GJ.js +238 -0
  22. package/lib/cjs/cobol-oxkMh1GJ.js.map +1 -0
  23. package/lib/cjs/coffeescript--eauIeRQ.js +332 -0
  24. package/lib/cjs/coffeescript--eauIeRQ.js.map +1 -0
  25. package/lib/cjs/commonlisp-pgSu-q6f.js +111 -0
  26. package/lib/cjs/commonlisp-pgSu-q6f.js.map +1 -0
  27. package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js +1138 -0
  28. package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js.map +1 -0
  29. package/lib/cjs/crystal-2y3I5ibZ.js +422 -0
  30. package/lib/cjs/crystal-2y3I5ibZ.js.map +1 -0
  31. package/lib/cjs/css-WH69cXzo.js +855 -0
  32. package/lib/cjs/css-WH69cXzo.js.map +1 -0
  33. package/lib/cjs/cypher-da-dqVyQ.js +125 -0
  34. package/lib/cjs/cypher-da-dqVyQ.js.map +1 -0
  35. package/lib/cjs/d-58J7EOkP.js +208 -0
  36. package/lib/cjs/d-58J7EOkP.js.map +1 -0
  37. package/lib/cjs/diff-437Hfzqm.js +33 -0
  38. package/lib/cjs/diff-437Hfzqm.js.map +1 -0
  39. package/lib/cjs/dockerfile-7i0OoaQe.js +202 -0
  40. package/lib/cjs/dockerfile-7i0OoaQe.js.map +1 -0
  41. package/lib/cjs/dtd-AKekCPPB.js +124 -0
  42. package/lib/cjs/dtd-AKekCPPB.js.map +1 -0
  43. package/lib/cjs/dylan-DLEmvz1I.js +340 -0
  44. package/lib/cjs/dylan-DLEmvz1I.js.map +1 -0
  45. package/lib/cjs/ebnf-36cJWqxB.js +154 -0
  46. package/lib/cjs/ebnf-36cJWqxB.js.map +1 -0
  47. package/lib/cjs/ecl-UWr5vJKJ.js +193 -0
  48. package/lib/cjs/ecl-UWr5vJKJ.js.map +1 -0
  49. package/lib/cjs/eiffel-Su-C9LAY.js +149 -0
  50. package/lib/cjs/eiffel-Su-C9LAY.js.map +1 -0
  51. package/lib/cjs/elm-vNNfVJj7.js +233 -0
  52. package/lib/cjs/elm-vNNfVJj7.js.map +1 -0
  53. package/lib/cjs/erlang-NM9dgYaS.js +584 -0
  54. package/lib/cjs/erlang-NM9dgYaS.js.map +1 -0
  55. package/lib/cjs/factor-RWs-4aWg.js +68 -0
  56. package/lib/cjs/factor-RWs-4aWg.js.map +1 -0
  57. package/lib/cjs/fcl-acUhGCfs.js +157 -0
  58. package/lib/cjs/fcl-acUhGCfs.js.map +1 -0
  59. package/lib/cjs/forth-sDkE6z3A.js +167 -0
  60. package/lib/cjs/forth-sDkE6z3A.js.map +1 -0
  61. package/lib/cjs/fortran-gkb4yvdk.js +175 -0
  62. package/lib/cjs/fortran-gkb4yvdk.js.map +1 -0
  63. package/lib/cjs/gas-mNA0qvkv.js +347 -0
  64. package/lib/cjs/gas-mNA0qvkv.js.map +1 -0
  65. package/lib/cjs/gherkin-5uyKpXXh.js +150 -0
  66. package/lib/cjs/gherkin-5uyKpXXh.js.map +1 -0
  67. package/lib/cjs/go-5XitXoIZ.js +167 -0
  68. package/lib/cjs/go-5XitXoIZ.js.map +1 -0
  69. package/lib/cjs/groovy-mz3pWMKN.js +233 -0
  70. package/lib/cjs/groovy-mz3pWMKN.js.map +1 -0
  71. package/lib/cjs/haskell-9KaSS7kb.js +242 -0
  72. package/lib/cjs/haskell-9KaSS7kb.js.map +1 -0
  73. package/lib/cjs/haxe-L8h6Pvni.js +494 -0
  74. package/lib/cjs/haxe-L8h6Pvni.js.map +1 -0
  75. package/lib/cjs/helper-OEW-2Vxr.js +9 -0
  76. package/lib/cjs/helper-OEW-2Vxr.js.map +1 -0
  77. package/lib/cjs/http-BFQQnRR-.js +92 -0
  78. package/lib/cjs/http-BFQQnRR-.js.map +1 -0
  79. package/lib/cjs/idl-29T-AzAy.js +277 -0
  80. package/lib/cjs/idl-29T-AzAy.js.map +1 -0
  81. package/lib/cjs/index-2oxl5Zo4.js +551 -0
  82. package/lib/cjs/index-2oxl5Zo4.js.map +1 -0
  83. package/lib/cjs/index-5PcT4iSf.js +107 -0
  84. package/lib/cjs/index-5PcT4iSf.js.map +1 -0
  85. package/lib/cjs/index-78P4PeZ9.js +361 -0
  86. package/lib/cjs/index-78P4PeZ9.js.map +1 -0
  87. package/lib/cjs/index-GEIgbcVc.js +1028 -0
  88. package/lib/cjs/index-GEIgbcVc.js.map +1 -0
  89. package/lib/cjs/index-GKolgvC5.js +505 -0
  90. package/lib/cjs/index-GKolgvC5.js.map +1 -0
  91. package/lib/cjs/index-JAqL0ybh.js +55 -0
  92. package/lib/cjs/index-JAqL0ybh.js.map +1 -0
  93. package/lib/cjs/index-LdEYPSZc.js +80 -0
  94. package/lib/cjs/index-LdEYPSZc.js.map +1 -0
  95. package/lib/cjs/index-Ne_pk53w.js +178 -0
  96. package/lib/cjs/index-Ne_pk53w.js.map +1 -0
  97. package/lib/cjs/index-O3vRXWIP.js +199 -0
  98. package/lib/cjs/index-O3vRXWIP.js.map +1 -0
  99. package/lib/cjs/index-OA_u95ey.js +531 -0
  100. package/lib/cjs/index-OA_u95ey.js.map +1 -0
  101. package/lib/cjs/index-OIQn1x0L.js +262 -0
  102. package/lib/cjs/index-OIQn1x0L.js.map +1 -0
  103. package/lib/cjs/index-OtaMLv5l.js +397 -0
  104. package/lib/cjs/index-OtaMLv5l.js.map +1 -0
  105. package/lib/cjs/index-PF7s7DOo.js +386 -0
  106. package/lib/cjs/index-PF7s7DOo.js.map +1 -0
  107. package/lib/cjs/index-SxWWV8XD.js +442 -0
  108. package/lib/cjs/index-SxWWV8XD.js.map +1 -0
  109. package/lib/cjs/index-TEjdwq--.js +2518 -0
  110. package/lib/cjs/index-TEjdwq--.js.map +1 -0
  111. package/lib/cjs/index-de3dfsQr.js +1044 -0
  112. package/lib/cjs/index-de3dfsQr.js.map +1 -0
  113. package/lib/cjs/index-fkT0ywfA.js +698 -0
  114. package/lib/cjs/index-fkT0ywfA.js.map +1 -0
  115. package/lib/cjs/index-i0_v2uVp.js +202 -0
  116. package/lib/cjs/index-i0_v2uVp.js.map +1 -0
  117. package/lib/cjs/index-kNI3S3lF.js +22477 -0
  118. package/lib/cjs/index-kNI3S3lF.js.map +1 -0
  119. package/lib/cjs/index-kvO8ReCY.js +1960 -0
  120. package/lib/cjs/index-kvO8ReCY.js.map +1 -0
  121. package/lib/cjs/index-llNS_EuP.js +25695 -0
  122. package/lib/cjs/index-llNS_EuP.js.map +1 -0
  123. package/lib/cjs/index-lrFGGa_l.js +404 -0
  124. package/lib/cjs/index-lrFGGa_l.js.map +1 -0
  125. package/lib/cjs/index-mJ47ZWO2.js +155 -0
  126. package/lib/cjs/index-mJ47ZWO2.js.map +1 -0
  127. package/lib/cjs/index-ortUqbAp.js +463 -0
  128. package/lib/cjs/index-ortUqbAp.js.map +1 -0
  129. package/lib/cjs/index-qRg5-QJH.js +160 -0
  130. package/lib/cjs/index-qRg5-QJH.js.map +1 -0
  131. package/lib/cjs/index-t_GA5F26.js +208 -0
  132. package/lib/cjs/index-t_GA5F26.js.map +1 -0
  133. package/lib/cjs/index-tbEq3xma.js +118 -0
  134. package/lib/cjs/index-tbEq3xma.js.map +1 -0
  135. package/lib/cjs/index-vlxA_KJ8.js +127 -0
  136. package/lib/cjs/index-vlxA_KJ8.js.map +1 -0
  137. package/lib/cjs/index-w9buMrFW.js +355 -0
  138. package/lib/cjs/index-w9buMrFW.js.map +1 -0
  139. package/lib/cjs/index-wXLifZgm.js +1877 -0
  140. package/lib/cjs/index-wXLifZgm.js.map +1 -0
  141. package/lib/cjs/index-xqKfEyRA.js +73 -0
  142. package/lib/cjs/index-xqKfEyRA.js.map +1 -0
  143. package/lib/cjs/index-z6pe2alg.js +20 -0
  144. package/lib/cjs/index-z6pe2alg.js.map +1 -0
  145. package/lib/cjs/index-zBr61zy6.js +773 -0
  146. package/lib/cjs/index-zBr61zy6.js.map +1 -0
  147. package/lib/cjs/index.js +19 -0
  148. package/lib/cjs/index.js.map +1 -0
  149. package/lib/cjs/javascript-5-BTydbD.js +928 -0
  150. package/lib/cjs/javascript-5-BTydbD.js.map +1 -0
  151. package/lib/cjs/jinja2-BWMz4gPk.js +174 -0
  152. package/lib/cjs/jinja2-BWMz4gPk.js.map +1 -0
  153. package/lib/cjs/julia-dtR9J3KZ.js +372 -0
  154. package/lib/cjs/julia-dtR9J3KZ.js.map +1 -0
  155. package/lib/cjs/livescript-YxT0INe3.js +262 -0
  156. package/lib/cjs/livescript-YxT0INe3.js.map +1 -0
  157. package/lib/cjs/lua-h7_AXjy9.js +140 -0
  158. package/lib/cjs/lua-h7_AXjy9.js.map +1 -0
  159. package/lib/cjs/mathematica-Zc57fOr3.js +156 -0
  160. package/lib/cjs/mathematica-Zc57fOr3.js.map +1 -0
  161. package/lib/cjs/mbox-ltKsKgJd.js +117 -0
  162. package/lib/cjs/mbox-ltKsKgJd.js.map +1 -0
  163. package/lib/cjs/meta-q8q9fHyr.js +14 -0
  164. package/lib/cjs/meta-q8q9fHyr.js.map +1 -0
  165. package/lib/cjs/mirc-xTLeWqmy.js +179 -0
  166. package/lib/cjs/mirc-xTLeWqmy.js.map +1 -0
  167. package/lib/cjs/mllike-xukl-Kjp.js +351 -0
  168. package/lib/cjs/mllike-xukl-Kjp.js.map +1 -0
  169. package/lib/cjs/modelica-LsXtAawk.js +195 -0
  170. package/lib/cjs/modelica-LsXtAawk.js.map +1 -0
  171. package/lib/cjs/mscgen-9HooYIVW.js +154 -0
  172. package/lib/cjs/mscgen-9HooYIVW.js.map +1 -0
  173. package/lib/cjs/mumps-VXqGp84f.js +132 -0
  174. package/lib/cjs/mumps-VXqGp84f.js.map +1 -0
  175. package/lib/cjs/nginx-UrubUbn1.js +166 -0
  176. package/lib/cjs/nginx-UrubUbn1.js.map +1 -0
  177. package/lib/cjs/nsis-c2AYwqyy.js +83 -0
  178. package/lib/cjs/nsis-c2AYwqyy.js.map +1 -0
  179. package/lib/cjs/ntriples-N1nwiheD.js +144 -0
  180. package/lib/cjs/ntriples-N1nwiheD.js.map +1 -0
  181. package/lib/cjs/octave-ElonStfZ.js +115 -0
  182. package/lib/cjs/octave-ElonStfZ.js.map +1 -0
  183. package/lib/cjs/oz-7VQTnCfu.js +238 -0
  184. package/lib/cjs/oz-7VQTnCfu.js.map +1 -0
  185. package/lib/cjs/pascal-yq2Cb88Q.js +127 -0
  186. package/lib/cjs/pascal-yq2Cb88Q.js.map +1 -0
  187. package/lib/cjs/perl-hJq4byS9.js +822 -0
  188. package/lib/cjs/perl-hJq4byS9.js.map +1 -0
  189. package/lib/cjs/pig-2syuOlAa.js +152 -0
  190. package/lib/cjs/pig-2syuOlAa.js.map +1 -0
  191. package/lib/cjs/powershell-NDwxuSDg.js +384 -0
  192. package/lib/cjs/powershell-NDwxuSDg.js.map +1 -0
  193. package/lib/cjs/properties-wacODxDJ.js +65 -0
  194. package/lib/cjs/properties-wacODxDJ.js.map +1 -0
  195. package/lib/cjs/protobuf-zVHZwskk.js +57 -0
  196. package/lib/cjs/protobuf-zVHZwskk.js.map +1 -0
  197. package/lib/cjs/puppet-koQikqO-.js +208 -0
  198. package/lib/cjs/puppet-koQikqO-.js.map +1 -0
  199. package/lib/cjs/python-P3UsKHbj.js +394 -0
  200. package/lib/cjs/python-P3UsKHbj.js.map +1 -0
  201. package/lib/cjs/q-Z_d2uXoA.js +126 -0
  202. package/lib/cjs/q-Z_d2uXoA.js.map +1 -0
  203. package/lib/cjs/r-J6Jl9z1i.js +177 -0
  204. package/lib/cjs/r-J6Jl9z1i.js.map +1 -0
  205. package/lib/cjs/rpm-6C0Omumu.js +93 -0
  206. package/lib/cjs/rpm-6C0Omumu.js.map +1 -0
  207. package/lib/cjs/ruby-POVyUmsb.js +290 -0
  208. package/lib/cjs/ruby-POVyUmsb.js.map +1 -0
  209. package/lib/cjs/sas-vDtpSmFr.js +271 -0
  210. package/lib/cjs/sas-vDtpSmFr.js.map +1 -0
  211. package/lib/cjs/schema-7d3meDfB.js +74 -0
  212. package/lib/cjs/schema-7d3meDfB.js.map +1 -0
  213. package/lib/cjs/scheme-5AA5BH7S.js +266 -0
  214. package/lib/cjs/scheme-5AA5BH7S.js.map +1 -0
  215. package/lib/cjs/shell-_ztDMiW6.js +148 -0
  216. package/lib/cjs/shell-_ztDMiW6.js.map +1 -0
  217. package/lib/cjs/sieve-R_vzlbvH.js +181 -0
  218. package/lib/cjs/sieve-R_vzlbvH.js.map +1 -0
  219. package/lib/cjs/simple-mode-ZwmNbV0h.js +138 -0
  220. package/lib/cjs/simple-mode-ZwmNbV0h.js.map +1 -0
  221. package/lib/cjs/smalltalk-dWLp5zN8.js +156 -0
  222. package/lib/cjs/smalltalk-dWLp5zN8.js.map +1 -0
  223. package/lib/cjs/solr-wSmvjKI8.js +83 -0
  224. package/lib/cjs/solr-wSmvjKI8.js.map +1 -0
  225. package/lib/cjs/sparql-GNU_0xKB.js +173 -0
  226. package/lib/cjs/sparql-GNU_0xKB.js.map +1 -0
  227. package/lib/cjs/spreadsheet-BiqYLk6M.js +101 -0
  228. package/lib/cjs/spreadsheet-BiqYLk6M.js.map +1 -0
  229. package/lib/cjs/sql-9GpHBPsC.js +497 -0
  230. package/lib/cjs/sql-9GpHBPsC.js.map +1 -0
  231. package/lib/cjs/stex-1V41CNLk.js +250 -0
  232. package/lib/cjs/stex-1V41CNLk.js.map +1 -0
  233. package/lib/cjs/stylus-H6hn9z_G.js +753 -0
  234. package/lib/cjs/stylus-H6hn9z_G.js.map +1 -0
  235. package/lib/cjs/swift-Xv5f8zgN.js +205 -0
  236. package/lib/cjs/swift-Xv5f8zgN.js.map +1 -0
  237. package/lib/cjs/tcl-LI-LOw_t.js +128 -0
  238. package/lib/cjs/tcl-LI-LOw_t.js.map +1 -0
  239. package/lib/cjs/textile-3NvRPUgg.js +444 -0
  240. package/lib/cjs/textile-3NvRPUgg.js.map +1 -0
  241. package/lib/cjs/tiddlywiki-PkMzy8_R.js +281 -0
  242. package/lib/cjs/tiddlywiki-PkMzy8_R.js.map +1 -0
  243. package/lib/cjs/tiki-Zk_GnEC8.js +292 -0
  244. package/lib/cjs/tiki-Zk_GnEC8.js.map +1 -0
  245. package/lib/cjs/toml-36gJ0YCq.js +78 -0
  246. package/lib/cjs/toml-36gJ0YCq.js.map +1 -0
  247. package/lib/cjs/tooltip-plugin-Mk9fRTxI.js +200 -0
  248. package/lib/cjs/tooltip-plugin-Mk9fRTxI.js.map +1 -0
  249. package/lib/cjs/troff-RLZ_o61o.js +67 -0
  250. package/lib/cjs/troff-RLZ_o61o.js.map +1 -0
  251. package/lib/cjs/ttcn-cfg-twaoJYvf.js +204 -0
  252. package/lib/cjs/ttcn-cfg-twaoJYvf.js.map +1 -0
  253. package/lib/cjs/ttcn-kGwvGb2v.js +260 -0
  254. package/lib/cjs/ttcn-kGwvGb2v.js.map +1 -0
  255. package/lib/cjs/turtle-nnevat7b.js +144 -0
  256. package/lib/cjs/turtle-nnevat7b.js.map +1 -0
  257. package/lib/cjs/vb-fO_I9s3s.js +252 -0
  258. package/lib/cjs/vb-fO_I9s3s.js.map +1 -0
  259. package/lib/cjs/vbscript-HXnn40y4.js +324 -0
  260. package/lib/cjs/vbscript-HXnn40y4.js.map +1 -0
  261. package/lib/cjs/velocity-Wn-ZfFzr.js +189 -0
  262. package/lib/cjs/velocity-Wn-ZfFzr.js.map +1 -0
  263. package/lib/cjs/verilog-y1ev34z6.js +569 -0
  264. package/lib/cjs/verilog-y1ev34z6.js.map +1 -0
  265. package/lib/cjs/vhdl-LF0oeXxc.js +177 -0
  266. package/lib/cjs/vhdl-LF0oeXxc.js.map +1 -0
  267. package/lib/cjs/webidl-6kI5KbeC.js +182 -0
  268. package/lib/cjs/webidl-6kI5KbeC.js.map +1 -0
  269. package/lib/cjs/xquery-BavrmwsO.js +428 -0
  270. package/lib/cjs/xquery-BavrmwsO.js.map +1 -0
  271. package/lib/cjs/yacas-1g_AbTrl.js +185 -0
  272. package/lib/cjs/yacas-1g_AbTrl.js.map +1 -0
  273. package/lib/cjs/z80-QYzKAAp7.js +106 -0
  274. package/lib/cjs/z80-QYzKAAp7.js.map +1 -0
  275. package/lib/esm/_view-JjtfhQ8k.js +25 -0
  276. package/lib/esm/_view-JjtfhQ8k.js.map +1 -0
  277. package/lib/esm/apl-eHQxyJFn.js +143 -0
  278. package/lib/esm/apl-eHQxyJFn.js.map +1 -0
  279. package/lib/esm/asciiarmor-Z-IGYCI4.js +57 -0
  280. package/lib/esm/asciiarmor-Z-IGYCI4.js.map +1 -0
  281. package/lib/esm/asn1-gF7x-q1y.js +193 -0
  282. package/lib/esm/asn1-gF7x-q1y.js.map +1 -0
  283. package/lib/esm/asterisk-swk20ftp.js +188 -0
  284. package/lib/esm/asterisk-swk20ftp.js.map +1 -0
  285. package/lib/esm/brainfuck-IFQdiQoR.js +71 -0
  286. package/lib/esm/brainfuck-IFQdiQoR.js.map +1 -0
  287. package/lib/esm/clike-q3hUF2Cx.js +1019 -0
  288. package/lib/esm/clike-q3hUF2Cx.js.map +1 -0
  289. package/lib/esm/clojure-I2Krbr2M.js +275 -0
  290. package/lib/esm/clojure-I2Krbr2M.js.map +1 -0
  291. package/lib/{icons-HYkfuR-O.js → esm/clsx-R7WFaNKL.js} +22 -20
  292. package/lib/esm/clsx-R7WFaNKL.js.map +1 -0
  293. package/lib/esm/cmake-ewwXLeuZ.js +82 -0
  294. package/lib/esm/cmake-ewwXLeuZ.js.map +1 -0
  295. package/lib/esm/cobol-fpN1nAnR.js +236 -0
  296. package/lib/esm/cobol-fpN1nAnR.js.map +1 -0
  297. package/lib/esm/coffeescript--eTFR-bH.js +330 -0
  298. package/lib/esm/coffeescript--eTFR-bH.js.map +1 -0
  299. package/lib/esm/commonlisp-XLSwVdLc.js +109 -0
  300. package/lib/esm/commonlisp-XLSwVdLc.js.map +1 -0
  301. package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js +1132 -0
  302. package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js.map +1 -0
  303. package/lib/esm/crystal-_r3Aa1_a.js +420 -0
  304. package/lib/esm/crystal-_r3Aa1_a.js.map +1 -0
  305. package/lib/esm/css-hgwYGMKZ.js +848 -0
  306. package/lib/esm/css-hgwYGMKZ.js.map +1 -0
  307. package/lib/esm/cypher-bbJyAa-4.js +123 -0
  308. package/lib/esm/cypher-bbJyAa-4.js.map +1 -0
  309. package/lib/esm/d-5MyulviS.js +206 -0
  310. package/lib/esm/d-5MyulviS.js.map +1 -0
  311. package/lib/esm/diff-neOaT_vk.js +31 -0
  312. package/lib/esm/diff-neOaT_vk.js.map +1 -0
  313. package/lib/{dockerfile-u6f6Vw2s.js → esm/dockerfile-lzx42-zz.js} +42 -36
  314. package/lib/esm/dockerfile-lzx42-zz.js.map +1 -0
  315. package/lib/esm/dtd-FmzPLZcQ.js +122 -0
  316. package/lib/esm/dtd-FmzPLZcQ.js.map +1 -0
  317. package/lib/esm/dylan-1HtRK4GO.js +338 -0
  318. package/lib/esm/dylan-1HtRK4GO.js.map +1 -0
  319. package/lib/esm/ebnf-Nz-pnLHy.js +152 -0
  320. package/lib/esm/ebnf-Nz-pnLHy.js.map +1 -0
  321. package/lib/esm/ecl-lQsZhQz0.js +191 -0
  322. package/lib/esm/ecl-lQsZhQz0.js.map +1 -0
  323. package/lib/esm/eiffel-R_HiEkhx.js +147 -0
  324. package/lib/esm/eiffel-R_HiEkhx.js.map +1 -0
  325. package/lib/esm/elm-KYv4VTDg.js +231 -0
  326. package/lib/esm/elm-KYv4VTDg.js.map +1 -0
  327. package/lib/esm/erlang-7YaHCBIe.js +582 -0
  328. package/lib/esm/erlang-7YaHCBIe.js.map +1 -0
  329. package/lib/esm/factor-opBU9aTK.js +66 -0
  330. package/lib/esm/factor-opBU9aTK.js.map +1 -0
  331. package/lib/esm/fcl-jm31FmFz.js +155 -0
  332. package/lib/esm/fcl-jm31FmFz.js.map +1 -0
  333. package/lib/esm/forth-5NKbjnWh.js +165 -0
  334. package/lib/esm/forth-5NKbjnWh.js.map +1 -0
  335. package/lib/esm/fortran-dXm_-cb9.js +173 -0
  336. package/lib/esm/fortran-dXm_-cb9.js.map +1 -0
  337. package/lib/esm/gas-nsYVnsy-.js +344 -0
  338. package/lib/esm/gas-nsYVnsy-.js.map +1 -0
  339. package/lib/esm/gherkin-fzKpjm3M.js +148 -0
  340. package/lib/esm/gherkin-fzKpjm3M.js.map +1 -0
  341. package/lib/esm/go-Pn1qh7yl.js +165 -0
  342. package/lib/esm/go-Pn1qh7yl.js.map +1 -0
  343. package/lib/esm/groovy-DZY-8keZ.js +231 -0
  344. package/lib/esm/groovy-DZY-8keZ.js.map +1 -0
  345. package/lib/esm/haskell-JGh2upDd.js +240 -0
  346. package/lib/esm/haskell-JGh2upDd.js.map +1 -0
  347. package/lib/esm/haxe-1hvVK-Fy.js +491 -0
  348. package/lib/esm/haxe-1hvVK-Fy.js.map +1 -0
  349. package/lib/esm/helper-iYEjPbOY.js +7 -0
  350. package/lib/esm/helper-iYEjPbOY.js.map +1 -0
  351. package/lib/esm/http-mY1M77wn.js +90 -0
  352. package/lib/esm/http-mY1M77wn.js.map +1 -0
  353. package/lib/esm/idl-dy_653wH.js +275 -0
  354. package/lib/esm/idl-dy_653wH.js.map +1 -0
  355. package/lib/esm/index-0khVa44f.js +77 -0
  356. package/lib/esm/index-0khVa44f.js.map +1 -0
  357. package/lib/esm/index-218OjRxG.js +549 -0
  358. package/lib/esm/index-218OjRxG.js.map +1 -0
  359. package/lib/{index-jZuF1Iix.js → esm/index-4QzlLVWs.js} +181 -128
  360. package/lib/esm/index-4QzlLVWs.js.map +1 -0
  361. package/lib/{index-P4-KqpEN.js → esm/index-4oMdufW4.js} +321 -239
  362. package/lib/esm/index-4oMdufW4.js.map +1 -0
  363. package/lib/esm/index-6P9Xk934.js +758 -0
  364. package/lib/esm/index-6P9Xk934.js.map +1 -0
  365. package/lib/{index-yrfirMbY.js → esm/index-7BVeXLQZ.js} +489 -514
  366. package/lib/esm/index-7BVeXLQZ.js.map +1 -0
  367. package/lib/{index-qMeqmZtK.js → esm/index-A9zdyi2L.js} +186 -149
  368. package/lib/esm/index-A9zdyi2L.js.map +1 -0
  369. package/lib/esm/index-AHPvVH4H.js +197 -0
  370. package/lib/esm/index-AHPvVH4H.js.map +1 -0
  371. package/lib/esm/index-Bg5GFp0g.js +384 -0
  372. package/lib/esm/index-Bg5GFp0g.js.map +1 -0
  373. package/lib/esm/index-DoEghZHy.js +2511 -0
  374. package/lib/esm/index-DoEghZHy.js.map +1 -0
  375. package/lib/esm/index-Grquo08f.js +152 -0
  376. package/lib/esm/index-Grquo08f.js.map +1 -0
  377. package/lib/esm/index-JkHHp3K-.js +22445 -0
  378. package/lib/esm/index-JkHHp3K-.js.map +1 -0
  379. package/lib/esm/index-Jvxff1vU.js +16 -0
  380. package/lib/esm/index-Jvxff1vU.js.map +1 -0
  381. package/lib/{index-DDSXiQ90.js → esm/index-L7VXk-jT.js} +645 -512
  382. package/lib/esm/index-L7VXk-jT.js.map +1 -0
  383. package/lib/esm/index-NmjiRA0M.js +1026 -0
  384. package/lib/esm/index-NmjiRA0M.js.map +1 -0
  385. package/lib/esm/index-PkBZpDL4.js +258 -0
  386. package/lib/esm/index-PkBZpDL4.js.map +1 -0
  387. package/lib/esm/index-TNMG6UrN.js +53 -0
  388. package/lib/esm/index-TNMG6UrN.js.map +1 -0
  389. package/lib/esm/index-U71v7KdA.js +400 -0
  390. package/lib/esm/index-U71v7KdA.js.map +1 -0
  391. package/lib/esm/index-U8q-F7hU.js +114 -0
  392. package/lib/esm/index-U8q-F7hU.js.map +1 -0
  393. package/lib/esm/index-UBeneu17.js +392 -0
  394. package/lib/esm/index-UBeneu17.js.map +1 -0
  395. package/lib/esm/index-VyZguCIt.js +69 -0
  396. package/lib/esm/index-VyZguCIt.js.map +1 -0
  397. package/lib/esm/index-a-SAfeeT.js +104 -0
  398. package/lib/esm/index-a-SAfeeT.js.map +1 -0
  399. package/lib/{index-KCykNSJx.js → esm/index-bVubJ6Rv.js} +405 -289
  400. package/lib/esm/index-bVubJ6Rv.js.map +1 -0
  401. package/lib/{index-kyD7hUif.js → esm/index-bsED907r.js} +143 -128
  402. package/lib/esm/index-bsED907r.js.map +1 -0
  403. package/lib/esm/index-h1arGiXv.js +1958 -0
  404. package/lib/esm/index-h1arGiXv.js.map +1 -0
  405. package/lib/esm/index-hQaRWeq1.js +350 -0
  406. package/lib/esm/index-hQaRWeq1.js.map +1 -0
  407. package/lib/esm/index-oMy83ynO.js +460 -0
  408. package/lib/esm/index-oMy83ynO.js.map +1 -0
  409. package/lib/esm/index-pHsvfB_I.js +503 -0
  410. package/lib/esm/index-pHsvfB_I.js.map +1 -0
  411. package/lib/esm/index-q-qE7-96.js +25651 -0
  412. package/lib/esm/index-q-qE7-96.js.map +1 -0
  413. package/lib/esm/index-rwcSpYkt.js +1037 -0
  414. package/lib/esm/index-rwcSpYkt.js.map +1 -0
  415. package/lib/esm/index-u8tWJbca.js +176 -0
  416. package/lib/esm/index-u8tWJbca.js.map +1 -0
  417. package/lib/{index-x6C6leag.js → esm/index-vwrMVELn.js} +110 -85
  418. package/lib/esm/index-vwrMVELn.js.map +1 -0
  419. package/lib/esm/index-x-zW6gKj.js +1872 -0
  420. package/lib/esm/index-x-zW6gKj.js.map +1 -0
  421. package/lib/esm/index.js +12 -0
  422. package/lib/esm/index.js.map +1 -0
  423. package/lib/esm/javascript-TMTz-YQH.js +923 -0
  424. package/lib/esm/javascript-TMTz-YQH.js.map +1 -0
  425. package/lib/esm/jinja2-sRIdliZK.js +172 -0
  426. package/lib/esm/jinja2-sRIdliZK.js.map +1 -0
  427. package/lib/esm/julia-fK0wmpGL.js +370 -0
  428. package/lib/esm/julia-fK0wmpGL.js.map +1 -0
  429. package/lib/esm/livescript-FRbAot3D.js +260 -0
  430. package/lib/esm/livescript-FRbAot3D.js.map +1 -0
  431. package/lib/esm/lua-t4FHEjvK.js +138 -0
  432. package/lib/esm/lua-t4FHEjvK.js.map +1 -0
  433. package/lib/esm/mathematica-sn_KGlYj.js +154 -0
  434. package/lib/esm/mathematica-sn_KGlYj.js.map +1 -0
  435. package/lib/esm/mbox-KvVC319E.js +115 -0
  436. package/lib/esm/mbox-KvVC319E.js.map +1 -0
  437. package/lib/esm/meta-3ZYGAGrY.js +12 -0
  438. package/lib/esm/meta-3ZYGAGrY.js.map +1 -0
  439. package/lib/esm/mirc-PzJ0zKSk.js +177 -0
  440. package/lib/esm/mirc-PzJ0zKSk.js.map +1 -0
  441. package/lib/esm/mllike-ZK411xkN.js +347 -0
  442. package/lib/esm/mllike-ZK411xkN.js.map +1 -0
  443. package/lib/esm/modelica-ZaHlRCbp.js +193 -0
  444. package/lib/esm/modelica-ZaHlRCbp.js.map +1 -0
  445. package/lib/esm/mscgen-Kkq4o4Zm.js +150 -0
  446. package/lib/esm/mscgen-Kkq4o4Zm.js.map +1 -0
  447. package/lib/esm/mumps-M8a87-rl.js +130 -0
  448. package/lib/esm/mumps-M8a87-rl.js.map +1 -0
  449. package/lib/esm/nginx-2LJIX23E.js +164 -0
  450. package/lib/esm/nginx-2LJIX23E.js.map +1 -0
  451. package/lib/esm/nsis-zvfFgMLi.js +81 -0
  452. package/lib/esm/nsis-zvfFgMLi.js.map +1 -0
  453. package/lib/esm/ntriples-tVkHy5bk.js +142 -0
  454. package/lib/esm/ntriples-tVkHy5bk.js.map +1 -0
  455. package/lib/esm/octave-mE4T5MF5.js +113 -0
  456. package/lib/esm/octave-mE4T5MF5.js.map +1 -0
  457. package/lib/esm/oz-q-LCsuVg.js +236 -0
  458. package/lib/esm/oz-q-LCsuVg.js.map +1 -0
  459. package/lib/esm/pascal-0IgUAn4C.js +125 -0
  460. package/lib/esm/pascal-0IgUAn4C.js.map +1 -0
  461. package/lib/esm/perl-AqxdYGac.js +820 -0
  462. package/lib/esm/perl-AqxdYGac.js.map +1 -0
  463. package/lib/esm/pig-ESM-IjQj.js +150 -0
  464. package/lib/esm/pig-ESM-IjQj.js.map +1 -0
  465. package/lib/esm/powershell-CLFP0L55.js +382 -0
  466. package/lib/esm/powershell-CLFP0L55.js.map +1 -0
  467. package/lib/esm/properties-oWHNzvb9.js +63 -0
  468. package/lib/esm/properties-oWHNzvb9.js.map +1 -0
  469. package/lib/esm/protobuf-c7eMmdcc.js +55 -0
  470. package/lib/esm/protobuf-c7eMmdcc.js.map +1 -0
  471. package/lib/esm/puppet-FjzvdRJr.js +206 -0
  472. package/lib/esm/puppet-FjzvdRJr.js.map +1 -0
  473. package/lib/esm/python-3Pv0tnvt.js +390 -0
  474. package/lib/esm/python-3Pv0tnvt.js.map +1 -0
  475. package/lib/esm/q-IImW8da6.js +124 -0
  476. package/lib/esm/q-IImW8da6.js.map +1 -0
  477. package/lib/esm/r-CnEkTvR0.js +175 -0
  478. package/lib/esm/r-CnEkTvR0.js.map +1 -0
  479. package/lib/esm/rpm-Q55-fEHj.js +90 -0
  480. package/lib/esm/rpm-Q55-fEHj.js.map +1 -0
  481. package/lib/esm/ruby-zhaGB3Kh.js +288 -0
  482. package/lib/esm/ruby-zhaGB3Kh.js.map +1 -0
  483. package/lib/esm/sas-Ur9jZIOV.js +269 -0
  484. package/lib/esm/sas-Ur9jZIOV.js.map +1 -0
  485. package/lib/esm/schema-hVsy-vme.js +71 -0
  486. package/lib/esm/schema-hVsy-vme.js.map +1 -0
  487. package/lib/esm/scheme-daT5-Rya.js +264 -0
  488. package/lib/esm/scheme-daT5-Rya.js.map +1 -0
  489. package/lib/esm/shell-cwFL0AYP.js +146 -0
  490. package/lib/esm/shell-cwFL0AYP.js.map +1 -0
  491. package/lib/esm/sieve-MlNXFFUq.js +179 -0
  492. package/lib/esm/sieve-MlNXFFUq.js.map +1 -0
  493. package/lib/esm/simple-mode-m1rsX7Gw.js +136 -0
  494. package/lib/esm/simple-mode-m1rsX7Gw.js.map +1 -0
  495. package/lib/esm/smalltalk-xrQICp9e.js +154 -0
  496. package/lib/esm/smalltalk-xrQICp9e.js.map +1 -0
  497. package/lib/esm/solr-PU3oPgQz.js +81 -0
  498. package/lib/esm/solr-PU3oPgQz.js.map +1 -0
  499. package/lib/esm/sparql--u8NRBii.js +171 -0
  500. package/lib/esm/sparql--u8NRBii.js.map +1 -0
  501. package/lib/esm/spreadsheet-QCp0LifX.js +99 -0
  502. package/lib/esm/spreadsheet-QCp0LifX.js.map +1 -0
  503. package/lib/esm/sql-dsGfl64h.js +482 -0
  504. package/lib/esm/sql-dsGfl64h.js.map +1 -0
  505. package/lib/esm/stex-WcLBzvkD.js +247 -0
  506. package/lib/esm/stex-WcLBzvkD.js.map +1 -0
  507. package/lib/esm/stylus--A5XAqOX.js +751 -0
  508. package/lib/esm/stylus--A5XAqOX.js.map +1 -0
  509. package/lib/esm/swift-qAm73i7G.js +203 -0
  510. package/lib/esm/swift-qAm73i7G.js.map +1 -0
  511. package/lib/esm/tcl-Kdc7qxc-.js +126 -0
  512. package/lib/esm/tcl-Kdc7qxc-.js.map +1 -0
  513. package/lib/esm/textile--sz8UrIz.js +442 -0
  514. package/lib/esm/textile--sz8UrIz.js.map +1 -0
  515. package/lib/esm/tiddlywiki-xNXTeBlQ.js +279 -0
  516. package/lib/esm/tiddlywiki-xNXTeBlQ.js.map +1 -0
  517. package/lib/esm/tiki-LCXjrNH3.js +290 -0
  518. package/lib/esm/tiki-LCXjrNH3.js.map +1 -0
  519. package/lib/esm/toml-Ac4tlBMn.js +76 -0
  520. package/lib/esm/toml-Ac4tlBMn.js.map +1 -0
  521. package/lib/esm/tooltip-plugin-vZefVSGL.js +194 -0
  522. package/lib/esm/tooltip-plugin-vZefVSGL.js.map +1 -0
  523. package/lib/esm/troff-LLW1x1Yz.js +65 -0
  524. package/lib/esm/troff-LLW1x1Yz.js.map +1 -0
  525. package/lib/esm/ttcn-ZYZ9FS3u.js +258 -0
  526. package/lib/esm/ttcn-ZYZ9FS3u.js.map +1 -0
  527. package/lib/esm/ttcn-cfg-qsvf3MfB.js +202 -0
  528. package/lib/esm/ttcn-cfg-qsvf3MfB.js.map +1 -0
  529. package/lib/esm/turtle-wq3TqOth.js +142 -0
  530. package/lib/esm/turtle-wq3TqOth.js.map +1 -0
  531. package/lib/esm/vb-86M_JuNP.js +250 -0
  532. package/lib/esm/vb-86M_JuNP.js.map +1 -0
  533. package/lib/esm/vbscript-GueAeVug.js +321 -0
  534. package/lib/esm/vbscript-GueAeVug.js.map +1 -0
  535. package/lib/esm/velocity-7PW9GXO2.js +187 -0
  536. package/lib/esm/velocity-7PW9GXO2.js.map +1 -0
  537. package/lib/esm/verilog-PXtXH14C.js +566 -0
  538. package/lib/esm/verilog-PXtXH14C.js.map +1 -0
  539. package/lib/esm/vhdl-I8eyK83X.js +175 -0
  540. package/lib/esm/vhdl-I8eyK83X.js.map +1 -0
  541. package/lib/esm/webidl-1f8ATJ66.js +180 -0
  542. package/lib/esm/webidl-1f8ATJ66.js.map +1 -0
  543. package/lib/esm/xquery-IYp28Wx6.js +426 -0
  544. package/lib/esm/xquery-IYp28Wx6.js.map +1 -0
  545. package/lib/esm/yacas-wkENB05f.js +183 -0
  546. package/lib/esm/yacas-wkENB05f.js.map +1 -0
  547. package/lib/esm/z80-GaXiLdiV.js +103 -0
  548. package/lib/esm/z80-GaXiLdiV.js.map +1 -0
  549. package/lib/theme/_internal/classic-common.css +256 -0
  550. package/lib/theme/classic/style.css +28 -0
  551. package/lib/theme/classic-dark/style.css +28 -0
  552. package/lib/theme/common/block-edit.css +118 -0
  553. package/lib/theme/common/code-mirror.css +177 -0
  554. package/lib/theme/common/cursor.css +13 -0
  555. package/lib/theme/common/image-block.css +362 -0
  556. package/lib/theme/common/link-tooltip.css +105 -0
  557. package/lib/theme/common/list-item.css +34 -0
  558. package/lib/theme/common/placeholder.css +7 -0
  559. package/lib/theme/common/prosemirror.css +1 -0
  560. package/lib/theme/common/style.css +9 -0
  561. package/lib/theme/common/toolbar.css +34 -0
  562. package/lib/{core → types/core}/crepe.d.ts +1 -3
  563. package/lib/types/core/crepe.d.ts.map +1 -0
  564. package/lib/types/core/index.d.ts +2 -0
  565. package/lib/types/core/index.d.ts.map +1 -0
  566. package/lib/types/core/slice.d.ts +5 -0
  567. package/lib/types/core/slice.d.ts.map +1 -0
  568. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -0
  569. package/lib/{feature → types/feature}/block-edit/handle/index.d.ts +2 -3
  570. package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -0
  571. package/lib/types/feature/block-edit/index.d.ts.map +1 -0
  572. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -0
  573. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -0
  574. package/lib/types/feature/block-edit/menu/icons.d.ts.map +1 -0
  575. package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -0
  576. package/lib/types/feature/code-mirror/index.d.ts +11 -0
  577. package/lib/types/feature/code-mirror/index.d.ts.map +1 -0
  578. package/lib/types/feature/cursor/index.d.ts +9 -0
  579. package/lib/types/feature/cursor/index.d.ts.map +1 -0
  580. package/lib/types/feature/image-block/index.d.ts.map +1 -0
  581. package/lib/{feature → types/feature}/index.d.ts +3 -1
  582. package/lib/types/feature/index.d.ts.map +1 -0
  583. package/lib/types/feature/link-tooltip/consts.d.ts.map +1 -0
  584. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -0
  585. package/lib/types/feature/list-item/consts.d.ts.map +1 -0
  586. package/lib/types/feature/list-item/index.d.ts.map +1 -0
  587. package/lib/{feature → types/feature}/placeholder/index.d.ts +2 -1
  588. package/lib/types/feature/placeholder/index.d.ts.map +1 -0
  589. package/lib/{feature → types/feature}/shared.d.ts +1 -1
  590. package/lib/types/feature/shared.d.ts.map +1 -0
  591. package/lib/types/feature/toolbar/component.d.ts.map +1 -0
  592. package/lib/types/feature/toolbar/consts.d.ts.map +1 -0
  593. package/lib/types/feature/toolbar/index.d.ts.map +1 -0
  594. package/lib/types/index.d.ts +3 -0
  595. package/lib/types/index.d.ts.map +1 -0
  596. package/lib/{utils → types/utils}/index.d.ts +1 -0
  597. package/lib/types/utils/index.d.ts.map +1 -0
  598. package/package.json +31 -23
  599. package/src/core/crepe.ts +2 -8
  600. package/src/core/index.ts +0 -3
  601. package/src/core/slice.ts +0 -33
  602. package/src/feature/block-edit/handle/component.ts +0 -1
  603. package/src/feature/block-edit/handle/index.ts +26 -19
  604. package/src/feature/block-edit/index.ts +0 -4
  605. package/src/feature/block-edit/menu/component.ts +18 -10
  606. package/src/feature/block-edit/menu/config.ts +0 -1
  607. package/src/feature/block-edit/menu/icons.ts +0 -1
  608. package/src/feature/block-edit/menu/index.ts +9 -13
  609. package/src/feature/code-mirror/index.ts +24 -32
  610. package/src/feature/cursor/index.ts +22 -0
  611. package/src/feature/image-block/index.ts +0 -4
  612. package/src/feature/index.ts +6 -5
  613. package/src/feature/link-tooltip/consts.ts +0 -1
  614. package/src/feature/link-tooltip/index.ts +0 -4
  615. package/src/feature/list-item/consts.ts +0 -1
  616. package/src/feature/list-item/index.ts +2 -6
  617. package/src/feature/placeholder/index.ts +1 -5
  618. package/src/feature/shared.ts +1 -2
  619. package/src/feature/toolbar/component.ts +0 -1
  620. package/src/feature/toolbar/consts.ts +0 -1
  621. package/src/feature/toolbar/index.ts +10 -16
  622. package/src/index.ts +0 -3
  623. package/src/theme/_internal/classic-common.css +219 -0
  624. package/src/theme/classic/style.css +2 -166
  625. package/src/theme/classic-dark/style.css +2 -171
  626. package/src/{feature/block-edit/style.css → theme/common/block-edit.css} +11 -1
  627. package/src/theme/common/code-mirror.css +176 -0
  628. package/src/theme/common/cursor.css +15 -0
  629. package/src/{feature/image-block/style.css → theme/common/image-block.css} +180 -16
  630. package/src/{feature/link-tooltip/style.css → theme/common/link-tooltip.css} +8 -0
  631. package/src/{feature/list-item/style.css → theme/common/list-item.css} +14 -3
  632. package/src/theme/common/prosemirror.css +1 -0
  633. package/src/theme/common/style.css +9 -0
  634. package/src/{feature/toolbar/style.css → theme/common/toolbar.css} +4 -0
  635. package/src/utils/index.ts +5 -1
  636. package/src/vite-env.d.ts +0 -1
  637. package/lib/apl-p0IPP13W.js +0 -76
  638. package/lib/asciiarmor-lJsBxlJJ.js +0 -34
  639. package/lib/asn1-Q9v1zIy5.js +0 -102
  640. package/lib/asterisk-foNkeTjy.js +0 -273
  641. package/lib/brainfuck-0XqyXpNS.js +0 -35
  642. package/lib/clike-ak6Z6Yhe.js +0 -639
  643. package/lib/clojure-iYO8U8Sg.js +0 -810
  644. package/lib/clsx-7d8NmkQq.js +0 -21
  645. package/lib/cmake-SVzjkxV_.js +0 -28
  646. package/lib/cobol-APHEnAOX.js +0 -74
  647. package/lib/coffeescript-KqQa0SYG.js +0 -182
  648. package/lib/commonlisp-bwqNqR5V.js +0 -79
  649. package/lib/core/crepe.d.ts.map +0 -1
  650. package/lib/core/index.d.ts +0 -3
  651. package/lib/core/index.d.ts.map +0 -1
  652. package/lib/core/slice.d.ts +0 -12
  653. package/lib/core/slice.d.ts.map +0 -1
  654. package/lib/crystal-BViWuDpA.js +0 -217
  655. package/lib/css-KHXHXfXg.js +0 -1572
  656. package/lib/cypher-XpTt4zQ3.js +0 -69
  657. package/lib/d-fLig6yqY.js +0 -139
  658. package/lib/diff-WoKGLpy6.js +0 -18
  659. package/lib/dtd-SIJRUW6K.js +0 -91
  660. package/lib/dylan-4HCLhpWP.js +0 -238
  661. package/lib/ebnf-h_0lged5.js +0 -77
  662. package/lib/ecl-Lf4FF0lf.js +0 -133
  663. package/lib/eiffel-qlw8KUyf.js +0 -112
  664. package/lib/elm-QRnB3zXs.js +0 -108
  665. package/lib/erlang-fyVKb7eK.js +0 -488
  666. package/lib/factor-BEeN4upY.js +0 -65
  667. package/lib/fcl-lRek3hEb.js +0 -106
  668. package/lib/feature/block-edit/handle/component.d.ts.map +0 -1
  669. package/lib/feature/block-edit/handle/index.d.ts.map +0 -1
  670. package/lib/feature/block-edit/index.d.ts.map +0 -1
  671. package/lib/feature/block-edit/menu/component.d.ts.map +0 -1
  672. package/lib/feature/block-edit/menu/config.d.ts.map +0 -1
  673. package/lib/feature/block-edit/menu/icons.d.ts.map +0 -1
  674. package/lib/feature/block-edit/menu/index.d.ts.map +0 -1
  675. package/lib/feature/code-mirror/index.d.ts.map +0 -1
  676. package/lib/feature/gap-cursor/index.d.ts.map +0 -1
  677. package/lib/feature/image-block/index.d.ts.map +0 -1
  678. package/lib/feature/index.d.ts.map +0 -1
  679. package/lib/feature/link-tooltip/consts.d.ts.map +0 -1
  680. package/lib/feature/link-tooltip/index.d.ts.map +0 -1
  681. package/lib/feature/list-item/consts.d.ts.map +0 -1
  682. package/lib/feature/list-item/index.d.ts +0 -3
  683. package/lib/feature/list-item/index.d.ts.map +0 -1
  684. package/lib/feature/placeholder/index.d.ts.map +0 -1
  685. package/lib/feature/shared.d.ts.map +0 -1
  686. package/lib/feature/toolbar/component.d.ts.map +0 -1
  687. package/lib/feature/toolbar/consts.d.ts.map +0 -1
  688. package/lib/feature/toolbar/index.d.ts +0 -3
  689. package/lib/feature/toolbar/index.d.ts.map +0 -1
  690. package/lib/forth-ua2bRd8T.js +0 -60
  691. package/lib/fortran-WnF7znuN.js +0 -443
  692. package/lib/gas-wowve1o7.js +0 -183
  693. package/lib/gherkin-m7GIChu3.js +0 -34
  694. package/lib/go-th443Dhb.js +0 -158
  695. package/lib/groovy-tR4RiZnc.js +0 -161
  696. package/lib/haskell-jxVBofv5.js +0 -375
  697. package/lib/haxe-kWPI2tq3.js +0 -390
  698. package/lib/hooks-82sqkbtE.js +0 -21
  699. package/lib/http-3GIFWUlG.js +0 -45
  700. package/lib/idl-PvpMZg-l.js +0 -947
  701. package/lib/index-BSv6537G.js +0 -364
  702. package/lib/index-BoI246Ti.js +0 -507
  703. package/lib/index-ECCvmC6D.js +0 -1301
  704. package/lib/index-EI1FcaSv.js +0 -928
  705. package/lib/index-ESoQGvsE.js +0 -288
  706. package/lib/index-GOH7H2i9.js +0 -81
  707. package/lib/index-GjFRg3RJ.js +0 -8
  708. package/lib/index-GzVCh3P9.js +0 -353
  709. package/lib/index-Ls2I7eOW.js +0 -20986
  710. package/lib/index-Qcks_HSE.js +0 -984
  711. package/lib/index-RKThEh9x.js +0 -517
  712. package/lib/index-UqF8o9eD.js +0 -19665
  713. package/lib/index-_VrGF4z-.js +0 -47
  714. package/lib/index-cteyPSwp.js +0 -83
  715. package/lib/index-f0pbmfJP.js +0 -64
  716. package/lib/index-gMYRN2wV.js +0 -107
  717. package/lib/index-oszOFbwW.js +0 -1041
  718. package/lib/index-pC1MPpe2.js +0 -1744
  719. package/lib/index-q3iu4cef.js +0 -78
  720. package/lib/index-rs4SJ8Gd.js +0 -253
  721. package/lib/index-w-CiezW1.js +0 -135
  722. package/lib/index-xHADmDT3.js +0 -12
  723. package/lib/index-xa7wUurf.js +0 -8
  724. package/lib/index-xjkoF_Bn.js +0 -317
  725. package/lib/index-zNGl_CdN.js +0 -8
  726. package/lib/index-zc51oyS8.js +0 -121
  727. package/lib/index.d.ts +0 -4
  728. package/lib/index.d.ts.map +0 -1
  729. package/lib/index.es.js +0 -7
  730. package/lib/javascript-8ZHqHagw.js +0 -758
  731. package/lib/jinja2-vsOFe0qD.js +0 -154
  732. package/lib/julia-dlp_pbN1.js +0 -241
  733. package/lib/livescript-Gf5R-LT6.js +0 -273
  734. package/lib/lua-c5Y_JsBp.js +0 -221
  735. package/lib/mathematica-iiGTGmUs.js +0 -35
  736. package/lib/mbox-ZJh86H8B.js +0 -78
  737. package/lib/meta-tAGyVRPE.js +0 -511
  738. package/lib/mirc-i0qkCa0y.js +0 -73
  739. package/lib/mllike-Dy551fZW.js +0 -275
  740. package/lib/modelica-n6tGqUT9.js +0 -94
  741. package/lib/mscgen-aKSbB7D9.js +0 -104
  742. package/lib/mumps-lNiKA6sp.js +0 -25
  743. package/lib/nginx--YmuCfDj.js +0 -93
  744. package/lib/nsis-zhS8iA09.js +0 -62
  745. package/lib/ntriples-E3jQl3MC.js +0 -79
  746. package/lib/octave-EQvkGIeG.js +0 -144
  747. package/lib/oz-W2cpqFf6.js +0 -152
  748. package/lib/pascal-lCh6ouNZ.js +0 -79
  749. package/lib/perl-PxEQBX0B.js +0 -915
  750. package/lib/pig-Y_bNcrzS.js +0 -56
  751. package/lib/powershell-GaQP-TZr.js +0 -249
  752. package/lib/properties-mbRyn54L.js +0 -26
  753. package/lib/prosemirror-noTDkx-k.js +0 -4
  754. package/lib/protobuf-8CJideyJ.js +0 -49
  755. package/lib/puppet-ABBaChNZ.js +0 -45
  756. package/lib/python-sKdHg3Ka.js +0 -321
  757. package/lib/q-_1yG40Nm.js +0 -89
  758. package/lib/r-Ziz56bHT.js +0 -108
  759. package/lib/rpm-ORjGOHaQ.js +0 -57
  760. package/lib/ruby-jlbYq0dT.js +0 -233
  761. package/lib/sas-2n7xeUuO.js +0 -107
  762. package/lib/schema-ywm7RaKF.js +0 -62
  763. package/lib/scheme-XCs-NPeU.js +0 -126
  764. package/lib/shell-0_1Um7Dq.js +0 -184
  765. package/lib/sieve-7uyJD1x1.js +0 -73
  766. package/lib/simple-mode--HIzBxba.js +0 -95
  767. package/lib/smalltalk-PEFzrlQ-.js +0 -48
  768. package/lib/solr-BLBaHahN.js +0 -41
  769. package/lib/sparql-4F9ZWf1b.js +0 -204
  770. package/lib/spreadsheet-SGSo6blj.js +0 -49
  771. package/lib/sql-tebLBzN0.js +0 -291
  772. package/lib/stex-SFJcFGOO.js +0 -130
  773. package/lib/stylus-rwwWYWFm.js +0 -256
  774. package/lib/swift-eorJ0tCv.js +0 -238
  775. package/lib/tcl-IwXMB8U4.js +0 -82
  776. package/lib/textile-ok2VyjwC.js +0 -299
  777. package/lib/theme/classic/index.d.ts +0 -3
  778. package/lib/theme/classic/index.d.ts.map +0 -1
  779. package/lib/theme/classic-dark/index.d.ts +0 -3
  780. package/lib/theme/classic-dark/index.d.ts.map +0 -1
  781. package/lib/theme/headless/index.d.ts +0 -3
  782. package/lib/theme/headless/index.d.ts.map +0 -1
  783. package/lib/theme/index.d.ts +0 -8
  784. package/lib/theme/index.d.ts.map +0 -1
  785. package/lib/theme/shared.d.ts +0 -3
  786. package/lib/theme/shared.d.ts.map +0 -1
  787. package/lib/tiddlywiki-DLhz8_pc.js +0 -156
  788. package/lib/tiki-DFAqFElY.js +0 -183
  789. package/lib/tippy.esm-4ny8MQOF.js +0 -1813
  790. package/lib/toml-ryxpTZEV.js +0 -49
  791. package/lib/tooltip-plugin-NpyG8C5u.js +0 -122
  792. package/lib/troff-ZzZyvNct.js +0 -36
  793. package/lib/ttcn-6gvkqqpW.js +0 -136
  794. package/lib/ttcn-cfg-oSu-Dq5C.js +0 -98
  795. package/lib/turtle-10ofr5au.js +0 -87
  796. package/lib/utils/index.d.ts.map +0 -1
  797. package/lib/vb-a6n6fzrD.js +0 -74
  798. package/lib/vbscript-dgvo8jPt.js +0 -324
  799. package/lib/velocity-CBncCrwO.js +0 -97
  800. package/lib/verilog-KlcACt6C.js +0 -271
  801. package/lib/vhdl-NMd7Gf35.js +0 -117
  802. package/lib/webidl-z1UE5DN_.js +0 -160
  803. package/lib/xquery-hDt5jWTp.js +0 -431
  804. package/lib/yacas-ftgh_qwr.js +0 -74
  805. package/lib/z80-dA1PqWe1.js +0 -62
  806. package/src/feature/code-mirror/style.css +0 -159
  807. package/src/feature/gap-cursor/index.ts +0 -31
  808. package/src/theme/classic/index.ts +0 -12
  809. package/src/theme/classic-dark/index.ts +0 -12
  810. package/src/theme/headless/index.ts +0 -9
  811. package/src/theme/index.ts +0 -26
  812. package/src/theme/shared.ts +0 -4
  813. /package/lib/{feature → types/feature}/block-edit/handle/component.d.ts +0 -0
  814. /package/lib/{feature → types/feature}/block-edit/index.d.ts +0 -0
  815. /package/lib/{feature → types/feature}/block-edit/menu/component.d.ts +0 -0
  816. /package/lib/{feature → types/feature}/block-edit/menu/config.d.ts +0 -0
  817. /package/lib/{feature → types/feature}/block-edit/menu/icons.d.ts +0 -0
  818. /package/lib/{feature → types/feature}/block-edit/menu/index.d.ts +0 -0
  819. /package/lib/{feature/code-mirror → types/feature/image-block}/index.d.ts +0 -0
  820. /package/lib/{feature → types/feature}/link-tooltip/consts.d.ts +0 -0
  821. /package/lib/{feature/gap-cursor → types/feature/link-tooltip}/index.d.ts +0 -0
  822. /package/lib/{feature → types/feature}/list-item/consts.d.ts +0 -0
  823. /package/lib/{feature/image-block → types/feature/list-item}/index.d.ts +0 -0
  824. /package/lib/{feature → types/feature}/toolbar/component.d.ts +0 -0
  825. /package/lib/{feature → types/feature}/toolbar/consts.d.ts +0 -0
  826. /package/lib/{feature/link-tooltip → types/feature/toolbar}/index.d.ts +0 -0
  827. /package/src/{feature/placeholder/style.css → theme/common/placeholder.css} +0 -0
@@ -0,0 +1,2511 @@
1
+ import { N as NodeType, n as NodeProp, b as styleTags, t as tags, o as NodeSet, P as Parser, T as Tag, q as Tree, p as parseMixed, h as syntaxTree, m as EditorSelection, r as countColumn, a as LanguageSupport, u as Prec, v as keymap, C as CompletionContext, w as EditorState, x as Language, y as indentUnit, z as defineLanguageFacet, f as foldNodeProp, i as indentNodeProp, A as languageDataProp, B as foldService, L as LanguageDescription, D as ParseContext } from './index-q-qE7-96.js';
2
+ import { htmlCompletionSource, html } from './index-rwcSpYkt.js';
3
+ import 'atomico';
4
+ import './clsx-R7WFaNKL.js';
5
+ import './meta-3ZYGAGrY.js';
6
+ import './index-JkHHp3K-.js';
7
+ import '@milkdown/prose/history';
8
+ import '@milkdown/prose/model';
9
+ import '@milkdown/prose/keymap';
10
+ import '@milkdown/prose/commands';
11
+ import '@milkdown/prose';
12
+ import '@milkdown/prose/state';
13
+ import '@milkdown/prose/inputrules';
14
+ import '@milkdown/prose/schema-list';
15
+ import '@milkdown/prose/view';
16
+ import '@milkdown/prose/transform';
17
+ import './helper-iYEjPbOY.js';
18
+ import './composed-offset-position.browser.min-Tnm31e-m.js';
19
+ import './_view-JjtfhQ8k.js';
20
+ import './index-x-zW6gKj.js';
21
+ import './index-UBeneu17.js';
22
+ import './index-L7VXk-jT.js';
23
+
24
+ class CompositeBlock {
25
+ static create(type, value, from, parentHash, end) {
26
+ let hash = (parentHash + (parentHash << 8) + type + (value << 4)) | 0;
27
+ return new CompositeBlock(type, value, from, hash, end, [], []);
28
+ }
29
+ constructor(type,
30
+ // Used for indentation in list items, markup character in lists
31
+ value, from, hash, end, children, positions) {
32
+ this.type = type;
33
+ this.value = value;
34
+ this.from = from;
35
+ this.hash = hash;
36
+ this.end = end;
37
+ this.children = children;
38
+ this.positions = positions;
39
+ this.hashProp = [[NodeProp.contextHash, hash]];
40
+ }
41
+ addChild(child, pos) {
42
+ if (child.prop(NodeProp.contextHash) != this.hash)
43
+ child = new Tree(child.type, child.children, child.positions, child.length, this.hashProp);
44
+ this.children.push(child);
45
+ this.positions.push(pos);
46
+ }
47
+ toTree(nodeSet, end = this.end) {
48
+ let last = this.children.length - 1;
49
+ if (last >= 0)
50
+ end = Math.max(end, this.positions[last] + this.children[last].length + this.from);
51
+ return new Tree(nodeSet.types[this.type], this.children, this.positions, end - this.from).balance({
52
+ makeTree: (children, positions, length) => new Tree(NodeType.none, children, positions, length, this.hashProp)
53
+ });
54
+ }
55
+ }
56
+ var Type;
57
+ (function (Type) {
58
+ Type[Type["Document"] = 1] = "Document";
59
+ Type[Type["CodeBlock"] = 2] = "CodeBlock";
60
+ Type[Type["FencedCode"] = 3] = "FencedCode";
61
+ Type[Type["Blockquote"] = 4] = "Blockquote";
62
+ Type[Type["HorizontalRule"] = 5] = "HorizontalRule";
63
+ Type[Type["BulletList"] = 6] = "BulletList";
64
+ Type[Type["OrderedList"] = 7] = "OrderedList";
65
+ Type[Type["ListItem"] = 8] = "ListItem";
66
+ Type[Type["ATXHeading1"] = 9] = "ATXHeading1";
67
+ Type[Type["ATXHeading2"] = 10] = "ATXHeading2";
68
+ Type[Type["ATXHeading3"] = 11] = "ATXHeading3";
69
+ Type[Type["ATXHeading4"] = 12] = "ATXHeading4";
70
+ Type[Type["ATXHeading5"] = 13] = "ATXHeading5";
71
+ Type[Type["ATXHeading6"] = 14] = "ATXHeading6";
72
+ Type[Type["SetextHeading1"] = 15] = "SetextHeading1";
73
+ Type[Type["SetextHeading2"] = 16] = "SetextHeading2";
74
+ Type[Type["HTMLBlock"] = 17] = "HTMLBlock";
75
+ Type[Type["LinkReference"] = 18] = "LinkReference";
76
+ Type[Type["Paragraph"] = 19] = "Paragraph";
77
+ Type[Type["CommentBlock"] = 20] = "CommentBlock";
78
+ Type[Type["ProcessingInstructionBlock"] = 21] = "ProcessingInstructionBlock";
79
+ // Inline
80
+ Type[Type["Escape"] = 22] = "Escape";
81
+ Type[Type["Entity"] = 23] = "Entity";
82
+ Type[Type["HardBreak"] = 24] = "HardBreak";
83
+ Type[Type["Emphasis"] = 25] = "Emphasis";
84
+ Type[Type["StrongEmphasis"] = 26] = "StrongEmphasis";
85
+ Type[Type["Link"] = 27] = "Link";
86
+ Type[Type["Image"] = 28] = "Image";
87
+ Type[Type["InlineCode"] = 29] = "InlineCode";
88
+ Type[Type["HTMLTag"] = 30] = "HTMLTag";
89
+ Type[Type["Comment"] = 31] = "Comment";
90
+ Type[Type["ProcessingInstruction"] = 32] = "ProcessingInstruction";
91
+ Type[Type["URL"] = 33] = "URL";
92
+ // Smaller tokens
93
+ Type[Type["HeaderMark"] = 34] = "HeaderMark";
94
+ Type[Type["QuoteMark"] = 35] = "QuoteMark";
95
+ Type[Type["ListMark"] = 36] = "ListMark";
96
+ Type[Type["LinkMark"] = 37] = "LinkMark";
97
+ Type[Type["EmphasisMark"] = 38] = "EmphasisMark";
98
+ Type[Type["CodeMark"] = 39] = "CodeMark";
99
+ Type[Type["CodeText"] = 40] = "CodeText";
100
+ Type[Type["CodeInfo"] = 41] = "CodeInfo";
101
+ Type[Type["LinkTitle"] = 42] = "LinkTitle";
102
+ Type[Type["LinkLabel"] = 43] = "LinkLabel";
103
+ })(Type || (Type = {}));
104
+ /// Data structure used to accumulate a block's content during [leaf
105
+ /// block parsing](#BlockParser.leaf).
106
+ class LeafBlock {
107
+ /// @internal
108
+ constructor(
109
+ /// The start position of the block.
110
+ start,
111
+ /// The block's text content.
112
+ content) {
113
+ this.start = start;
114
+ this.content = content;
115
+ /// @internal
116
+ this.marks = [];
117
+ /// The block parsers active for this block.
118
+ this.parsers = [];
119
+ }
120
+ }
121
+ /// Data structure used during block-level per-line parsing.
122
+ class Line {
123
+ constructor() {
124
+ /// The line's full text.
125
+ this.text = "";
126
+ /// The base indent provided by the composite contexts (that have
127
+ /// been handled so far).
128
+ this.baseIndent = 0;
129
+ /// The string position corresponding to the base indent.
130
+ this.basePos = 0;
131
+ /// The number of contexts handled @internal
132
+ this.depth = 0;
133
+ /// Any markers (i.e. block quote markers) parsed for the contexts. @internal
134
+ this.markers = [];
135
+ /// The position of the next non-whitespace character beyond any
136
+ /// list, blockquote, or other composite block markers.
137
+ this.pos = 0;
138
+ /// The column of the next non-whitespace character.
139
+ this.indent = 0;
140
+ /// The character code of the character after `pos`.
141
+ this.next = -1;
142
+ }
143
+ /// @internal
144
+ forward() {
145
+ if (this.basePos > this.pos)
146
+ this.forwardInner();
147
+ }
148
+ /// @internal
149
+ forwardInner() {
150
+ let newPos = this.skipSpace(this.basePos);
151
+ this.indent = this.countIndent(newPos, this.pos, this.indent);
152
+ this.pos = newPos;
153
+ this.next = newPos == this.text.length ? -1 : this.text.charCodeAt(newPos);
154
+ }
155
+ /// Skip whitespace after the given position, return the position of
156
+ /// the next non-space character or the end of the line if there's
157
+ /// only space after `from`.
158
+ skipSpace(from) { return skipSpace(this.text, from); }
159
+ /// @internal
160
+ reset(text) {
161
+ this.text = text;
162
+ this.baseIndent = this.basePos = this.pos = this.indent = 0;
163
+ this.forwardInner();
164
+ this.depth = 1;
165
+ while (this.markers.length)
166
+ this.markers.pop();
167
+ }
168
+ /// Move the line's base position forward to the given position.
169
+ /// This should only be called by composite [block
170
+ /// parsers](#BlockParser.parse) or [markup skipping
171
+ /// functions](#NodeSpec.composite).
172
+ moveBase(to) {
173
+ this.basePos = to;
174
+ this.baseIndent = this.countIndent(to, this.pos, this.indent);
175
+ }
176
+ /// Move the line's base position forward to the given _column_.
177
+ moveBaseColumn(indent) {
178
+ this.baseIndent = indent;
179
+ this.basePos = this.findColumn(indent);
180
+ }
181
+ /// Store a composite-block-level marker. Should be called from
182
+ /// [markup skipping functions](#NodeSpec.composite) when they
183
+ /// consume any non-whitespace characters.
184
+ addMarker(elt) {
185
+ this.markers.push(elt);
186
+ }
187
+ /// Find the column position at `to`, optionally starting at a given
188
+ /// position and column.
189
+ countIndent(to, from = 0, indent = 0) {
190
+ for (let i = from; i < to; i++)
191
+ indent += this.text.charCodeAt(i) == 9 ? 4 - indent % 4 : 1;
192
+ return indent;
193
+ }
194
+ /// Find the position corresponding to the given column.
195
+ findColumn(goal) {
196
+ let i = 0;
197
+ for (let indent = 0; i < this.text.length && indent < goal; i++)
198
+ indent += this.text.charCodeAt(i) == 9 ? 4 - indent % 4 : 1;
199
+ return i;
200
+ }
201
+ /// @internal
202
+ scrub() {
203
+ if (!this.baseIndent)
204
+ return this.text;
205
+ let result = "";
206
+ for (let i = 0; i < this.basePos; i++)
207
+ result += " ";
208
+ return result + this.text.slice(this.basePos);
209
+ }
210
+ }
211
+ function skipForList(bl, cx, line) {
212
+ if (line.pos == line.text.length ||
213
+ (bl != cx.block && line.indent >= cx.stack[line.depth + 1].value + line.baseIndent))
214
+ return true;
215
+ if (line.indent >= line.baseIndent + 4)
216
+ return false;
217
+ let size = (bl.type == Type.OrderedList ? isOrderedList : isBulletList)(line, cx, false);
218
+ return size > 0 &&
219
+ (bl.type != Type.BulletList || isHorizontalRule(line, cx, false) < 0) &&
220
+ line.text.charCodeAt(line.pos + size - 1) == bl.value;
221
+ }
222
+ const DefaultSkipMarkup = {
223
+ [Type.Blockquote](bl, cx, line) {
224
+ if (line.next != 62 /* '>' */)
225
+ return false;
226
+ line.markers.push(elt(Type.QuoteMark, cx.lineStart + line.pos, cx.lineStart + line.pos + 1));
227
+ line.moveBase(line.pos + (space(line.text.charCodeAt(line.pos + 1)) ? 2 : 1));
228
+ bl.end = cx.lineStart + line.text.length;
229
+ return true;
230
+ },
231
+ [Type.ListItem](bl, _cx, line) {
232
+ if (line.indent < line.baseIndent + bl.value && line.next > -1)
233
+ return false;
234
+ line.moveBaseColumn(line.baseIndent + bl.value);
235
+ return true;
236
+ },
237
+ [Type.OrderedList]: skipForList,
238
+ [Type.BulletList]: skipForList,
239
+ [Type.Document]() { return true; }
240
+ };
241
+ function space(ch) { return ch == 32 || ch == 9 || ch == 10 || ch == 13; }
242
+ function skipSpace(line, i = 0) {
243
+ while (i < line.length && space(line.charCodeAt(i)))
244
+ i++;
245
+ return i;
246
+ }
247
+ function skipSpaceBack(line, i, to) {
248
+ while (i > to && space(line.charCodeAt(i - 1)))
249
+ i--;
250
+ return i;
251
+ }
252
+ function isFencedCode(line) {
253
+ if (line.next != 96 && line.next != 126 /* '`~' */)
254
+ return -1;
255
+ let pos = line.pos + 1;
256
+ while (pos < line.text.length && line.text.charCodeAt(pos) == line.next)
257
+ pos++;
258
+ if (pos < line.pos + 3)
259
+ return -1;
260
+ if (line.next == 96)
261
+ for (let i = pos; i < line.text.length; i++)
262
+ if (line.text.charCodeAt(i) == 96)
263
+ return -1;
264
+ return pos;
265
+ }
266
+ function isBlockquote(line) {
267
+ return line.next != 62 /* '>' */ ? -1 : line.text.charCodeAt(line.pos + 1) == 32 ? 2 : 1;
268
+ }
269
+ function isHorizontalRule(line, cx, breaking) {
270
+ if (line.next != 42 && line.next != 45 && line.next != 95 /* '_-*' */)
271
+ return -1;
272
+ let count = 1;
273
+ for (let pos = line.pos + 1; pos < line.text.length; pos++) {
274
+ let ch = line.text.charCodeAt(pos);
275
+ if (ch == line.next)
276
+ count++;
277
+ else if (!space(ch))
278
+ return -1;
279
+ }
280
+ // Setext headers take precedence
281
+ if (breaking && line.next == 45 && isSetextUnderline(line) > -1 && line.depth == cx.stack.length)
282
+ return -1;
283
+ return count < 3 ? -1 : 1;
284
+ }
285
+ function inList(cx, type) {
286
+ for (let i = cx.stack.length - 1; i >= 0; i--)
287
+ if (cx.stack[i].type == type)
288
+ return true;
289
+ return false;
290
+ }
291
+ function isBulletList(line, cx, breaking) {
292
+ return (line.next == 45 || line.next == 43 || line.next == 42 /* '-+*' */) &&
293
+ (line.pos == line.text.length - 1 || space(line.text.charCodeAt(line.pos + 1))) &&
294
+ (!breaking || inList(cx, Type.BulletList) || line.skipSpace(line.pos + 2) < line.text.length) ? 1 : -1;
295
+ }
296
+ function isOrderedList(line, cx, breaking) {
297
+ let pos = line.pos, next = line.next;
298
+ for (;;) {
299
+ if (next >= 48 && next <= 57 /* '0-9' */)
300
+ pos++;
301
+ else
302
+ break;
303
+ if (pos == line.text.length)
304
+ return -1;
305
+ next = line.text.charCodeAt(pos);
306
+ }
307
+ if (pos == line.pos || pos > line.pos + 9 ||
308
+ (next != 46 && next != 41 /* '.)' */) ||
309
+ (pos < line.text.length - 1 && !space(line.text.charCodeAt(pos + 1))) ||
310
+ breaking && !inList(cx, Type.OrderedList) &&
311
+ (line.skipSpace(pos + 1) == line.text.length || pos > line.pos + 1 || line.next != 49 /* '1' */))
312
+ return -1;
313
+ return pos + 1 - line.pos;
314
+ }
315
+ function isAtxHeading(line) {
316
+ if (line.next != 35 /* '#' */)
317
+ return -1;
318
+ let pos = line.pos + 1;
319
+ while (pos < line.text.length && line.text.charCodeAt(pos) == 35)
320
+ pos++;
321
+ if (pos < line.text.length && line.text.charCodeAt(pos) != 32)
322
+ return -1;
323
+ let size = pos - line.pos;
324
+ return size > 6 ? -1 : size;
325
+ }
326
+ function isSetextUnderline(line) {
327
+ if (line.next != 45 && line.next != 61 /* '-=' */ || line.indent >= line.baseIndent + 4)
328
+ return -1;
329
+ let pos = line.pos + 1;
330
+ while (pos < line.text.length && line.text.charCodeAt(pos) == line.next)
331
+ pos++;
332
+ let end = pos;
333
+ while (pos < line.text.length && space(line.text.charCodeAt(pos)))
334
+ pos++;
335
+ return pos == line.text.length ? end : -1;
336
+ }
337
+ const EmptyLine = /^[ \t]*$/, CommentEnd = /-->/, ProcessingEnd = /\?>/;
338
+ const HTMLBlockStyle = [
339
+ [/^<(?:script|pre|style)(?:\s|>|$)/i, /<\/(?:script|pre|style)>/i],
340
+ [/^\s*<!--/, CommentEnd],
341
+ [/^\s*<\?/, ProcessingEnd],
342
+ [/^\s*<![A-Z]/, />/],
343
+ [/^\s*<!\[CDATA\[/, /\]\]>/],
344
+ [/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i, EmptyLine],
345
+ [/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i, EmptyLine]
346
+ ];
347
+ function isHTMLBlock(line, _cx, breaking) {
348
+ if (line.next != 60 /* '<' */)
349
+ return -1;
350
+ let rest = line.text.slice(line.pos);
351
+ for (let i = 0, e = HTMLBlockStyle.length - (breaking ? 1 : 0); i < e; i++)
352
+ if (HTMLBlockStyle[i][0].test(rest))
353
+ return i;
354
+ return -1;
355
+ }
356
+ function getListIndent(line, pos) {
357
+ let indentAfter = line.countIndent(pos, line.pos, line.indent);
358
+ let indented = line.countIndent(line.skipSpace(pos), pos, indentAfter);
359
+ return indented >= indentAfter + 5 ? indentAfter + 1 : indented;
360
+ }
361
+ function addCodeText(marks, from, to) {
362
+ let last = marks.length - 1;
363
+ if (last >= 0 && marks[last].to == from && marks[last].type == Type.CodeText)
364
+ marks[last].to = to;
365
+ else
366
+ marks.push(elt(Type.CodeText, from, to));
367
+ }
368
+ // Rules for parsing blocks. A return value of false means the rule
369
+ // doesn't apply here, true means it does. When true is returned and
370
+ // `p.line` has been updated, the rule is assumed to have consumed a
371
+ // leaf block. Otherwise, it is assumed to have opened a context.
372
+ const DefaultBlockParsers = {
373
+ LinkReference: undefined,
374
+ IndentedCode(cx, line) {
375
+ let base = line.baseIndent + 4;
376
+ if (line.indent < base)
377
+ return false;
378
+ let start = line.findColumn(base);
379
+ let from = cx.lineStart + start, to = cx.lineStart + line.text.length;
380
+ let marks = [], pendingMarks = [];
381
+ addCodeText(marks, from, to);
382
+ while (cx.nextLine() && line.depth >= cx.stack.length) {
383
+ if (line.pos == line.text.length) { // Empty
384
+ addCodeText(pendingMarks, cx.lineStart - 1, cx.lineStart);
385
+ for (let m of line.markers)
386
+ pendingMarks.push(m);
387
+ }
388
+ else if (line.indent < base) {
389
+ break;
390
+ }
391
+ else {
392
+ if (pendingMarks.length) {
393
+ for (let m of pendingMarks) {
394
+ if (m.type == Type.CodeText)
395
+ addCodeText(marks, m.from, m.to);
396
+ else
397
+ marks.push(m);
398
+ }
399
+ pendingMarks = [];
400
+ }
401
+ addCodeText(marks, cx.lineStart - 1, cx.lineStart);
402
+ for (let m of line.markers)
403
+ marks.push(m);
404
+ to = cx.lineStart + line.text.length;
405
+ let codeStart = cx.lineStart + line.findColumn(line.baseIndent + 4);
406
+ if (codeStart < to)
407
+ addCodeText(marks, codeStart, to);
408
+ }
409
+ }
410
+ if (pendingMarks.length) {
411
+ pendingMarks = pendingMarks.filter(m => m.type != Type.CodeText);
412
+ if (pendingMarks.length)
413
+ line.markers = pendingMarks.concat(line.markers);
414
+ }
415
+ cx.addNode(cx.buffer.writeElements(marks, -from).finish(Type.CodeBlock, to - from), from);
416
+ return true;
417
+ },
418
+ FencedCode(cx, line) {
419
+ let fenceEnd = isFencedCode(line);
420
+ if (fenceEnd < 0)
421
+ return false;
422
+ let from = cx.lineStart + line.pos, ch = line.next, len = fenceEnd - line.pos;
423
+ let infoFrom = line.skipSpace(fenceEnd), infoTo = skipSpaceBack(line.text, line.text.length, infoFrom);
424
+ let marks = [elt(Type.CodeMark, from, from + len)];
425
+ if (infoFrom < infoTo)
426
+ marks.push(elt(Type.CodeInfo, cx.lineStart + infoFrom, cx.lineStart + infoTo));
427
+ for (let first = true; cx.nextLine() && line.depth >= cx.stack.length; first = false) {
428
+ let i = line.pos;
429
+ if (line.indent - line.baseIndent < 4)
430
+ while (i < line.text.length && line.text.charCodeAt(i) == ch)
431
+ i++;
432
+ if (i - line.pos >= len && line.skipSpace(i) == line.text.length) {
433
+ for (let m of line.markers)
434
+ marks.push(m);
435
+ marks.push(elt(Type.CodeMark, cx.lineStart + line.pos, cx.lineStart + i));
436
+ cx.nextLine();
437
+ break;
438
+ }
439
+ else {
440
+ if (!first)
441
+ addCodeText(marks, cx.lineStart - 1, cx.lineStart);
442
+ for (let m of line.markers)
443
+ marks.push(m);
444
+ let textStart = cx.lineStart + line.basePos, textEnd = cx.lineStart + line.text.length;
445
+ if (textStart < textEnd)
446
+ addCodeText(marks, textStart, textEnd);
447
+ }
448
+ }
449
+ cx.addNode(cx.buffer.writeElements(marks, -from)
450
+ .finish(Type.FencedCode, cx.prevLineEnd() - from), from);
451
+ return true;
452
+ },
453
+ Blockquote(cx, line) {
454
+ let size = isBlockquote(line);
455
+ if (size < 0)
456
+ return false;
457
+ cx.startContext(Type.Blockquote, line.pos);
458
+ cx.addNode(Type.QuoteMark, cx.lineStart + line.pos, cx.lineStart + line.pos + 1);
459
+ line.moveBase(line.pos + size);
460
+ return null;
461
+ },
462
+ HorizontalRule(cx, line) {
463
+ if (isHorizontalRule(line, cx, false) < 0)
464
+ return false;
465
+ let from = cx.lineStart + line.pos;
466
+ cx.nextLine();
467
+ cx.addNode(Type.HorizontalRule, from);
468
+ return true;
469
+ },
470
+ BulletList(cx, line) {
471
+ let size = isBulletList(line, cx, false);
472
+ if (size < 0)
473
+ return false;
474
+ if (cx.block.type != Type.BulletList)
475
+ cx.startContext(Type.BulletList, line.basePos, line.next);
476
+ let newBase = getListIndent(line, line.pos + 1);
477
+ cx.startContext(Type.ListItem, line.basePos, newBase - line.baseIndent);
478
+ cx.addNode(Type.ListMark, cx.lineStart + line.pos, cx.lineStart + line.pos + size);
479
+ line.moveBaseColumn(newBase);
480
+ return null;
481
+ },
482
+ OrderedList(cx, line) {
483
+ let size = isOrderedList(line, cx, false);
484
+ if (size < 0)
485
+ return false;
486
+ if (cx.block.type != Type.OrderedList)
487
+ cx.startContext(Type.OrderedList, line.basePos, line.text.charCodeAt(line.pos + size - 1));
488
+ let newBase = getListIndent(line, line.pos + size);
489
+ cx.startContext(Type.ListItem, line.basePos, newBase - line.baseIndent);
490
+ cx.addNode(Type.ListMark, cx.lineStart + line.pos, cx.lineStart + line.pos + size);
491
+ line.moveBaseColumn(newBase);
492
+ return null;
493
+ },
494
+ ATXHeading(cx, line) {
495
+ let size = isAtxHeading(line);
496
+ if (size < 0)
497
+ return false;
498
+ let off = line.pos, from = cx.lineStart + off;
499
+ let endOfSpace = skipSpaceBack(line.text, line.text.length, off), after = endOfSpace;
500
+ while (after > off && line.text.charCodeAt(after - 1) == line.next)
501
+ after--;
502
+ if (after == endOfSpace || after == off || !space(line.text.charCodeAt(after - 1)))
503
+ after = line.text.length;
504
+ let buf = cx.buffer
505
+ .write(Type.HeaderMark, 0, size)
506
+ .writeElements(cx.parser.parseInline(line.text.slice(off + size + 1, after), from + size + 1), -from);
507
+ if (after < line.text.length)
508
+ buf.write(Type.HeaderMark, after - off, endOfSpace - off);
509
+ let node = buf.finish(Type.ATXHeading1 - 1 + size, line.text.length - off);
510
+ cx.nextLine();
511
+ cx.addNode(node, from);
512
+ return true;
513
+ },
514
+ HTMLBlock(cx, line) {
515
+ let type = isHTMLBlock(line, cx, false);
516
+ if (type < 0)
517
+ return false;
518
+ let from = cx.lineStart + line.pos, end = HTMLBlockStyle[type][1];
519
+ let marks = [], trailing = end != EmptyLine;
520
+ while (!end.test(line.text) && cx.nextLine()) {
521
+ if (line.depth < cx.stack.length) {
522
+ trailing = false;
523
+ break;
524
+ }
525
+ for (let m of line.markers)
526
+ marks.push(m);
527
+ }
528
+ if (trailing)
529
+ cx.nextLine();
530
+ let nodeType = end == CommentEnd ? Type.CommentBlock : end == ProcessingEnd ? Type.ProcessingInstructionBlock : Type.HTMLBlock;
531
+ let to = cx.prevLineEnd();
532
+ cx.addNode(cx.buffer.writeElements(marks, -from).finish(nodeType, to - from), from);
533
+ return true;
534
+ },
535
+ SetextHeading: undefined // Specifies relative precedence for block-continue function
536
+ };
537
+ // This implements a state machine that incrementally parses link references. At each
538
+ // next line, it looks ahead to see if the line continues the reference or not. If it
539
+ // doesn't and a valid link is available ending before that line, it finishes that.
540
+ // Similarly, on `finish` (when the leaf is terminated by external circumstances), it
541
+ // creates a link reference if there's a valid reference up to the current point.
542
+ class LinkReferenceParser {
543
+ constructor(leaf) {
544
+ this.stage = 0 /* RefStage.Start */;
545
+ this.elts = [];
546
+ this.pos = 0;
547
+ this.start = leaf.start;
548
+ this.advance(leaf.content);
549
+ }
550
+ nextLine(cx, line, leaf) {
551
+ if (this.stage == -1 /* RefStage.Failed */)
552
+ return false;
553
+ let content = leaf.content + "\n" + line.scrub();
554
+ let finish = this.advance(content);
555
+ if (finish > -1 && finish < content.length)
556
+ return this.complete(cx, leaf, finish);
557
+ return false;
558
+ }
559
+ finish(cx, leaf) {
560
+ if ((this.stage == 2 /* RefStage.Link */ || this.stage == 3 /* RefStage.Title */) && skipSpace(leaf.content, this.pos) == leaf.content.length)
561
+ return this.complete(cx, leaf, leaf.content.length);
562
+ return false;
563
+ }
564
+ complete(cx, leaf, len) {
565
+ cx.addLeafElement(leaf, elt(Type.LinkReference, this.start, this.start + len, this.elts));
566
+ return true;
567
+ }
568
+ nextStage(elt) {
569
+ if (elt) {
570
+ this.pos = elt.to - this.start;
571
+ this.elts.push(elt);
572
+ this.stage++;
573
+ return true;
574
+ }
575
+ if (elt === false)
576
+ this.stage = -1 /* RefStage.Failed */;
577
+ return false;
578
+ }
579
+ advance(content) {
580
+ for (;;) {
581
+ if (this.stage == -1 /* RefStage.Failed */) {
582
+ return -1;
583
+ }
584
+ else if (this.stage == 0 /* RefStage.Start */) {
585
+ if (!this.nextStage(parseLinkLabel(content, this.pos, this.start, true)))
586
+ return -1;
587
+ if (content.charCodeAt(this.pos) != 58 /* ':' */)
588
+ return this.stage = -1 /* RefStage.Failed */;
589
+ this.elts.push(elt(Type.LinkMark, this.pos + this.start, this.pos + this.start + 1));
590
+ this.pos++;
591
+ }
592
+ else if (this.stage == 1 /* RefStage.Label */) {
593
+ if (!this.nextStage(parseURL(content, skipSpace(content, this.pos), this.start)))
594
+ return -1;
595
+ }
596
+ else if (this.stage == 2 /* RefStage.Link */) {
597
+ let skip = skipSpace(content, this.pos), end = 0;
598
+ if (skip > this.pos) {
599
+ let title = parseLinkTitle(content, skip, this.start);
600
+ if (title) {
601
+ let titleEnd = lineEnd(content, title.to - this.start);
602
+ if (titleEnd > 0) {
603
+ this.nextStage(title);
604
+ end = titleEnd;
605
+ }
606
+ }
607
+ }
608
+ if (!end)
609
+ end = lineEnd(content, this.pos);
610
+ return end > 0 && end < content.length ? end : -1;
611
+ }
612
+ else { // RefStage.Title
613
+ return lineEnd(content, this.pos);
614
+ }
615
+ }
616
+ }
617
+ }
618
+ function lineEnd(text, pos) {
619
+ for (; pos < text.length; pos++) {
620
+ let next = text.charCodeAt(pos);
621
+ if (next == 10)
622
+ break;
623
+ if (!space(next))
624
+ return -1;
625
+ }
626
+ return pos;
627
+ }
628
+ class SetextHeadingParser {
629
+ nextLine(cx, line, leaf) {
630
+ let underline = line.depth < cx.stack.length ? -1 : isSetextUnderline(line);
631
+ let next = line.next;
632
+ if (underline < 0)
633
+ return false;
634
+ let underlineMark = elt(Type.HeaderMark, cx.lineStart + line.pos, cx.lineStart + underline);
635
+ cx.nextLine();
636
+ cx.addLeafElement(leaf, elt(next == 61 ? Type.SetextHeading1 : Type.SetextHeading2, leaf.start, cx.prevLineEnd(), [
637
+ ...cx.parser.parseInline(leaf.content, leaf.start),
638
+ underlineMark
639
+ ]));
640
+ return true;
641
+ }
642
+ finish() {
643
+ return false;
644
+ }
645
+ }
646
+ const DefaultLeafBlocks = {
647
+ LinkReference(_, leaf) { return leaf.content.charCodeAt(0) == 91 /* '[' */ ? new LinkReferenceParser(leaf) : null; },
648
+ SetextHeading() { return new SetextHeadingParser; }
649
+ };
650
+ const DefaultEndLeaf = [
651
+ (_, line) => isAtxHeading(line) >= 0,
652
+ (_, line) => isFencedCode(line) >= 0,
653
+ (_, line) => isBlockquote(line) >= 0,
654
+ (p, line) => isBulletList(line, p, true) >= 0,
655
+ (p, line) => isOrderedList(line, p, true) >= 0,
656
+ (p, line) => isHorizontalRule(line, p, true) >= 0,
657
+ (p, line) => isHTMLBlock(line, p, true) >= 0
658
+ ];
659
+ const scanLineResult = { text: "", end: 0 };
660
+ /// Block-level parsing functions get access to this context object.
661
+ class BlockContext {
662
+ /// @internal
663
+ constructor(
664
+ /// The parser configuration used.
665
+ parser,
666
+ /// @internal
667
+ input, fragments,
668
+ /// @internal
669
+ ranges) {
670
+ this.parser = parser;
671
+ this.input = input;
672
+ this.ranges = ranges;
673
+ this.line = new Line();
674
+ this.atEnd = false;
675
+ /// For reused nodes on gaps, we can't directly put the original
676
+ /// node into the tree, since that may be bitter than its parent.
677
+ /// When this happens, we create a dummy tree that is replaced by
678
+ /// the proper node in `injectGaps` @internal
679
+ this.reusePlaceholders = new Map;
680
+ this.stoppedAt = null;
681
+ /// The range index that absoluteLineStart points into @internal
682
+ this.rangeI = 0;
683
+ this.to = ranges[ranges.length - 1].to;
684
+ this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = ranges[0].from;
685
+ this.block = CompositeBlock.create(Type.Document, 0, this.lineStart, 0, 0);
686
+ this.stack = [this.block];
687
+ this.fragments = fragments.length ? new FragmentCursor(fragments, input) : null;
688
+ this.readLine();
689
+ }
690
+ get parsedPos() {
691
+ return this.absoluteLineStart;
692
+ }
693
+ advance() {
694
+ if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt)
695
+ return this.finish();
696
+ let { line } = this;
697
+ for (;;) {
698
+ for (let markI = 0;;) {
699
+ let next = line.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
700
+ while (markI < line.markers.length && (!next || line.markers[markI].from < next.end)) {
701
+ let mark = line.markers[markI++];
702
+ this.addNode(mark.type, mark.from, mark.to);
703
+ }
704
+ if (!next)
705
+ break;
706
+ this.finishContext();
707
+ }
708
+ if (line.pos < line.text.length)
709
+ break;
710
+ // Empty line
711
+ if (!this.nextLine())
712
+ return this.finish();
713
+ }
714
+ if (this.fragments && this.reuseFragment(line.basePos))
715
+ return null;
716
+ start: for (;;) {
717
+ for (let type of this.parser.blockParsers)
718
+ if (type) {
719
+ let result = type(this, line);
720
+ if (result != false) {
721
+ if (result == true)
722
+ return null;
723
+ line.forward();
724
+ continue start;
725
+ }
726
+ }
727
+ break;
728
+ }
729
+ let leaf = new LeafBlock(this.lineStart + line.pos, line.text.slice(line.pos));
730
+ for (let parse of this.parser.leafBlockParsers)
731
+ if (parse) {
732
+ let parser = parse(this, leaf);
733
+ if (parser)
734
+ leaf.parsers.push(parser);
735
+ }
736
+ lines: while (this.nextLine()) {
737
+ if (line.pos == line.text.length)
738
+ break;
739
+ if (line.indent < line.baseIndent + 4) {
740
+ for (let stop of this.parser.endLeafBlock)
741
+ if (stop(this, line, leaf))
742
+ break lines;
743
+ }
744
+ for (let parser of leaf.parsers)
745
+ if (parser.nextLine(this, line, leaf))
746
+ return null;
747
+ leaf.content += "\n" + line.scrub();
748
+ for (let m of line.markers)
749
+ leaf.marks.push(m);
750
+ }
751
+ this.finishLeaf(leaf);
752
+ return null;
753
+ }
754
+ stopAt(pos) {
755
+ if (this.stoppedAt != null && this.stoppedAt < pos)
756
+ throw new RangeError("Can't move stoppedAt forward");
757
+ this.stoppedAt = pos;
758
+ }
759
+ reuseFragment(start) {
760
+ if (!this.fragments.moveTo(this.absoluteLineStart + start, this.absoluteLineStart) ||
761
+ !this.fragments.matches(this.block.hash))
762
+ return false;
763
+ let taken = this.fragments.takeNodes(this);
764
+ if (!taken)
765
+ return false;
766
+ this.absoluteLineStart += taken;
767
+ this.lineStart = toRelative(this.absoluteLineStart, this.ranges);
768
+ this.moveRangeI();
769
+ if (this.absoluteLineStart < this.to) {
770
+ this.lineStart++;
771
+ this.absoluteLineStart++;
772
+ this.readLine();
773
+ }
774
+ else {
775
+ this.atEnd = true;
776
+ this.readLine();
777
+ }
778
+ return true;
779
+ }
780
+ /// The number of parent blocks surrounding the current block.
781
+ get depth() {
782
+ return this.stack.length;
783
+ }
784
+ /// Get the type of the parent block at the given depth. When no
785
+ /// depth is passed, return the type of the innermost parent.
786
+ parentType(depth = this.depth - 1) {
787
+ return this.parser.nodeSet.types[this.stack[depth].type];
788
+ }
789
+ /// Move to the next input line. This should only be called by
790
+ /// (non-composite) [block parsers](#BlockParser.parse) that consume
791
+ /// the line directly, or leaf block parser
792
+ /// [`nextLine`](#LeafBlockParser.nextLine) methods when they
793
+ /// consume the current line (and return true).
794
+ nextLine() {
795
+ this.lineStart += this.line.text.length;
796
+ if (this.absoluteLineEnd >= this.to) {
797
+ this.absoluteLineStart = this.absoluteLineEnd;
798
+ this.atEnd = true;
799
+ this.readLine();
800
+ return false;
801
+ }
802
+ else {
803
+ this.lineStart++;
804
+ this.absoluteLineStart = this.absoluteLineEnd + 1;
805
+ this.moveRangeI();
806
+ this.readLine();
807
+ return true;
808
+ }
809
+ }
810
+ moveRangeI() {
811
+ while (this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to) {
812
+ this.rangeI++;
813
+ this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
814
+ }
815
+ }
816
+ /// @internal
817
+ scanLine(start) {
818
+ let r = scanLineResult;
819
+ r.end = start;
820
+ if (start >= this.to) {
821
+ r.text = "";
822
+ }
823
+ else {
824
+ r.text = this.lineChunkAt(start);
825
+ r.end += r.text.length;
826
+ if (this.ranges.length > 1) {
827
+ let textOffset = this.absoluteLineStart, rangeI = this.rangeI;
828
+ while (this.ranges[rangeI].to < r.end) {
829
+ rangeI++;
830
+ let nextFrom = this.ranges[rangeI].from;
831
+ let after = this.lineChunkAt(nextFrom);
832
+ r.end = nextFrom + after.length;
833
+ r.text = r.text.slice(0, this.ranges[rangeI - 1].to - textOffset) + after;
834
+ textOffset = r.end - r.text.length;
835
+ }
836
+ }
837
+ }
838
+ return r;
839
+ }
840
+ /// @internal
841
+ readLine() {
842
+ let { line } = this, { text, end } = this.scanLine(this.absoluteLineStart);
843
+ this.absoluteLineEnd = end;
844
+ line.reset(text);
845
+ for (; line.depth < this.stack.length; line.depth++) {
846
+ let cx = this.stack[line.depth], handler = this.parser.skipContextMarkup[cx.type];
847
+ if (!handler)
848
+ throw new Error("Unhandled block context " + Type[cx.type]);
849
+ if (!handler(cx, this, line))
850
+ break;
851
+ line.forward();
852
+ }
853
+ }
854
+ lineChunkAt(pos) {
855
+ let next = this.input.chunk(pos), text;
856
+ if (!this.input.lineChunks) {
857
+ let eol = next.indexOf("\n");
858
+ text = eol < 0 ? next : next.slice(0, eol);
859
+ }
860
+ else {
861
+ text = next == "\n" ? "" : next;
862
+ }
863
+ return pos + text.length > this.to ? text.slice(0, this.to - pos) : text;
864
+ }
865
+ /// The end position of the previous line.
866
+ prevLineEnd() { return this.atEnd ? this.lineStart : this.lineStart - 1; }
867
+ /// @internal
868
+ startContext(type, start, value = 0) {
869
+ this.block = CompositeBlock.create(type, value, this.lineStart + start, this.block.hash, this.lineStart + this.line.text.length);
870
+ this.stack.push(this.block);
871
+ }
872
+ /// Start a composite block. Should only be called from [block
873
+ /// parser functions](#BlockParser.parse) that return null.
874
+ startComposite(type, start, value = 0) {
875
+ this.startContext(this.parser.getNodeType(type), start, value);
876
+ }
877
+ /// @internal
878
+ addNode(block, from, to) {
879
+ if (typeof block == "number")
880
+ block = new Tree(this.parser.nodeSet.types[block], none, none, (to !== null && to !== void 0 ? to : this.prevLineEnd()) - from);
881
+ this.block.addChild(block, from - this.block.from);
882
+ }
883
+ /// Add a block element. Can be called by [block
884
+ /// parsers](#BlockParser.parse).
885
+ addElement(elt) {
886
+ this.block.addChild(elt.toTree(this.parser.nodeSet), elt.from - this.block.from);
887
+ }
888
+ /// Add a block element from a [leaf parser](#LeafBlockParser). This
889
+ /// makes sure any extra composite block markup (such as blockquote
890
+ /// markers) inside the block are also added to the syntax tree.
891
+ addLeafElement(leaf, elt) {
892
+ this.addNode(this.buffer
893
+ .writeElements(injectMarks(elt.children, leaf.marks), -elt.from)
894
+ .finish(elt.type, elt.to - elt.from), elt.from);
895
+ }
896
+ /// @internal
897
+ finishContext() {
898
+ let cx = this.stack.pop();
899
+ let top = this.stack[this.stack.length - 1];
900
+ top.addChild(cx.toTree(this.parser.nodeSet), cx.from - top.from);
901
+ this.block = top;
902
+ }
903
+ finish() {
904
+ while (this.stack.length > 1)
905
+ this.finishContext();
906
+ return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
907
+ }
908
+ addGaps(tree) {
909
+ return this.ranges.length > 1 ?
910
+ injectGaps(this.ranges, 0, tree.topNode, this.ranges[0].from, this.reusePlaceholders) : tree;
911
+ }
912
+ /// @internal
913
+ finishLeaf(leaf) {
914
+ for (let parser of leaf.parsers)
915
+ if (parser.finish(this, leaf))
916
+ return;
917
+ let inline = injectMarks(this.parser.parseInline(leaf.content, leaf.start), leaf.marks);
918
+ this.addNode(this.buffer
919
+ .writeElements(inline, -leaf.start)
920
+ .finish(Type.Paragraph, leaf.content.length), leaf.start);
921
+ }
922
+ elt(type, from, to, children) {
923
+ if (typeof type == "string")
924
+ return elt(this.parser.getNodeType(type), from, to, children);
925
+ return new TreeElement(type, from);
926
+ }
927
+ /// @internal
928
+ get buffer() { return new Buffer(this.parser.nodeSet); }
929
+ }
930
+ function injectGaps(ranges, rangeI, tree, offset, dummies) {
931
+ let rangeEnd = ranges[rangeI].to;
932
+ let children = [], positions = [], start = tree.from + offset;
933
+ function movePastNext(upto, inclusive) {
934
+ while (inclusive ? upto >= rangeEnd : upto > rangeEnd) {
935
+ let size = ranges[rangeI + 1].from - rangeEnd;
936
+ offset += size;
937
+ upto += size;
938
+ rangeI++;
939
+ rangeEnd = ranges[rangeI].to;
940
+ }
941
+ }
942
+ for (let ch = tree.firstChild; ch; ch = ch.nextSibling) {
943
+ movePastNext(ch.from + offset, true);
944
+ let from = ch.from + offset, node, reuse = dummies.get(ch.tree);
945
+ if (reuse) {
946
+ node = reuse;
947
+ }
948
+ else if (ch.to + offset > rangeEnd) {
949
+ node = injectGaps(ranges, rangeI, ch, offset, dummies);
950
+ movePastNext(ch.to + offset, false);
951
+ }
952
+ else {
953
+ node = ch.toTree();
954
+ }
955
+ children.push(node);
956
+ positions.push(from - start);
957
+ }
958
+ movePastNext(tree.to + offset, false);
959
+ return new Tree(tree.type, children, positions, tree.to + offset - start, tree.tree ? tree.tree.propValues : undefined);
960
+ }
961
+ /// A Markdown parser configuration.
962
+ class MarkdownParser extends Parser {
963
+ /// @internal
964
+ constructor(
965
+ /// The parser's syntax [node
966
+ /// types](https://lezer.codemirror.net/docs/ref/#common.NodeSet).
967
+ nodeSet,
968
+ /// @internal
969
+ blockParsers,
970
+ /// @internal
971
+ leafBlockParsers,
972
+ /// @internal
973
+ blockNames,
974
+ /// @internal
975
+ endLeafBlock,
976
+ /// @internal
977
+ skipContextMarkup,
978
+ /// @internal
979
+ inlineParsers,
980
+ /// @internal
981
+ inlineNames,
982
+ /// @internal
983
+ wrappers) {
984
+ super();
985
+ this.nodeSet = nodeSet;
986
+ this.blockParsers = blockParsers;
987
+ this.leafBlockParsers = leafBlockParsers;
988
+ this.blockNames = blockNames;
989
+ this.endLeafBlock = endLeafBlock;
990
+ this.skipContextMarkup = skipContextMarkup;
991
+ this.inlineParsers = inlineParsers;
992
+ this.inlineNames = inlineNames;
993
+ this.wrappers = wrappers;
994
+ /// @internal
995
+ this.nodeTypes = Object.create(null);
996
+ for (let t of nodeSet.types)
997
+ this.nodeTypes[t.name] = t.id;
998
+ }
999
+ createParse(input, fragments, ranges) {
1000
+ let parse = new BlockContext(this, input, fragments, ranges);
1001
+ for (let w of this.wrappers)
1002
+ parse = w(parse, input, fragments, ranges);
1003
+ return parse;
1004
+ }
1005
+ /// Reconfigure the parser.
1006
+ configure(spec) {
1007
+ let config = resolveConfig(spec);
1008
+ if (!config)
1009
+ return this;
1010
+ let { nodeSet, skipContextMarkup } = this;
1011
+ let blockParsers = this.blockParsers.slice(), leafBlockParsers = this.leafBlockParsers.slice(), blockNames = this.blockNames.slice(), inlineParsers = this.inlineParsers.slice(), inlineNames = this.inlineNames.slice(), endLeafBlock = this.endLeafBlock.slice(), wrappers = this.wrappers;
1012
+ if (nonEmpty(config.defineNodes)) {
1013
+ skipContextMarkup = Object.assign({}, skipContextMarkup);
1014
+ let nodeTypes = nodeSet.types.slice(), styles;
1015
+ for (let s of config.defineNodes) {
1016
+ let { name, block, composite, style } = typeof s == "string" ? { name: s } : s;
1017
+ if (nodeTypes.some(t => t.name == name))
1018
+ continue;
1019
+ if (composite)
1020
+ skipContextMarkup[nodeTypes.length] =
1021
+ (bl, cx, line) => composite(cx, line, bl.value);
1022
+ let id = nodeTypes.length;
1023
+ let group = composite ? ["Block", "BlockContext"] : !block ? undefined
1024
+ : id >= Type.ATXHeading1 && id <= Type.SetextHeading2 ? ["Block", "LeafBlock", "Heading"] : ["Block", "LeafBlock"];
1025
+ nodeTypes.push(NodeType.define({
1026
+ id,
1027
+ name,
1028
+ props: group && [[NodeProp.group, group]]
1029
+ }));
1030
+ if (style) {
1031
+ if (!styles)
1032
+ styles = {};
1033
+ if (Array.isArray(style) || style instanceof Tag)
1034
+ styles[name] = style;
1035
+ else
1036
+ Object.assign(styles, style);
1037
+ }
1038
+ }
1039
+ nodeSet = new NodeSet(nodeTypes);
1040
+ if (styles)
1041
+ nodeSet = nodeSet.extend(styleTags(styles));
1042
+ }
1043
+ if (nonEmpty(config.props))
1044
+ nodeSet = nodeSet.extend(...config.props);
1045
+ if (nonEmpty(config.remove)) {
1046
+ for (let rm of config.remove) {
1047
+ let block = this.blockNames.indexOf(rm), inline = this.inlineNames.indexOf(rm);
1048
+ if (block > -1)
1049
+ blockParsers[block] = leafBlockParsers[block] = undefined;
1050
+ if (inline > -1)
1051
+ inlineParsers[inline] = undefined;
1052
+ }
1053
+ }
1054
+ if (nonEmpty(config.parseBlock)) {
1055
+ for (let spec of config.parseBlock) {
1056
+ let found = blockNames.indexOf(spec.name);
1057
+ if (found > -1) {
1058
+ blockParsers[found] = spec.parse;
1059
+ leafBlockParsers[found] = spec.leaf;
1060
+ }
1061
+ else {
1062
+ let pos = spec.before ? findName(blockNames, spec.before)
1063
+ : spec.after ? findName(blockNames, spec.after) + 1 : blockNames.length - 1;
1064
+ blockParsers.splice(pos, 0, spec.parse);
1065
+ leafBlockParsers.splice(pos, 0, spec.leaf);
1066
+ blockNames.splice(pos, 0, spec.name);
1067
+ }
1068
+ if (spec.endLeaf)
1069
+ endLeafBlock.push(spec.endLeaf);
1070
+ }
1071
+ }
1072
+ if (nonEmpty(config.parseInline)) {
1073
+ for (let spec of config.parseInline) {
1074
+ let found = inlineNames.indexOf(spec.name);
1075
+ if (found > -1) {
1076
+ inlineParsers[found] = spec.parse;
1077
+ }
1078
+ else {
1079
+ let pos = spec.before ? findName(inlineNames, spec.before)
1080
+ : spec.after ? findName(inlineNames, spec.after) + 1 : inlineNames.length - 1;
1081
+ inlineParsers.splice(pos, 0, spec.parse);
1082
+ inlineNames.splice(pos, 0, spec.name);
1083
+ }
1084
+ }
1085
+ }
1086
+ if (config.wrap)
1087
+ wrappers = wrappers.concat(config.wrap);
1088
+ return new MarkdownParser(nodeSet, blockParsers, leafBlockParsers, blockNames, endLeafBlock, skipContextMarkup, inlineParsers, inlineNames, wrappers);
1089
+ }
1090
+ /// @internal
1091
+ getNodeType(name) {
1092
+ let found = this.nodeTypes[name];
1093
+ if (found == null)
1094
+ throw new RangeError(`Unknown node type '${name}'`);
1095
+ return found;
1096
+ }
1097
+ /// Parse the given piece of inline text at the given offset,
1098
+ /// returning an array of [`Element`](#Element) objects representing
1099
+ /// the inline content.
1100
+ parseInline(text, offset) {
1101
+ let cx = new InlineContext(this, text, offset);
1102
+ outer: for (let pos = offset; pos < cx.end;) {
1103
+ let next = cx.char(pos);
1104
+ for (let token of this.inlineParsers)
1105
+ if (token) {
1106
+ let result = token(cx, next, pos);
1107
+ if (result >= 0) {
1108
+ pos = result;
1109
+ continue outer;
1110
+ }
1111
+ }
1112
+ pos++;
1113
+ }
1114
+ return cx.resolveMarkers(0);
1115
+ }
1116
+ }
1117
+ function nonEmpty(a) {
1118
+ return a != null && a.length > 0;
1119
+ }
1120
+ function resolveConfig(spec) {
1121
+ if (!Array.isArray(spec))
1122
+ return spec;
1123
+ if (spec.length == 0)
1124
+ return null;
1125
+ let conf = resolveConfig(spec[0]);
1126
+ if (spec.length == 1)
1127
+ return conf;
1128
+ let rest = resolveConfig(spec.slice(1));
1129
+ if (!rest || !conf)
1130
+ return conf || rest;
1131
+ let conc = (a, b) => (a || none).concat(b || none);
1132
+ let wrapA = conf.wrap, wrapB = rest.wrap;
1133
+ return {
1134
+ props: conc(conf.props, rest.props),
1135
+ defineNodes: conc(conf.defineNodes, rest.defineNodes),
1136
+ parseBlock: conc(conf.parseBlock, rest.parseBlock),
1137
+ parseInline: conc(conf.parseInline, rest.parseInline),
1138
+ remove: conc(conf.remove, rest.remove),
1139
+ wrap: !wrapA ? wrapB : !wrapB ? wrapA :
1140
+ (inner, input, fragments, ranges) => wrapA(wrapB(inner, input, fragments, ranges), input, fragments, ranges)
1141
+ };
1142
+ }
1143
+ function findName(names, name) {
1144
+ let found = names.indexOf(name);
1145
+ if (found < 0)
1146
+ throw new RangeError(`Position specified relative to unknown parser ${name}`);
1147
+ return found;
1148
+ }
1149
+ let nodeTypes = [NodeType.none];
1150
+ for (let i = 1, name; name = Type[i]; i++) {
1151
+ nodeTypes[i] = NodeType.define({
1152
+ id: i,
1153
+ name,
1154
+ props: i >= Type.Escape ? [] : [[NodeProp.group, i in DefaultSkipMarkup ? ["Block", "BlockContext"] : ["Block", "LeafBlock"]]],
1155
+ top: name == "Document"
1156
+ });
1157
+ }
1158
+ const none = [];
1159
+ class Buffer {
1160
+ constructor(nodeSet) {
1161
+ this.nodeSet = nodeSet;
1162
+ this.content = [];
1163
+ this.nodes = [];
1164
+ }
1165
+ write(type, from, to, children = 0) {
1166
+ this.content.push(type, from, to, 4 + children * 4);
1167
+ return this;
1168
+ }
1169
+ writeElements(elts, offset = 0) {
1170
+ for (let e of elts)
1171
+ e.writeTo(this, offset);
1172
+ return this;
1173
+ }
1174
+ finish(type, length) {
1175
+ return Tree.build({
1176
+ buffer: this.content,
1177
+ nodeSet: this.nodeSet,
1178
+ reused: this.nodes,
1179
+ topID: type,
1180
+ length
1181
+ });
1182
+ }
1183
+ }
1184
+ /// Elements are used to compose syntax nodes during parsing.
1185
+ class Element {
1186
+ /// @internal
1187
+ constructor(
1188
+ /// The node's
1189
+ /// [id](https://lezer.codemirror.net/docs/ref/#common.NodeType.id).
1190
+ type,
1191
+ /// The start of the node, as an offset from the start of the document.
1192
+ from,
1193
+ /// The end of the node.
1194
+ to,
1195
+ /// The node's child nodes @internal
1196
+ children = none) {
1197
+ this.type = type;
1198
+ this.from = from;
1199
+ this.to = to;
1200
+ this.children = children;
1201
+ }
1202
+ /// @internal
1203
+ writeTo(buf, offset) {
1204
+ let startOff = buf.content.length;
1205
+ buf.writeElements(this.children, offset);
1206
+ buf.content.push(this.type, this.from + offset, this.to + offset, buf.content.length + 4 - startOff);
1207
+ }
1208
+ /// @internal
1209
+ toTree(nodeSet) {
1210
+ return new Buffer(nodeSet).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
1211
+ }
1212
+ }
1213
+ class TreeElement {
1214
+ constructor(tree, from) {
1215
+ this.tree = tree;
1216
+ this.from = from;
1217
+ }
1218
+ get to() { return this.from + this.tree.length; }
1219
+ get type() { return this.tree.type.id; }
1220
+ get children() { return none; }
1221
+ writeTo(buf, offset) {
1222
+ buf.nodes.push(this.tree);
1223
+ buf.content.push(buf.nodes.length - 1, this.from + offset, this.to + offset, -1);
1224
+ }
1225
+ toTree() { return this.tree; }
1226
+ }
1227
+ function elt(type, from, to, children) {
1228
+ return new Element(type, from, to, children);
1229
+ }
1230
+ const EmphasisUnderscore = { resolve: "Emphasis", mark: "EmphasisMark" };
1231
+ const EmphasisAsterisk = { resolve: "Emphasis", mark: "EmphasisMark" };
1232
+ const LinkStart = {}, ImageStart = {};
1233
+ class InlineDelimiter {
1234
+ constructor(type, from, to, side) {
1235
+ this.type = type;
1236
+ this.from = from;
1237
+ this.to = to;
1238
+ this.side = side;
1239
+ }
1240
+ }
1241
+ const Escapable = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
1242
+ let Punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
1243
+ try {
1244
+ Punctuation = new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]", "u");
1245
+ }
1246
+ catch (_) { }
1247
+ const DefaultInline = {
1248
+ Escape(cx, next, start) {
1249
+ if (next != 92 /* '\\' */ || start == cx.end - 1)
1250
+ return -1;
1251
+ let escaped = cx.char(start + 1);
1252
+ for (let i = 0; i < Escapable.length; i++)
1253
+ if (Escapable.charCodeAt(i) == escaped)
1254
+ return cx.append(elt(Type.Escape, start, start + 2));
1255
+ return -1;
1256
+ },
1257
+ Entity(cx, next, start) {
1258
+ if (next != 38 /* '&' */)
1259
+ return -1;
1260
+ let m = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(cx.slice(start + 1, start + 31));
1261
+ return m ? cx.append(elt(Type.Entity, start, start + 1 + m[0].length)) : -1;
1262
+ },
1263
+ InlineCode(cx, next, start) {
1264
+ if (next != 96 /* '`' */ || start && cx.char(start - 1) == 96)
1265
+ return -1;
1266
+ let pos = start + 1;
1267
+ while (pos < cx.end && cx.char(pos) == 96)
1268
+ pos++;
1269
+ let size = pos - start, curSize = 0;
1270
+ for (; pos < cx.end; pos++) {
1271
+ if (cx.char(pos) == 96) {
1272
+ curSize++;
1273
+ if (curSize == size && cx.char(pos + 1) != 96)
1274
+ return cx.append(elt(Type.InlineCode, start, pos + 1, [
1275
+ elt(Type.CodeMark, start, start + size),
1276
+ elt(Type.CodeMark, pos + 1 - size, pos + 1)
1277
+ ]));
1278
+ }
1279
+ else {
1280
+ curSize = 0;
1281
+ }
1282
+ }
1283
+ return -1;
1284
+ },
1285
+ HTMLTag(cx, next, start) {
1286
+ if (next != 60 /* '<' */ || start == cx.end - 1)
1287
+ return -1;
1288
+ let after = cx.slice(start + 1, cx.end);
1289
+ let url = /^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(after);
1290
+ if (url)
1291
+ return cx.append(elt(Type.URL, start, start + 1 + url[0].length));
1292
+ let comment = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(after);
1293
+ if (comment)
1294
+ return cx.append(elt(Type.Comment, start, start + 1 + comment[0].length));
1295
+ let procInst = /^\?[^]*?\?>/.exec(after);
1296
+ if (procInst)
1297
+ return cx.append(elt(Type.ProcessingInstruction, start, start + 1 + procInst[0].length));
1298
+ let m = /^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(after);
1299
+ if (!m)
1300
+ return -1;
1301
+ return cx.append(elt(Type.HTMLTag, start, start + 1 + m[0].length));
1302
+ },
1303
+ Emphasis(cx, next, start) {
1304
+ if (next != 95 && next != 42)
1305
+ return -1;
1306
+ let pos = start + 1;
1307
+ while (cx.char(pos) == next)
1308
+ pos++;
1309
+ let before = cx.slice(start - 1, start), after = cx.slice(pos, pos + 1);
1310
+ let pBefore = Punctuation.test(before), pAfter = Punctuation.test(after);
1311
+ let sBefore = /\s|^$/.test(before), sAfter = /\s|^$/.test(after);
1312
+ let leftFlanking = !sAfter && (!pAfter || sBefore || pBefore);
1313
+ let rightFlanking = !sBefore && (!pBefore || sAfter || pAfter);
1314
+ let canOpen = leftFlanking && (next == 42 || !rightFlanking || pBefore);
1315
+ let canClose = rightFlanking && (next == 42 || !leftFlanking || pAfter);
1316
+ return cx.append(new InlineDelimiter(next == 95 ? EmphasisUnderscore : EmphasisAsterisk, start, pos, (canOpen ? 1 /* Mark.Open */ : 0 /* Mark.None */) | (canClose ? 2 /* Mark.Close */ : 0 /* Mark.None */)));
1317
+ },
1318
+ HardBreak(cx, next, start) {
1319
+ if (next == 92 /* '\\' */ && cx.char(start + 1) == 10 /* '\n' */)
1320
+ return cx.append(elt(Type.HardBreak, start, start + 2));
1321
+ if (next == 32) {
1322
+ let pos = start + 1;
1323
+ while (cx.char(pos) == 32)
1324
+ pos++;
1325
+ if (cx.char(pos) == 10 && pos >= start + 2)
1326
+ return cx.append(elt(Type.HardBreak, start, pos + 1));
1327
+ }
1328
+ return -1;
1329
+ },
1330
+ Link(cx, next, start) {
1331
+ return next == 91 /* '[' */ ? cx.append(new InlineDelimiter(LinkStart, start, start + 1, 1 /* Mark.Open */)) : -1;
1332
+ },
1333
+ Image(cx, next, start) {
1334
+ return next == 33 /* '!' */ && cx.char(start + 1) == 91 /* '[' */
1335
+ ? cx.append(new InlineDelimiter(ImageStart, start, start + 2, 1 /* Mark.Open */)) : -1;
1336
+ },
1337
+ LinkEnd(cx, next, start) {
1338
+ if (next != 93 /* ']' */)
1339
+ return -1;
1340
+ // Scanning back to the next link/image start marker
1341
+ for (let i = cx.parts.length - 1; i >= 0; i--) {
1342
+ let part = cx.parts[i];
1343
+ if (part instanceof InlineDelimiter && (part.type == LinkStart || part.type == ImageStart)) {
1344
+ // If this one has been set invalid (because it would produce
1345
+ // a nested link) or there's no valid link here ignore both.
1346
+ if (!part.side || cx.skipSpace(part.to) == start && !/[(\[]/.test(cx.slice(start + 1, start + 2))) {
1347
+ cx.parts[i] = null;
1348
+ return -1;
1349
+ }
1350
+ // Finish the content and replace the entire range in
1351
+ // this.parts with the link/image node.
1352
+ let content = cx.takeContent(i);
1353
+ let link = cx.parts[i] = finishLink(cx, content, part.type == LinkStart ? Type.Link : Type.Image, part.from, start + 1);
1354
+ // Set any open-link markers before this link to invalid.
1355
+ if (part.type == LinkStart)
1356
+ for (let j = 0; j < i; j++) {
1357
+ let p = cx.parts[j];
1358
+ if (p instanceof InlineDelimiter && p.type == LinkStart)
1359
+ p.side = 0 /* Mark.None */;
1360
+ }
1361
+ return link.to;
1362
+ }
1363
+ }
1364
+ return -1;
1365
+ }
1366
+ };
1367
+ function finishLink(cx, content, type, start, startPos) {
1368
+ let { text } = cx, next = cx.char(startPos), endPos = startPos;
1369
+ content.unshift(elt(Type.LinkMark, start, start + (type == Type.Image ? 2 : 1)));
1370
+ content.push(elt(Type.LinkMark, startPos - 1, startPos));
1371
+ if (next == 40 /* '(' */) {
1372
+ let pos = cx.skipSpace(startPos + 1);
1373
+ let dest = parseURL(text, pos - cx.offset, cx.offset), title;
1374
+ if (dest) {
1375
+ pos = cx.skipSpace(dest.to);
1376
+ title = parseLinkTitle(text, pos - cx.offset, cx.offset);
1377
+ if (title)
1378
+ pos = cx.skipSpace(title.to);
1379
+ }
1380
+ if (cx.char(pos) == 41 /* ')' */) {
1381
+ content.push(elt(Type.LinkMark, startPos, startPos + 1));
1382
+ endPos = pos + 1;
1383
+ if (dest)
1384
+ content.push(dest);
1385
+ if (title)
1386
+ content.push(title);
1387
+ content.push(elt(Type.LinkMark, pos, endPos));
1388
+ }
1389
+ }
1390
+ else if (next == 91 /* '[' */) {
1391
+ let label = parseLinkLabel(text, startPos - cx.offset, cx.offset, false);
1392
+ if (label) {
1393
+ content.push(label);
1394
+ endPos = label.to;
1395
+ }
1396
+ }
1397
+ return elt(type, start, endPos, content);
1398
+ }
1399
+ // These return `null` when falling off the end of the input, `false`
1400
+ // when parsing fails otherwise (for use in the incremental link
1401
+ // reference parser).
1402
+ function parseURL(text, start, offset) {
1403
+ let next = text.charCodeAt(start);
1404
+ if (next == 60 /* '<' */) {
1405
+ for (let pos = start + 1; pos < text.length; pos++) {
1406
+ let ch = text.charCodeAt(pos);
1407
+ if (ch == 62 /* '>' */)
1408
+ return elt(Type.URL, start + offset, pos + 1 + offset);
1409
+ if (ch == 60 || ch == 10 /* '<\n' */)
1410
+ return false;
1411
+ }
1412
+ return null;
1413
+ }
1414
+ else {
1415
+ let depth = 0, pos = start;
1416
+ for (let escaped = false; pos < text.length; pos++) {
1417
+ let ch = text.charCodeAt(pos);
1418
+ if (space(ch)) {
1419
+ break;
1420
+ }
1421
+ else if (escaped) {
1422
+ escaped = false;
1423
+ }
1424
+ else if (ch == 40 /* '(' */) {
1425
+ depth++;
1426
+ }
1427
+ else if (ch == 41 /* ')' */) {
1428
+ if (!depth)
1429
+ break;
1430
+ depth--;
1431
+ }
1432
+ else if (ch == 92 /* '\\' */) {
1433
+ escaped = true;
1434
+ }
1435
+ }
1436
+ return pos > start ? elt(Type.URL, start + offset, pos + offset) : pos == text.length ? null : false;
1437
+ }
1438
+ }
1439
+ function parseLinkTitle(text, start, offset) {
1440
+ let next = text.charCodeAt(start);
1441
+ if (next != 39 && next != 34 && next != 40 /* '"\'(' */)
1442
+ return false;
1443
+ let end = next == 40 ? 41 : next;
1444
+ for (let pos = start + 1, escaped = false; pos < text.length; pos++) {
1445
+ let ch = text.charCodeAt(pos);
1446
+ if (escaped)
1447
+ escaped = false;
1448
+ else if (ch == end)
1449
+ return elt(Type.LinkTitle, start + offset, pos + 1 + offset);
1450
+ else if (ch == 92 /* '\\' */)
1451
+ escaped = true;
1452
+ }
1453
+ return null;
1454
+ }
1455
+ function parseLinkLabel(text, start, offset, requireNonWS) {
1456
+ for (let escaped = false, pos = start + 1, end = Math.min(text.length, pos + 999); pos < end; pos++) {
1457
+ let ch = text.charCodeAt(pos);
1458
+ if (escaped)
1459
+ escaped = false;
1460
+ else if (ch == 93 /* ']' */)
1461
+ return requireNonWS ? false : elt(Type.LinkLabel, start + offset, pos + 1 + offset);
1462
+ else {
1463
+ if (requireNonWS && !space(ch))
1464
+ requireNonWS = false;
1465
+ if (ch == 91 /* '[' */)
1466
+ return false;
1467
+ else if (ch == 92 /* '\\' */)
1468
+ escaped = true;
1469
+ }
1470
+ }
1471
+ return null;
1472
+ }
1473
+ /// Inline parsing functions get access to this context, and use it to
1474
+ /// read the content and emit syntax nodes.
1475
+ class InlineContext {
1476
+ /// @internal
1477
+ constructor(
1478
+ /// The parser that is being used.
1479
+ parser,
1480
+ /// The text of this inline section.
1481
+ text,
1482
+ /// The starting offset of the section in the document.
1483
+ offset) {
1484
+ this.parser = parser;
1485
+ this.text = text;
1486
+ this.offset = offset;
1487
+ /// @internal
1488
+ this.parts = [];
1489
+ }
1490
+ /// Get the character code at the given (document-relative)
1491
+ /// position.
1492
+ char(pos) { return pos >= this.end ? -1 : this.text.charCodeAt(pos - this.offset); }
1493
+ /// The position of the end of this inline section.
1494
+ get end() { return this.offset + this.text.length; }
1495
+ /// Get a substring of this inline section. Again uses
1496
+ /// document-relative positions.
1497
+ slice(from, to) { return this.text.slice(from - this.offset, to - this.offset); }
1498
+ /// @internal
1499
+ append(elt) {
1500
+ this.parts.push(elt);
1501
+ return elt.to;
1502
+ }
1503
+ /// Add a [delimiter](#DelimiterType) at this given position. `open`
1504
+ /// and `close` indicate whether this delimiter is opening, closing,
1505
+ /// or both. Returns the end of the delimiter, for convenient
1506
+ /// returning from [parse functions](#InlineParser.parse).
1507
+ addDelimiter(type, from, to, open, close) {
1508
+ return this.append(new InlineDelimiter(type, from, to, (open ? 1 /* Mark.Open */ : 0 /* Mark.None */) | (close ? 2 /* Mark.Close */ : 0 /* Mark.None */)));
1509
+ }
1510
+ /// Add an inline element. Returns the end of the element.
1511
+ addElement(elt) {
1512
+ return this.append(elt);
1513
+ }
1514
+ /// Resolve markers between this.parts.length and from, wrapping matched markers in the
1515
+ /// appropriate node and updating the content of this.parts. @internal
1516
+ resolveMarkers(from) {
1517
+ // Scan forward, looking for closing tokens
1518
+ for (let i = from; i < this.parts.length; i++) {
1519
+ let close = this.parts[i];
1520
+ if (!(close instanceof InlineDelimiter && close.type.resolve && (close.side & 2 /* Mark.Close */)))
1521
+ continue;
1522
+ let emp = close.type == EmphasisUnderscore || close.type == EmphasisAsterisk;
1523
+ let closeSize = close.to - close.from;
1524
+ let open, j = i - 1;
1525
+ // Continue scanning for a matching opening token
1526
+ for (; j >= from; j--) {
1527
+ let part = this.parts[j];
1528
+ if (part instanceof InlineDelimiter && (part.side & 1 /* Mark.Open */) && part.type == close.type &&
1529
+ // Ignore emphasis delimiters where the character count doesn't match
1530
+ !(emp && ((close.side & 1 /* Mark.Open */) || (part.side & 2 /* Mark.Close */)) &&
1531
+ (part.to - part.from + closeSize) % 3 == 0 && ((part.to - part.from) % 3 || closeSize % 3))) {
1532
+ open = part;
1533
+ break;
1534
+ }
1535
+ }
1536
+ if (!open)
1537
+ continue;
1538
+ let type = close.type.resolve, content = [];
1539
+ let start = open.from, end = close.to;
1540
+ // Emphasis marker effect depends on the character count. Size consumed is minimum of the two
1541
+ // markers.
1542
+ if (emp) {
1543
+ let size = Math.min(2, open.to - open.from, closeSize);
1544
+ start = open.to - size;
1545
+ end = close.from + size;
1546
+ type = size == 1 ? "Emphasis" : "StrongEmphasis";
1547
+ }
1548
+ // Move the covered region into content, optionally adding marker nodes
1549
+ if (open.type.mark)
1550
+ content.push(this.elt(open.type.mark, start, open.to));
1551
+ for (let k = j + 1; k < i; k++) {
1552
+ if (this.parts[k] instanceof Element)
1553
+ content.push(this.parts[k]);
1554
+ this.parts[k] = null;
1555
+ }
1556
+ if (close.type.mark)
1557
+ content.push(this.elt(close.type.mark, close.from, end));
1558
+ let element = this.elt(type, start, end, content);
1559
+ // If there are leftover emphasis marker characters, shrink the close/open markers. Otherwise, clear them.
1560
+ this.parts[j] = emp && open.from != start ? new InlineDelimiter(open.type, open.from, start, open.side) : null;
1561
+ let keep = this.parts[i] = emp && close.to != end ? new InlineDelimiter(close.type, end, close.to, close.side) : null;
1562
+ // Insert the new element in this.parts
1563
+ if (keep)
1564
+ this.parts.splice(i, 0, element);
1565
+ else
1566
+ this.parts[i] = element;
1567
+ }
1568
+ // Collect the elements remaining in this.parts into an array.
1569
+ let result = [];
1570
+ for (let i = from; i < this.parts.length; i++) {
1571
+ let part = this.parts[i];
1572
+ if (part instanceof Element)
1573
+ result.push(part);
1574
+ }
1575
+ return result;
1576
+ }
1577
+ /// Find an opening delimiter of the given type. Returns `null` if
1578
+ /// no delimiter is found, or an index that can be passed to
1579
+ /// [`takeContent`](#InlineContext.takeContent) otherwise.
1580
+ findOpeningDelimiter(type) {
1581
+ for (let i = this.parts.length - 1; i >= 0; i--) {
1582
+ let part = this.parts[i];
1583
+ if (part instanceof InlineDelimiter && part.type == type)
1584
+ return i;
1585
+ }
1586
+ return null;
1587
+ }
1588
+ /// Remove all inline elements and delimiters starting from the
1589
+ /// given index (which you should get from
1590
+ /// [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
1591
+ /// resolve delimiters inside of them, and return them as an array
1592
+ /// of elements.
1593
+ takeContent(startIndex) {
1594
+ let content = this.resolveMarkers(startIndex);
1595
+ this.parts.length = startIndex;
1596
+ return content;
1597
+ }
1598
+ /// Skip space after the given (document) position, returning either
1599
+ /// the position of the next non-space character or the end of the
1600
+ /// section.
1601
+ skipSpace(from) { return skipSpace(this.text, from - this.offset) + this.offset; }
1602
+ elt(type, from, to, children) {
1603
+ if (typeof type == "string")
1604
+ return elt(this.parser.getNodeType(type), from, to, children);
1605
+ return new TreeElement(type, from);
1606
+ }
1607
+ }
1608
+ function injectMarks(elements, marks) {
1609
+ if (!marks.length)
1610
+ return elements;
1611
+ if (!elements.length)
1612
+ return marks;
1613
+ let elts = elements.slice(), eI = 0;
1614
+ for (let mark of marks) {
1615
+ while (eI < elts.length && elts[eI].to < mark.to)
1616
+ eI++;
1617
+ if (eI < elts.length && elts[eI].from < mark.from) {
1618
+ let e = elts[eI];
1619
+ if (e instanceof Element)
1620
+ elts[eI] = new Element(e.type, e.from, e.to, injectMarks(e.children, [mark]));
1621
+ }
1622
+ else {
1623
+ elts.splice(eI++, 0, mark);
1624
+ }
1625
+ }
1626
+ return elts;
1627
+ }
1628
+ // These are blocks that can span blank lines, and should thus only be
1629
+ // reused if their next sibling is also being reused.
1630
+ const NotLast = [Type.CodeBlock, Type.ListItem, Type.OrderedList, Type.BulletList];
1631
+ class FragmentCursor {
1632
+ constructor(fragments, input) {
1633
+ this.fragments = fragments;
1634
+ this.input = input;
1635
+ // Index into fragment array
1636
+ this.i = 0;
1637
+ // Active fragment
1638
+ this.fragment = null;
1639
+ this.fragmentEnd = -1;
1640
+ // Cursor into the current fragment, if any. When `moveTo` returns
1641
+ // true, this points at the first block after `pos`.
1642
+ this.cursor = null;
1643
+ if (fragments.length)
1644
+ this.fragment = fragments[this.i++];
1645
+ }
1646
+ nextFragment() {
1647
+ this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null;
1648
+ this.cursor = null;
1649
+ this.fragmentEnd = -1;
1650
+ }
1651
+ moveTo(pos, lineStart) {
1652
+ while (this.fragment && this.fragment.to <= pos)
1653
+ this.nextFragment();
1654
+ if (!this.fragment || this.fragment.from > (pos ? pos - 1 : 0))
1655
+ return false;
1656
+ if (this.fragmentEnd < 0) {
1657
+ let end = this.fragment.to;
1658
+ while (end > 0 && this.input.read(end - 1, end) != "\n")
1659
+ end--;
1660
+ this.fragmentEnd = end ? end - 1 : 0;
1661
+ }
1662
+ let c = this.cursor;
1663
+ if (!c) {
1664
+ c = this.cursor = this.fragment.tree.cursor();
1665
+ c.firstChild();
1666
+ }
1667
+ let rPos = pos + this.fragment.offset;
1668
+ while (c.to <= rPos)
1669
+ if (!c.parent())
1670
+ return false;
1671
+ for (;;) {
1672
+ if (c.from >= rPos)
1673
+ return this.fragment.from <= lineStart;
1674
+ if (!c.childAfter(rPos))
1675
+ return false;
1676
+ }
1677
+ }
1678
+ matches(hash) {
1679
+ let tree = this.cursor.tree;
1680
+ return tree && tree.prop(NodeProp.contextHash) == hash;
1681
+ }
1682
+ takeNodes(cx) {
1683
+ let cur = this.cursor, off = this.fragment.offset, fragEnd = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0);
1684
+ let start = cx.absoluteLineStart, end = start, blockI = cx.block.children.length;
1685
+ let prevEnd = end, prevI = blockI;
1686
+ for (;;) {
1687
+ if (cur.to - off > fragEnd) {
1688
+ if (cur.type.isAnonymous && cur.firstChild())
1689
+ continue;
1690
+ break;
1691
+ }
1692
+ let pos = toRelative(cur.from - off, cx.ranges);
1693
+ if (cur.to - off <= cx.ranges[cx.rangeI].to) { // Fits in current range
1694
+ cx.addNode(cur.tree, pos);
1695
+ }
1696
+ else {
1697
+ let dummy = new Tree(cx.parser.nodeSet.types[Type.Paragraph], [], [], 0, cx.block.hashProp);
1698
+ cx.reusePlaceholders.set(dummy, cur.tree);
1699
+ cx.addNode(dummy, pos);
1700
+ }
1701
+ // Taken content must always end in a block, because incremental
1702
+ // parsing happens on block boundaries. Never stop directly
1703
+ // after an indented code block, since those can continue after
1704
+ // any number of blank lines.
1705
+ if (cur.type.is("Block")) {
1706
+ if (NotLast.indexOf(cur.type.id) < 0) {
1707
+ end = cur.to - off;
1708
+ blockI = cx.block.children.length;
1709
+ }
1710
+ else {
1711
+ end = prevEnd;
1712
+ blockI = prevI;
1713
+ prevEnd = cur.to - off;
1714
+ prevI = cx.block.children.length;
1715
+ }
1716
+ }
1717
+ if (!cur.nextSibling())
1718
+ break;
1719
+ }
1720
+ while (cx.block.children.length > blockI) {
1721
+ cx.block.children.pop();
1722
+ cx.block.positions.pop();
1723
+ }
1724
+ return end - start;
1725
+ }
1726
+ }
1727
+ // Convert an input-stream-relative position to a
1728
+ // Markdown-doc-relative position by subtracting the size of all input
1729
+ // gaps before `abs`.
1730
+ function toRelative(abs, ranges) {
1731
+ let pos = abs;
1732
+ for (let i = 1; i < ranges.length; i++) {
1733
+ let gapFrom = ranges[i - 1].to, gapTo = ranges[i].from;
1734
+ if (gapFrom < abs)
1735
+ pos -= gapTo - gapFrom;
1736
+ }
1737
+ return pos;
1738
+ }
1739
+ const markdownHighlighting = styleTags({
1740
+ "Blockquote/...": tags.quote,
1741
+ HorizontalRule: tags.contentSeparator,
1742
+ "ATXHeading1/... SetextHeading1/...": tags.heading1,
1743
+ "ATXHeading2/... SetextHeading2/...": tags.heading2,
1744
+ "ATXHeading3/...": tags.heading3,
1745
+ "ATXHeading4/...": tags.heading4,
1746
+ "ATXHeading5/...": tags.heading5,
1747
+ "ATXHeading6/...": tags.heading6,
1748
+ "Comment CommentBlock": tags.comment,
1749
+ Escape: tags.escape,
1750
+ Entity: tags.character,
1751
+ "Emphasis/...": tags.emphasis,
1752
+ "StrongEmphasis/...": tags.strong,
1753
+ "Link/... Image/...": tags.link,
1754
+ "OrderedList/... BulletList/...": tags.list,
1755
+ "BlockQuote/...": tags.quote,
1756
+ "InlineCode CodeText": tags.monospace,
1757
+ URL: tags.url,
1758
+ "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": tags.processingInstruction,
1759
+ "CodeInfo LinkLabel": tags.labelName,
1760
+ LinkTitle: tags.string,
1761
+ Paragraph: tags.content
1762
+ });
1763
+ /// The default CommonMark parser.
1764
+ const parser = new MarkdownParser(new NodeSet(nodeTypes).extend(markdownHighlighting), Object.keys(DefaultBlockParsers).map(n => DefaultBlockParsers[n]), Object.keys(DefaultBlockParsers).map(n => DefaultLeafBlocks[n]), Object.keys(DefaultBlockParsers), DefaultEndLeaf, DefaultSkipMarkup, Object.keys(DefaultInline).map(n => DefaultInline[n]), Object.keys(DefaultInline), []);
1765
+
1766
+ function leftOverSpace(node, from, to) {
1767
+ let ranges = [];
1768
+ for (let n = node.firstChild, pos = from;; n = n.nextSibling) {
1769
+ let nextPos = n ? n.from : to;
1770
+ if (nextPos > pos)
1771
+ ranges.push({ from: pos, to: nextPos });
1772
+ if (!n)
1773
+ break;
1774
+ pos = n.to;
1775
+ }
1776
+ return ranges;
1777
+ }
1778
+ /// Create a Markdown extension to enable nested parsing on code
1779
+ /// blocks and/or embedded HTML.
1780
+ function parseCode(config) {
1781
+ let { codeParser, htmlParser } = config;
1782
+ let wrap = parseMixed((node, input) => {
1783
+ let id = node.type.id;
1784
+ if (codeParser && (id == Type.CodeBlock || id == Type.FencedCode)) {
1785
+ let info = "";
1786
+ if (id == Type.FencedCode) {
1787
+ let infoNode = node.node.getChild(Type.CodeInfo);
1788
+ if (infoNode)
1789
+ info = input.read(infoNode.from, infoNode.to);
1790
+ }
1791
+ let parser = codeParser(info);
1792
+ if (parser)
1793
+ return { parser, overlay: node => node.type.id == Type.CodeText };
1794
+ }
1795
+ else if (htmlParser && (id == Type.HTMLBlock || id == Type.HTMLTag)) {
1796
+ return { parser: htmlParser, overlay: leftOverSpace(node.node, node.from, node.to) };
1797
+ }
1798
+ return null;
1799
+ });
1800
+ return { wrap };
1801
+ }
1802
+
1803
+ const StrikethroughDelim = { resolve: "Strikethrough", mark: "StrikethroughMark" };
1804
+ /// An extension that implements
1805
+ /// [GFM-style](https://github.github.com/gfm/#strikethrough-extension-)
1806
+ /// Strikethrough syntax using `~~` delimiters.
1807
+ const Strikethrough = {
1808
+ defineNodes: [{
1809
+ name: "Strikethrough",
1810
+ style: { "Strikethrough/...": tags.strikethrough }
1811
+ }, {
1812
+ name: "StrikethroughMark",
1813
+ style: tags.processingInstruction
1814
+ }],
1815
+ parseInline: [{
1816
+ name: "Strikethrough",
1817
+ parse(cx, next, pos) {
1818
+ if (next != 126 /* '~' */ || cx.char(pos + 1) != 126 || cx.char(pos + 2) == 126)
1819
+ return -1;
1820
+ let before = cx.slice(pos - 1, pos), after = cx.slice(pos + 2, pos + 3);
1821
+ let sBefore = /\s|^$/.test(before), sAfter = /\s|^$/.test(after);
1822
+ let pBefore = Punctuation.test(before), pAfter = Punctuation.test(after);
1823
+ return cx.addDelimiter(StrikethroughDelim, pos, pos + 2, !sAfter && (!pAfter || sBefore || pBefore), !sBefore && (!pBefore || sAfter || pAfter));
1824
+ },
1825
+ after: "Emphasis"
1826
+ }]
1827
+ };
1828
+ function parseRow(cx, line, startI = 0, elts, offset = 0) {
1829
+ let count = 0, first = true, cellStart = -1, cellEnd = -1, esc = false;
1830
+ let parseCell = () => {
1831
+ elts.push(cx.elt("TableCell", offset + cellStart, offset + cellEnd, cx.parser.parseInline(line.slice(cellStart, cellEnd), offset + cellStart)));
1832
+ };
1833
+ for (let i = startI; i < line.length; i++) {
1834
+ let next = line.charCodeAt(i);
1835
+ if (next == 124 /* '|' */ && !esc) {
1836
+ if (!first || cellStart > -1)
1837
+ count++;
1838
+ first = false;
1839
+ if (elts) {
1840
+ if (cellStart > -1)
1841
+ parseCell();
1842
+ elts.push(cx.elt("TableDelimiter", i + offset, i + offset + 1));
1843
+ }
1844
+ cellStart = cellEnd = -1;
1845
+ }
1846
+ else if (esc || next != 32 && next != 9) {
1847
+ if (cellStart < 0)
1848
+ cellStart = i;
1849
+ cellEnd = i + 1;
1850
+ }
1851
+ esc = !esc && next == 92;
1852
+ }
1853
+ if (cellStart > -1) {
1854
+ count++;
1855
+ if (elts)
1856
+ parseCell();
1857
+ }
1858
+ return count;
1859
+ }
1860
+ function hasPipe(str, start) {
1861
+ for (let i = start; i < str.length; i++) {
1862
+ let next = str.charCodeAt(i);
1863
+ if (next == 124 /* '|' */)
1864
+ return true;
1865
+ if (next == 92 /* '\\' */)
1866
+ i++;
1867
+ }
1868
+ return false;
1869
+ }
1870
+ const delimiterLine = /^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;
1871
+ class TableParser {
1872
+ constructor() {
1873
+ // Null means we haven't seen the second line yet, false means this
1874
+ // isn't a table, and an array means this is a table and we've
1875
+ // parsed the given rows so far.
1876
+ this.rows = null;
1877
+ }
1878
+ nextLine(cx, line, leaf) {
1879
+ if (this.rows == null) { // Second line
1880
+ this.rows = false;
1881
+ let lineText;
1882
+ if ((line.next == 45 || line.next == 58 || line.next == 124 /* '-:|' */) &&
1883
+ delimiterLine.test(lineText = line.text.slice(line.pos))) {
1884
+ let firstRow = [], firstCount = parseRow(cx, leaf.content, 0, firstRow, leaf.start);
1885
+ if (firstCount == parseRow(cx, lineText, line.pos))
1886
+ this.rows = [cx.elt("TableHeader", leaf.start, leaf.start + leaf.content.length, firstRow),
1887
+ cx.elt("TableDelimiter", cx.lineStart + line.pos, cx.lineStart + line.text.length)];
1888
+ }
1889
+ }
1890
+ else if (this.rows) { // Line after the second
1891
+ let content = [];
1892
+ parseRow(cx, line.text, line.pos, content, cx.lineStart);
1893
+ this.rows.push(cx.elt("TableRow", cx.lineStart + line.pos, cx.lineStart + line.text.length, content));
1894
+ }
1895
+ return false;
1896
+ }
1897
+ finish(cx, leaf) {
1898
+ if (!this.rows)
1899
+ return false;
1900
+ cx.addLeafElement(leaf, cx.elt("Table", leaf.start, leaf.start + leaf.content.length, this.rows));
1901
+ return true;
1902
+ }
1903
+ }
1904
+ /// This extension provides
1905
+ /// [GFM-style](https://github.github.com/gfm/#tables-extension-)
1906
+ /// tables, using syntax like this:
1907
+ ///
1908
+ /// ```
1909
+ /// | head 1 | head 2 |
1910
+ /// | --- | --- |
1911
+ /// | cell 1 | cell 2 |
1912
+ /// ```
1913
+ const Table = {
1914
+ defineNodes: [
1915
+ { name: "Table", block: true },
1916
+ { name: "TableHeader", style: { "TableHeader/...": tags.heading } },
1917
+ "TableRow",
1918
+ { name: "TableCell", style: tags.content },
1919
+ { name: "TableDelimiter", style: tags.processingInstruction },
1920
+ ],
1921
+ parseBlock: [{
1922
+ name: "Table",
1923
+ leaf(_, leaf) { return hasPipe(leaf.content, 0) ? new TableParser : null; },
1924
+ endLeaf(cx, line, leaf) {
1925
+ if (leaf.parsers.some(p => p instanceof TableParser) || !hasPipe(line.text, line.basePos))
1926
+ return false;
1927
+ let next = cx.scanLine(cx.absoluteLineEnd + 1).text;
1928
+ return delimiterLine.test(next) && parseRow(cx, line.text, line.basePos) == parseRow(cx, next, line.basePos);
1929
+ },
1930
+ before: "SetextHeading"
1931
+ }]
1932
+ };
1933
+ class TaskParser {
1934
+ nextLine() { return false; }
1935
+ finish(cx, leaf) {
1936
+ cx.addLeafElement(leaf, cx.elt("Task", leaf.start, leaf.start + leaf.content.length, [
1937
+ cx.elt("TaskMarker", leaf.start, leaf.start + 3),
1938
+ ...cx.parser.parseInline(leaf.content.slice(3), leaf.start + 3)
1939
+ ]));
1940
+ return true;
1941
+ }
1942
+ }
1943
+ /// Extension providing
1944
+ /// [GFM-style](https://github.github.com/gfm/#task-list-items-extension-)
1945
+ /// task list items, where list items can be prefixed with `[ ]` or
1946
+ /// `[x]` to add a checkbox.
1947
+ const TaskList = {
1948
+ defineNodes: [
1949
+ { name: "Task", block: true, style: tags.list },
1950
+ { name: "TaskMarker", style: tags.atom }
1951
+ ],
1952
+ parseBlock: [{
1953
+ name: "TaskList",
1954
+ leaf(cx, leaf) {
1955
+ return /^\[[ xX]\][ \t]/.test(leaf.content) && cx.parentType().name == "ListItem" ? new TaskParser : null;
1956
+ },
1957
+ after: "SetextHeading"
1958
+ }]
1959
+ };
1960
+ const autolinkRE = /(www\.)|(https?:\/\/)|([\w.+-]+@)|(mailto:|xmpp:)/gy;
1961
+ const urlRE = /[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy;
1962
+ const lastTwoDomainWords = /[\w-]+\.[\w-]+($|\/)/;
1963
+ const emailRE = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy;
1964
+ const xmppResourceRE = /\/[a-zA-Z\d@.]+/gy;
1965
+ function count(str, from, to, ch) {
1966
+ let result = 0;
1967
+ for (let i = from; i < to; i++)
1968
+ if (str[i] == ch)
1969
+ result++;
1970
+ return result;
1971
+ }
1972
+ function autolinkURLEnd(text, from) {
1973
+ urlRE.lastIndex = from;
1974
+ let m = urlRE.exec(text);
1975
+ if (!m || lastTwoDomainWords.exec(m[0])[0].indexOf("_") > -1)
1976
+ return -1;
1977
+ let end = from + m[0].length;
1978
+ for (;;) {
1979
+ let last = text[end - 1], m;
1980
+ if (/[?!.,:*_~]/.test(last) ||
1981
+ last == ")" && count(text, from, end, ")") > count(text, from, end, "("))
1982
+ end--;
1983
+ else if (last == ";" && (m = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(text.slice(from, end))))
1984
+ end = from + m.index;
1985
+ else
1986
+ break;
1987
+ }
1988
+ return end;
1989
+ }
1990
+ function autolinkEmailEnd(text, from) {
1991
+ emailRE.lastIndex = from;
1992
+ let m = emailRE.exec(text);
1993
+ if (!m)
1994
+ return -1;
1995
+ let last = m[0][m[0].length - 1];
1996
+ return last == "_" || last == "-" ? -1 : from + m[0].length - (last == "." ? 1 : 0);
1997
+ }
1998
+ /// Extension that implements autolinking for
1999
+ /// `www.`/`http://`/`https://`/`mailto:`/`xmpp:` URLs and email
2000
+ /// addresses.
2001
+ const Autolink = {
2002
+ parseInline: [{
2003
+ name: "Autolink",
2004
+ parse(cx, next, absPos) {
2005
+ let pos = absPos - cx.offset;
2006
+ autolinkRE.lastIndex = pos;
2007
+ let m = autolinkRE.exec(cx.text), end = -1;
2008
+ if (!m)
2009
+ return -1;
2010
+ if (m[1] || m[2]) { // www., http://
2011
+ end = autolinkURLEnd(cx.text, pos + m[0].length);
2012
+ }
2013
+ else if (m[3]) { // email address
2014
+ end = autolinkEmailEnd(cx.text, pos);
2015
+ }
2016
+ else { // mailto:/xmpp:
2017
+ end = autolinkEmailEnd(cx.text, pos + m[0].length);
2018
+ if (end > -1 && m[0] == "xmpp:") {
2019
+ xmppResourceRE.lastIndex = end;
2020
+ m = xmppResourceRE.exec(cx.text);
2021
+ if (m)
2022
+ end = m.index + m[0].length;
2023
+ }
2024
+ }
2025
+ if (end < 0)
2026
+ return -1;
2027
+ cx.addElement(cx.elt("URL", absPos, end + cx.offset));
2028
+ return end + cx.offset;
2029
+ }
2030
+ }]
2031
+ };
2032
+ /// Extension bundle containing [`Table`](#Table),
2033
+ /// [`TaskList`](#TaskList), [`Strikethrough`](#Strikethrough), and
2034
+ /// [`Autolink`](#Autolink).
2035
+ const GFM = [Table, TaskList, Strikethrough, Autolink];
2036
+ function parseSubSuper(ch, node, mark) {
2037
+ return (cx, next, pos) => {
2038
+ if (next != ch || cx.char(pos + 1) == ch)
2039
+ return -1;
2040
+ let elts = [cx.elt(mark, pos, pos + 1)];
2041
+ for (let i = pos + 1; i < cx.end; i++) {
2042
+ let next = cx.char(i);
2043
+ if (next == ch)
2044
+ return cx.addElement(cx.elt(node, pos, i + 1, elts.concat(cx.elt(mark, i, i + 1))));
2045
+ if (next == 92 /* '\\' */)
2046
+ elts.push(cx.elt("Escape", i, i++ + 2));
2047
+ if (space(next))
2048
+ break;
2049
+ }
2050
+ return -1;
2051
+ };
2052
+ }
2053
+ /// Extension providing
2054
+ /// [Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
2055
+ /// superscript using `^` markers.
2056
+ const Superscript = {
2057
+ defineNodes: [
2058
+ { name: "Superscript", style: tags.special(tags.content) },
2059
+ { name: "SuperscriptMark", style: tags.processingInstruction }
2060
+ ],
2061
+ parseInline: [{
2062
+ name: "Superscript",
2063
+ parse: parseSubSuper(94 /* '^' */, "Superscript", "SuperscriptMark")
2064
+ }]
2065
+ };
2066
+ /// Extension providing
2067
+ /// [Pandoc-style](https://pandoc.org/MANUAL.html#superscripts-and-subscripts)
2068
+ /// subscript using `~` markers.
2069
+ const Subscript = {
2070
+ defineNodes: [
2071
+ { name: "Subscript", style: tags.special(tags.content) },
2072
+ { name: "SubscriptMark", style: tags.processingInstruction }
2073
+ ],
2074
+ parseInline: [{
2075
+ name: "Subscript",
2076
+ parse: parseSubSuper(126 /* '~' */, "Subscript", "SubscriptMark")
2077
+ }]
2078
+ };
2079
+ /// Extension that parses two colons with only letters, underscores,
2080
+ /// and numbers between them as `Emoji` nodes.
2081
+ const Emoji = {
2082
+ defineNodes: [{ name: "Emoji", style: tags.character }],
2083
+ parseInline: [{
2084
+ name: "Emoji",
2085
+ parse(cx, next, pos) {
2086
+ let match;
2087
+ if (next != 58 /* ':' */ || !(match = /^[a-zA-Z_0-9]+:/.exec(cx.slice(pos + 1, cx.end))))
2088
+ return -1;
2089
+ return cx.addElement(cx.elt("Emoji", pos, pos + 1 + match[0].length));
2090
+ }
2091
+ }]
2092
+ };
2093
+
2094
+ const data = /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "<!--", close: "-->" } } });
2095
+ const headingProp = /*@__PURE__*/new NodeProp();
2096
+ const commonmark = /*@__PURE__*/parser.configure({
2097
+ props: [
2098
+ /*@__PURE__*/foldNodeProp.add(type => {
2099
+ return !type.is("Block") || type.is("Document") || isHeading(type) != null ? undefined
2100
+ : (tree, state) => ({ from: state.doc.lineAt(tree.from).to, to: tree.to });
2101
+ }),
2102
+ /*@__PURE__*/headingProp.add(isHeading),
2103
+ /*@__PURE__*/indentNodeProp.add({
2104
+ Document: () => null
2105
+ }),
2106
+ /*@__PURE__*/languageDataProp.add({
2107
+ Document: data
2108
+ })
2109
+ ]
2110
+ });
2111
+ function isHeading(type) {
2112
+ let match = /^(?:ATX|Setext)Heading(\d)$/.exec(type.name);
2113
+ return match ? +match[1] : undefined;
2114
+ }
2115
+ function findSectionEnd(headerNode, level) {
2116
+ let last = headerNode;
2117
+ for (;;) {
2118
+ let next = last.nextSibling, heading;
2119
+ if (!next || (heading = isHeading(next.type)) != null && heading <= level)
2120
+ break;
2121
+ last = next;
2122
+ }
2123
+ return last.to;
2124
+ }
2125
+ const headerIndent = /*@__PURE__*/foldService.of((state, start, end) => {
2126
+ for (let node = syntaxTree(state).resolveInner(end, -1); node; node = node.parent) {
2127
+ if (node.from < start)
2128
+ break;
2129
+ let heading = node.type.prop(headingProp);
2130
+ if (heading == null)
2131
+ continue;
2132
+ let upto = findSectionEnd(node, heading);
2133
+ if (upto > end)
2134
+ return { from: end, to: upto };
2135
+ }
2136
+ return null;
2137
+ });
2138
+ function mkLang(parser) {
2139
+ return new Language(data, parser, [headerIndent], "markdown");
2140
+ }
2141
+ /**
2142
+ Language support for strict CommonMark.
2143
+ */
2144
+ const commonmarkLanguage = /*@__PURE__*/mkLang(commonmark);
2145
+ const extended = /*@__PURE__*/commonmark.configure([GFM, Subscript, Superscript, Emoji, {
2146
+ props: [
2147
+ /*@__PURE__*/foldNodeProp.add({
2148
+ Table: (tree, state) => ({ from: state.doc.lineAt(tree.from).to, to: tree.to })
2149
+ })
2150
+ ]
2151
+ }]);
2152
+ /**
2153
+ Language support for [GFM](https://github.github.com/gfm/) plus
2154
+ subscript, superscript, and emoji syntax.
2155
+ */
2156
+ const markdownLanguage = /*@__PURE__*/mkLang(extended);
2157
+ function getCodeParser(languages, defaultLanguage) {
2158
+ return (info) => {
2159
+ if (info && languages) {
2160
+ let found = null;
2161
+ // Strip anything after whitespace
2162
+ info = /\S*/.exec(info)[0];
2163
+ if (typeof languages == "function")
2164
+ found = languages(info);
2165
+ else
2166
+ found = LanguageDescription.matchLanguageName(languages, info, true);
2167
+ if (found instanceof LanguageDescription)
2168
+ return found.support ? found.support.language.parser : ParseContext.getSkippingParser(found.load());
2169
+ else if (found)
2170
+ return found.parser;
2171
+ }
2172
+ return defaultLanguage ? defaultLanguage.parser : null;
2173
+ };
2174
+ }
2175
+
2176
+ class Context {
2177
+ constructor(node, from, to, spaceBefore, spaceAfter, type, item) {
2178
+ this.node = node;
2179
+ this.from = from;
2180
+ this.to = to;
2181
+ this.spaceBefore = spaceBefore;
2182
+ this.spaceAfter = spaceAfter;
2183
+ this.type = type;
2184
+ this.item = item;
2185
+ }
2186
+ blank(maxWidth, trailing = true) {
2187
+ let result = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : "");
2188
+ if (maxWidth != null) {
2189
+ while (result.length < maxWidth)
2190
+ result += " ";
2191
+ return result;
2192
+ }
2193
+ else {
2194
+ for (let i = this.to - this.from - result.length - this.spaceAfter.length; i > 0; i--)
2195
+ result += " ";
2196
+ return result + (trailing ? this.spaceAfter : "");
2197
+ }
2198
+ }
2199
+ marker(doc, add) {
2200
+ let number = this.node.name == "OrderedList" ? String((+itemNumber(this.item, doc)[2] + add)) : "";
2201
+ return this.spaceBefore + number + this.type + this.spaceAfter;
2202
+ }
2203
+ }
2204
+ function getContext(node, doc) {
2205
+ let nodes = [];
2206
+ for (let cur = node; cur && cur.name != "Document"; cur = cur.parent) {
2207
+ if (cur.name == "ListItem" || cur.name == "Blockquote" || cur.name == "FencedCode")
2208
+ nodes.push(cur);
2209
+ }
2210
+ let context = [];
2211
+ for (let i = nodes.length - 1; i >= 0; i--) {
2212
+ let node = nodes[i], match;
2213
+ let line = doc.lineAt(node.from), startPos = node.from - line.from;
2214
+ if (node.name == "FencedCode") {
2215
+ context.push(new Context(node, startPos, startPos, "", "", "", null));
2216
+ }
2217
+ else if (node.name == "Blockquote" && (match = /^ *>( ?)/.exec(line.text.slice(startPos)))) {
2218
+ context.push(new Context(node, startPos, startPos + match[0].length, "", match[1], ">", null));
2219
+ }
2220
+ else if (node.name == "ListItem" && node.parent.name == "OrderedList" &&
2221
+ (match = /^( *)\d+([.)])( *)/.exec(line.text.slice(startPos)))) {
2222
+ let after = match[3], len = match[0].length;
2223
+ if (after.length >= 4) {
2224
+ after = after.slice(0, after.length - 4);
2225
+ len -= 4;
2226
+ }
2227
+ context.push(new Context(node.parent, startPos, startPos + len, match[1], after, match[2], node));
2228
+ }
2229
+ else if (node.name == "ListItem" && node.parent.name == "BulletList" &&
2230
+ (match = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(line.text.slice(startPos)))) {
2231
+ let after = match[4], len = match[0].length;
2232
+ if (after.length > 4) {
2233
+ after = after.slice(0, after.length - 4);
2234
+ len -= 4;
2235
+ }
2236
+ let type = match[2];
2237
+ if (match[3])
2238
+ type += match[3].replace(/[xX]/, ' ');
2239
+ context.push(new Context(node.parent, startPos, startPos + len, match[1], after, type, node));
2240
+ }
2241
+ }
2242
+ return context;
2243
+ }
2244
+ function itemNumber(item, doc) {
2245
+ return /^(\s*)(\d+)(?=[.)])/.exec(doc.sliceString(item.from, item.from + 10));
2246
+ }
2247
+ function renumberList(after, doc, changes, offset = 0) {
2248
+ for (let prev = -1, node = after;;) {
2249
+ if (node.name == "ListItem") {
2250
+ let m = itemNumber(node, doc);
2251
+ let number = +m[2];
2252
+ if (prev >= 0) {
2253
+ if (number != prev + 1)
2254
+ return;
2255
+ changes.push({ from: node.from + m[1].length, to: node.from + m[0].length, insert: String(prev + 2 + offset) });
2256
+ }
2257
+ prev = number;
2258
+ }
2259
+ let next = node.nextSibling;
2260
+ if (!next)
2261
+ break;
2262
+ node = next;
2263
+ }
2264
+ }
2265
+ function normalizeIndent(content, state) {
2266
+ let blank = /^[ \t]*/.exec(content)[0].length;
2267
+ if (!blank || state.facet(indentUnit) != "\t")
2268
+ return content;
2269
+ let col = countColumn(content, 4, blank);
2270
+ let space = "";
2271
+ for (let i = col; i > 0;) {
2272
+ if (i >= 4) {
2273
+ space += "\t";
2274
+ i -= 4;
2275
+ }
2276
+ else {
2277
+ space += " ";
2278
+ i--;
2279
+ }
2280
+ }
2281
+ return space + content.slice(blank);
2282
+ }
2283
+ /**
2284
+ This command, when invoked in Markdown context with cursor
2285
+ selection(s), will create a new line with the markup for
2286
+ blockquotes and lists that were active on the old line. If the
2287
+ cursor was directly after the end of the markup for the old line,
2288
+ trailing whitespace and list markers are removed from that line.
2289
+
2290
+ The command does nothing in non-Markdown context, so it should
2291
+ not be used as the only binding for Enter (even in a Markdown
2292
+ document, HTML and code regions might use a different language).
2293
+ */
2294
+ const insertNewlineContinueMarkup = ({ state, dispatch }) => {
2295
+ let tree = syntaxTree(state), { doc } = state;
2296
+ let dont = null, changes = state.changeByRange(range => {
2297
+ if (!range.empty || !markdownLanguage.isActiveAt(state, range.from))
2298
+ return dont = { range };
2299
+ let pos = range.from, line = doc.lineAt(pos);
2300
+ let context = getContext(tree.resolveInner(pos, -1), doc);
2301
+ while (context.length && context[context.length - 1].from > pos - line.from)
2302
+ context.pop();
2303
+ if (!context.length)
2304
+ return dont = { range };
2305
+ let inner = context[context.length - 1];
2306
+ if (inner.to - inner.spaceAfter.length > pos - line.from)
2307
+ return dont = { range };
2308
+ let emptyLine = pos >= (inner.to - inner.spaceAfter.length) && !/\S/.test(line.text.slice(inner.to));
2309
+ // Empty line in list
2310
+ if (inner.item && emptyLine) {
2311
+ // First list item or blank line before: delete a level of markup
2312
+ if (inner.node.firstChild.to >= pos ||
2313
+ line.from > 0 && !/[^\s>]/.test(doc.lineAt(line.from - 1).text)) {
2314
+ let next = context.length > 1 ? context[context.length - 2] : null;
2315
+ let delTo, insert = "";
2316
+ if (next && next.item) { // Re-add marker for the list at the next level
2317
+ delTo = line.from + next.from;
2318
+ insert = next.marker(doc, 1);
2319
+ }
2320
+ else {
2321
+ delTo = line.from + (next ? next.to : 0);
2322
+ }
2323
+ let changes = [{ from: delTo, to: pos, insert }];
2324
+ if (inner.node.name == "OrderedList")
2325
+ renumberList(inner.item, doc, changes, -2);
2326
+ if (next && next.node.name == "OrderedList")
2327
+ renumberList(next.item, doc, changes);
2328
+ return { range: EditorSelection.cursor(delTo + insert.length), changes };
2329
+ }
2330
+ else { // Move this line down
2331
+ let insert = "";
2332
+ for (let i = 0, e = context.length - 2; i <= e; i++) {
2333
+ insert += context[i].blank(i < e ? countColumn(line.text, 4, context[i + 1].from) - insert.length : null, i < e);
2334
+ }
2335
+ insert = normalizeIndent(insert, state);
2336
+ return { range: EditorSelection.cursor(pos + insert.length + 1),
2337
+ changes: { from: line.from, insert: insert + state.lineBreak } };
2338
+ }
2339
+ }
2340
+ if (inner.node.name == "Blockquote" && emptyLine && line.from) {
2341
+ let prevLine = doc.lineAt(line.from - 1), quoted = />\s*$/.exec(prevLine.text);
2342
+ // Two aligned empty quoted lines in a row
2343
+ if (quoted && quoted.index == inner.from) {
2344
+ let changes = state.changes([{ from: prevLine.from + quoted.index, to: prevLine.to },
2345
+ { from: line.from + inner.from, to: line.to }]);
2346
+ return { range: range.map(changes), changes };
2347
+ }
2348
+ }
2349
+ let changes = [];
2350
+ if (inner.node.name == "OrderedList")
2351
+ renumberList(inner.item, doc, changes);
2352
+ let continued = inner.item && inner.item.from < line.from;
2353
+ let insert = "";
2354
+ // If not dedented
2355
+ if (!continued || /^[\s\d.)\-+*>]*/.exec(line.text)[0].length >= inner.to) {
2356
+ for (let i = 0, e = context.length - 1; i <= e; i++) {
2357
+ insert += i == e && !continued ? context[i].marker(doc, 1)
2358
+ : context[i].blank(i < e ? countColumn(line.text, 4, context[i + 1].from) - insert.length : null);
2359
+ }
2360
+ }
2361
+ let from = pos;
2362
+ while (from > line.from && /\s/.test(line.text.charAt(from - line.from - 1)))
2363
+ from--;
2364
+ insert = normalizeIndent(insert, state);
2365
+ changes.push({ from, to: pos, insert: state.lineBreak + insert });
2366
+ return { range: EditorSelection.cursor(from + insert.length + 1), changes };
2367
+ });
2368
+ if (dont)
2369
+ return false;
2370
+ dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
2371
+ return true;
2372
+ };
2373
+ function isMark(node) {
2374
+ return node.name == "QuoteMark" || node.name == "ListMark";
2375
+ }
2376
+ function contextNodeForDelete(tree, pos) {
2377
+ let node = tree.resolveInner(pos, -1), scan = pos;
2378
+ if (isMark(node)) {
2379
+ scan = node.from;
2380
+ node = node.parent;
2381
+ }
2382
+ for (let prev; prev = node.childBefore(scan);) {
2383
+ if (isMark(prev)) {
2384
+ scan = prev.from;
2385
+ }
2386
+ else if (prev.name == "OrderedList" || prev.name == "BulletList") {
2387
+ node = prev.lastChild;
2388
+ scan = node.to;
2389
+ }
2390
+ else {
2391
+ break;
2392
+ }
2393
+ }
2394
+ return node;
2395
+ }
2396
+ /**
2397
+ This command will, when invoked in a Markdown context with the
2398
+ cursor directly after list or blockquote markup, delete one level
2399
+ of markup. When the markup is for a list, it will be replaced by
2400
+ spaces on the first invocation (a further invocation will delete
2401
+ the spaces), to make it easy to continue a list.
2402
+
2403
+ When not after Markdown block markup, this command will return
2404
+ false, so it is intended to be bound alongside other deletion
2405
+ commands, with a higher precedence than the more generic commands.
2406
+ */
2407
+ const deleteMarkupBackward = ({ state, dispatch }) => {
2408
+ let tree = syntaxTree(state);
2409
+ let dont = null, changes = state.changeByRange(range => {
2410
+ let pos = range.from, { doc } = state;
2411
+ if (range.empty && markdownLanguage.isActiveAt(state, range.from)) {
2412
+ let line = doc.lineAt(pos);
2413
+ let context = getContext(contextNodeForDelete(tree, pos), doc);
2414
+ if (context.length) {
2415
+ let inner = context[context.length - 1];
2416
+ let spaceEnd = inner.to - inner.spaceAfter.length + (inner.spaceAfter ? 1 : 0);
2417
+ // Delete extra trailing space after markup
2418
+ if (pos - line.from > spaceEnd && !/\S/.test(line.text.slice(spaceEnd, pos - line.from)))
2419
+ return { range: EditorSelection.cursor(line.from + spaceEnd),
2420
+ changes: { from: line.from + spaceEnd, to: pos } };
2421
+ if (pos - line.from == spaceEnd &&
2422
+ // Only apply this if we're on the line that has the
2423
+ // construct's syntax, or there's only indentation in the
2424
+ // target range
2425
+ (!inner.item || line.from <= inner.item.from || !/\S/.test(line.text.slice(0, inner.to)))) {
2426
+ let start = line.from + inner.from;
2427
+ // Replace a list item marker with blank space
2428
+ if (inner.item && inner.node.from < inner.item.from && /\S/.test(line.text.slice(inner.from, inner.to))) {
2429
+ let insert = inner.blank(countColumn(line.text, 4, inner.to) - countColumn(line.text, 4, inner.from));
2430
+ if (start == line.from)
2431
+ insert = normalizeIndent(insert, state);
2432
+ return { range: EditorSelection.cursor(start + insert.length),
2433
+ changes: { from: start, to: line.from + inner.to, insert } };
2434
+ }
2435
+ // Delete one level of indentation
2436
+ if (start < pos)
2437
+ return { range: EditorSelection.cursor(start), changes: { from: start, to: pos } };
2438
+ }
2439
+ }
2440
+ }
2441
+ return dont = { range };
2442
+ });
2443
+ if (dont)
2444
+ return false;
2445
+ dispatch(state.update(changes, { scrollIntoView: true, userEvent: "delete" }));
2446
+ return true;
2447
+ };
2448
+
2449
+ /**
2450
+ A small keymap with Markdown-specific bindings. Binds Enter to
2451
+ [`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup)
2452
+ and Backspace to
2453
+ [`deleteMarkupBackward`](https://codemirror.net/6/docs/ref/#lang-markdown.deleteMarkupBackward).
2454
+ */
2455
+ const markdownKeymap = [
2456
+ { key: "Enter", run: insertNewlineContinueMarkup },
2457
+ { key: "Backspace", run: deleteMarkupBackward }
2458
+ ];
2459
+ const htmlNoMatch = /*@__PURE__*/html({ matchClosingTags: false });
2460
+ /**
2461
+ Markdown language support.
2462
+ */
2463
+ function markdown(config = {}) {
2464
+ let { codeLanguages, defaultCodeLanguage, addKeymap = true, base: { parser } = commonmarkLanguage, completeHTMLTags = true } = config;
2465
+ if (!(parser instanceof MarkdownParser))
2466
+ throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");
2467
+ let extensions = config.extensions ? [config.extensions] : [];
2468
+ let support = [htmlNoMatch.support], defaultCode;
2469
+ if (defaultCodeLanguage instanceof LanguageSupport) {
2470
+ support.push(defaultCodeLanguage.support);
2471
+ defaultCode = defaultCodeLanguage.language;
2472
+ }
2473
+ else if (defaultCodeLanguage) {
2474
+ defaultCode = defaultCodeLanguage;
2475
+ }
2476
+ let codeParser = codeLanguages || defaultCode ? getCodeParser(codeLanguages, defaultCode) : undefined;
2477
+ extensions.push(parseCode({ codeParser, htmlParser: htmlNoMatch.language.parser }));
2478
+ if (addKeymap)
2479
+ support.push(Prec.high(keymap.of(markdownKeymap)));
2480
+ let lang = mkLang(parser.configure(extensions));
2481
+ if (completeHTMLTags)
2482
+ support.push(lang.data.of({ autocomplete: htmlTagCompletion }));
2483
+ return new LanguageSupport(lang, support);
2484
+ }
2485
+ function htmlTagCompletion(context) {
2486
+ let { state, pos } = context, m = /<[:\-\.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos - 25, pos));
2487
+ if (!m)
2488
+ return null;
2489
+ let tree = syntaxTree(state).resolveInner(pos, -1);
2490
+ while (tree && !tree.type.isTop) {
2491
+ if (tree.name == "CodeBlock" || tree.name == "FencedCode" || tree.name == "ProcessingInstructionBlock" ||
2492
+ tree.name == "CommentBlock" || tree.name == "Link" || tree.name == "Image")
2493
+ return null;
2494
+ tree = tree.parent;
2495
+ }
2496
+ return {
2497
+ from: pos - m[0].length, to: pos,
2498
+ options: htmlTagCompletions(),
2499
+ validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
2500
+ };
2501
+ }
2502
+ let _tagCompletions = null;
2503
+ function htmlTagCompletions() {
2504
+ if (_tagCompletions)
2505
+ return _tagCompletions;
2506
+ let result = htmlCompletionSource(new CompletionContext(EditorState.create({ extensions: htmlNoMatch }), 0, true));
2507
+ return _tagCompletions = result ? result.options : [];
2508
+ }
2509
+
2510
+ export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, markdown, markdownKeymap, markdownLanguage };
2511
+ //# sourceMappingURL=index-DoEghZHy.js.map