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