udxcms 1.0.1 → 1.0.2

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 (695) hide show
  1. package/README.md +8 -1
  2. package/dist/assets/apps-article-cover-1.svg +14 -0
  3. package/dist/assets/apps-article-cover-2.svg +14 -0
  4. package/dist/assets/apps-bg.svg +238 -0
  5. package/dist/assets/component_img/about-team-bg2.png +0 -0
  6. package/dist/assets/component_img/demo-first-bg.png +0 -0
  7. package/dist/assets/component_img/index-bridge/Wallet.png +0 -0
  8. package/dist/assets/component_img/index-bridge/footer-img.png +0 -0
  9. package/dist/assets/component_img/index-bridge/index-bg.png +0 -0
  10. package/dist/assets/component_img/index-bridge/lang.png +0 -0
  11. package/dist/assets/component_img/index-bridge/logo.png +0 -0
  12. package/dist/assets/component_img/index-common/feature-1.svg +4 -0
  13. package/dist/assets/component_img/index-common/feature-2.svg +5 -0
  14. package/dist/assets/component_img/index-common/feature-3.svg +5 -0
  15. package/dist/assets/component_img/index-common/feature-4.svg +4 -0
  16. package/dist/assets/component_img/index-common/feature-5.svg +5 -0
  17. package/dist/assets/component_img/index-common/feature-6.svg +4 -0
  18. package/dist/assets/component_img/index-common/home-bg.png +0 -0
  19. package/dist/assets/component_img/index-common/home-img-three.png +0 -0
  20. package/dist/assets/component_img/index-common/home-phone.png +0 -0
  21. package/dist/assets/component_img/index-common/home-trade.png +0 -0
  22. package/dist/assets/component_img/index-common/line-item-bg.png +0 -0
  23. package/dist/assets/component_img/index-common/nine-p-img-01.svg +14 -0
  24. package/dist/assets/component_img/index-common/nine-p-img-02.svg +22 -0
  25. package/dist/assets/component_img/index-common/nine-p-img-03.svg +11 -0
  26. package/dist/assets/component_img/index-common/nine-p-img-04.svg +12 -0
  27. package/dist/assets/component_img/index-common/pioneer-1.png +0 -0
  28. package/dist/assets/component_img/index-common/pioneer-2.png +0 -0
  29. package/dist/assets/component_img/index-common/process-01.svg +5 -0
  30. package/dist/assets/component_img/index-common/process-02.svg +6 -0
  31. package/dist/assets/component_img/index-common/process-03.svg +4 -0
  32. package/dist/assets/component_img/index-common/process-04.svg +8 -0
  33. package/dist/assets/component_img/index-dark/home-phone.png +0 -0
  34. package/dist/assets/component_img/index-dark/home-trade.png +0 -0
  35. package/dist/assets/component_img/index-dex/bottom-img-bg.svg +9 -0
  36. package/dist/assets/component_img/index-dex/eleven-bg.svg +9 -0
  37. package/dist/assets/component_img/index-dex/feature-item-icon-bg-1.svg +9 -0
  38. package/dist/assets/component_img/index-dex/feature-item-icon-bg-2.svg +9 -0
  39. package/dist/assets/component_img/index-dex/feature-item-icon-bg-3.svg +9 -0
  40. package/dist/assets/component_img/index-dex/home-item-1.svg +190 -0
  41. package/dist/assets/component_img/index-dex/home-item-3-h5.png +0 -0
  42. package/dist/assets/component_img/index-dex/home-item-3.png +0 -0
  43. package/dist/assets/component_img/index-dex/mutilChain.svg +41 -0
  44. package/dist/assets/component_img/index-dex/started-icon-01.svg +5 -0
  45. package/dist/assets/component_img/index-dex/started-icon-02.svg +6 -0
  46. package/dist/assets/component_img/index-dex/started-icon-03.svg +6 -0
  47. package/dist/assets/component_img/index-dex/started-icon-04.svg +7 -0
  48. package/dist/assets/component_img/index-dex/started-icon-arrow.svg +6 -0
  49. package/dist/assets/component_img/index-dex/top-img-bg.svg +52 -0
  50. package/dist/assets/component_img/index-morse/home-item-1.png +0 -0
  51. package/dist/assets/component_img/index-morse/home-item-left-line.png +0 -0
  52. package/dist/assets/component_img/index-morse/home-item-right-1-1.png +0 -0
  53. package/dist/assets/component_img/index-morse/home-item2-around.png +0 -0
  54. package/dist/assets/component_img/index-morse/home-item2-lock.png +0 -0
  55. package/dist/assets/component_img/index-morse/home-item3-line.png +0 -0
  56. package/dist/assets/component_img/index-morse/home-item4-arrow.png +0 -0
  57. package/dist/assets/component_img/index-morse/home-item4-feature-1.png +0 -0
  58. package/dist/assets/component_img/index-morse/home-item4-feature-2.png +0 -0
  59. package/dist/assets/component_img/index-morse/home-item4-feature-3.png +0 -0
  60. package/dist/assets/component_img/index-morse/home-item4-feature-4.png +0 -0
  61. package/dist/assets/component_img/index-morse/home-item4-feature-5.png +0 -0
  62. package/dist/assets/component_img/index-morse/home-item4-feature-6.png +0 -0
  63. package/dist/assets/component_img/index-morse/home-item5-computer.png +0 -0
  64. package/dist/assets/component_img/index-morse/home-item6-bg.png +0 -0
  65. package/dist/assets/component_img/index-morse/home-item6-feature-1.png +0 -0
  66. package/dist/assets/component_img/index-morse/home-item6-feature-2.png +0 -0
  67. package/dist/assets/component_img/index-morse/home-item6-feature-3.png +0 -0
  68. package/dist/assets/component_img/index-morse/home-item6-feature-4.png +0 -0
  69. package/dist/assets/component_img/index-orbits/feature-1.png +0 -0
  70. package/dist/assets/component_img/index-orbits/feature-2.png +0 -0
  71. package/dist/assets/component_img/index-orbits/feature-3.png +0 -0
  72. package/dist/assets/component_img/index-orbits/feature-4.png +0 -0
  73. package/dist/assets/component_img/index-orbits/feature-5.png +0 -0
  74. package/dist/assets/component_img/index-orbits/feature-6.png +0 -0
  75. package/dist/assets/component_img/index-orbits/feature-light2.png +0 -0
  76. package/dist/assets/component_img/index-orbits/home-img-three.png +0 -0
  77. package/dist/assets/component_img/index-orbits/process-01.png +0 -0
  78. package/dist/assets/component_img/index-orbits/process-02.png +0 -0
  79. package/dist/assets/component_img/index-orbits/process-03.png +0 -0
  80. package/dist/assets/component_img/index-orbits/process-04.png +0 -0
  81. package/dist/assets/component_img/index-orbits/process-bg.png +0 -0
  82. package/dist/assets/component_img/index-orbits/section1_bg.png +0 -0
  83. package/dist/assets/component_img/index-orbits/section2_light.png +0 -0
  84. package/dist/assets/component_img/index-pointx/Learn.png +0 -0
  85. package/dist/assets/component_img/index-pointx/PointX.png +0 -0
  86. package/dist/assets/component_img/index-pointx/Subtract0.png +0 -0
  87. package/dist/assets/component_img/index-pointx/Subtract1.png +0 -0
  88. package/dist/assets/component_img/index-pointx/Subtract2.png +0 -0
  89. package/dist/assets/component_img/index-pointx/Subtract3.png +0 -0
  90. package/dist/assets/component_img/index-pointx/Vector-pointx.png +0 -0
  91. package/dist/assets/component_img/index-pointx/Wallet.png +0 -0
  92. package/dist/assets/component_img/index-pointx/arrow.png +0 -0
  93. package/dist/assets/component_img/index-pointx/bill-background.png +0 -0
  94. package/dist/assets/component_img/index-pointx/billboard-title.png +0 -0
  95. package/dist/assets/component_img/index-pointx/email-pointx.png +0 -0
  96. package/dist/assets/component_img/index-pointx/hand-icon.png +0 -0
  97. package/dist/assets/component_img/index-pointx/head-title.png +0 -0
  98. package/dist/assets/component_img/index-pointx/polygon.png +0 -0
  99. package/dist/assets/component_img/index-pointx/roadmap.png +0 -0
  100. package/dist/assets/component_img/index-pointx/solana.png +0 -0
  101. package/dist/assets/component_img/index-pointx/space-1.png +0 -0
  102. package/dist/assets/component_img/index-pointx/space-2.png +0 -0
  103. package/dist/assets/component_img/index-pointx/space-3.png +0 -0
  104. package/dist/assets/component_img/index-pointx/space-4.png +0 -0
  105. package/dist/assets/component_img/index-pointx/space-5.png +0 -0
  106. package/dist/assets/component_img/index-pointx/space-bg-2.png +0 -0
  107. package/dist/assets/component_img/index-pointx/space-bg.png +0 -0
  108. package/dist/assets/component_img/index-pointx/space-p-1.png +0 -0
  109. package/dist/assets/component_img/index-pointx/space-p-2.png +0 -0
  110. package/dist/assets/component_img/index-pointx/space-p-3.png +0 -0
  111. package/dist/assets/component_img/index-pointx/space-p-4.png +0 -0
  112. package/dist/assets/component_img/index-pointx/space-p-5.png +0 -0
  113. package/dist/assets/component_img/index-pointx/space-share.png +0 -0
  114. package/dist/assets/component_img/index-pointx/space-user-logo.png +0 -0
  115. package/dist/assets/component_img/index-pointx/star.png +0 -0
  116. package/dist/assets/component_img/index-pointx/telegram-pointx.png +0 -0
  117. package/dist/assets/component_img/index-pointx/why-1.png +0 -0
  118. package/dist/assets/component_img/index-pointx/why-2.png +0 -0
  119. package/dist/assets/component_img/index-pointx/why-3.png +0 -0
  120. package/dist/assets/component_img/index-pointx/why-4.png +0 -0
  121. package/dist/assets/component_img/index-vortex/advantage-1.png +0 -0
  122. package/dist/assets/component_img/index-vortex/advantage-2.png +0 -0
  123. package/dist/assets/component_img/index-vortex/advantage-3.png +0 -0
  124. package/dist/assets/component_img/index-vortex/advantage-4.png +0 -0
  125. package/dist/assets/component_img/index-vortex/advantage-5.png +0 -0
  126. package/dist/assets/component_img/index-vortex/advantage-bg.png +0 -0
  127. package/dist/assets/component_img/index-vortex/feature-1.png +0 -0
  128. package/dist/assets/component_img/index-vortex/feature-2.png +0 -0
  129. package/dist/assets/component_img/index-vortex/feature-3.png +0 -0
  130. package/dist/assets/component_img/index-vortex/feature-4.png +0 -0
  131. package/dist/assets/component_img/index-vortex/feature-5.png +0 -0
  132. package/dist/assets/component_img/index-vortex/feature-6.png +0 -0
  133. package/dist/assets/component_img/index-vortex/first-bg.png +0 -0
  134. package/dist/assets/component_img/index-vortex/home-img-three.png +0 -0
  135. package/dist/assets/component_img/index-vortex/indexVortex.gif +0 -0
  136. package/dist/assets/component_img/index-vortex/new/section-five-1.png +0 -0
  137. package/dist/assets/component_img/index-vortex/new/section-five-2.png +0 -0
  138. package/dist/assets/component_img/index-vortex/new/section-five-item-01.png +0 -0
  139. package/dist/assets/component_img/index-vortex/new/section-five-item-02.png +0 -0
  140. package/dist/assets/component_img/index-vortex/new/section-five-item-03.png +0 -0
  141. package/dist/assets/component_img/index-vortex/new/section-five-item-04.png +0 -0
  142. package/dist/assets/component_img/index-vortex/new/section-four-01.png +0 -0
  143. package/dist/assets/component_img/index-vortex/new/section-four-02.png +0 -0
  144. package/dist/assets/component_img/index-vortex/new/section-four-03.png +0 -0
  145. package/dist/assets/component_img/index-vortex/new/section-four-04.png +0 -0
  146. package/dist/assets/component_img/index-vortex/new/section-four-05.png +0 -0
  147. package/dist/assets/component_img/index-vortex/new/section-one-1.png +0 -0
  148. package/dist/assets/component_img/index-vortex/new/section-one-bg.png +0 -0
  149. package/dist/assets/component_img/index-vortex/new/section-seven.png +0 -0
  150. package/dist/assets/component_img/index-vortex/new/section-six-01.png +0 -0
  151. package/dist/assets/component_img/index-vortex/new/section-six-02.png +0 -0
  152. package/dist/assets/component_img/index-vortex/new/section-six-03.png +0 -0
  153. package/dist/assets/component_img/index-vortex/new/section-six-04.png +0 -0
  154. package/dist/assets/component_img/index-vortex/new/section-three-01.png +0 -0
  155. package/dist/assets/component_img/index-vortex/new/section-three-02.png +0 -0
  156. package/dist/assets/component_img/index-vortex/new/section-three-03.png +0 -0
  157. package/dist/assets/component_img/index-vortex/new/section-three-04.png +0 -0
  158. package/dist/assets/component_img/index-vortex/new/section-three-bg.png +0 -0
  159. package/dist/assets/component_img/index-vortex/new/section-three-item-bg.png +0 -0
  160. package/dist/assets/component_img/index-vortex/new/section-two-bg.png +0 -0
  161. package/dist/assets/component_img/index-vortex/process-01.svg +5 -0
  162. package/dist/assets/component_img/index-vortex/process-02.svg +6 -0
  163. package/dist/assets/component_img/index-vortex/process-03.svg +4 -0
  164. package/dist/assets/component_img/index-vortex/process-04.svg +8 -0
  165. package/dist/assets/component_img/index-wallet/ETH.svg +10 -0
  166. package/dist/assets/component_img/index-wallet/L2.svg +12 -0
  167. package/dist/assets/component_img/index-wallet/WalletConnect.svg +12 -0
  168. package/dist/assets/component_img/index-wallet/explore-metaverse.svg +25 -0
  169. package/dist/assets/component_img/index-wallet/hom-three-img.png +0 -0
  170. package/dist/assets/component_img/index-wallet/home-download-cover.png +0 -0
  171. package/dist/assets/component_img/index-wallet/home-two1.svg +44 -0
  172. package/dist/assets/component_img/index-wallet/home-two2.svg +44 -0
  173. package/dist/assets/component_img/index-wallet/home-two3.svg +33 -0
  174. package/dist/assets/component_img/index-wallet/layer-2-integration.svg +16 -0
  175. package/dist/assets/component_img/index-wallet/mao.png +0 -0
  176. package/dist/assets/component_img/index-wallet/ultra-low-fee.svg +12 -0
  177. package/dist/assets/component_img/mission-bg.png +0 -0
  178. package/dist/assets/component_img/mobi.png +0 -0
  179. package/dist/assets/component_img/putting.png +0 -0
  180. package/dist/assets/css/academy/_button.less +518 -0
  181. package/dist/assets/css/academy/_common.less +61 -0
  182. package/dist/assets/css/academy/index.less +2 -0
  183. package/dist/assets/css/cms_detail.less +78 -0
  184. package/dist/assets/dapp-1.png +0 -0
  185. package/dist/assets/dapp-2.png +0 -0
  186. package/dist/assets/dapp-3.png +0 -0
  187. package/dist/assets/dapp-4.png +0 -0
  188. package/dist/assets/dapp-5.png +0 -0
  189. package/dist/assets/dapp-6.png +0 -0
  190. package/dist/assets/default-site-icon.png +0 -0
  191. package/dist/assets/download-annoumment.png +0 -0
  192. package/dist/assets/h5/firstPage/APK.svg +15 -0
  193. package/dist/assets/h5/firstPage/ETH.svg +10 -0
  194. package/dist/assets/h5/firstPage/Google.svg +17 -0
  195. package/dist/assets/h5/firstPage/L2.svg +12 -0
  196. package/dist/assets/h5/firstPage/Store.svg +20 -0
  197. package/dist/assets/h5/firstPage/WalletConnect.svg +12 -0
  198. package/dist/assets/h5/firstPage/arrow-right.png +0 -0
  199. package/dist/assets/h5/firstPage/arrowDown.png +0 -0
  200. package/dist/assets/h5/firstPage/first-bg.png +0 -0
  201. package/dist/assets/h5/firstPage/first-btns-bg.svg +17 -0
  202. package/dist/assets/h5/firstPage/first-p-link.png +0 -0
  203. package/dist/assets/h5/firstPage/first-p-six.png +0 -0
  204. package/dist/assets/h5/firstPage/first-p-true-exchange.png +0 -0
  205. package/dist/assets/h5/firstPage/firstT-01.png +0 -0
  206. package/dist/assets/h5/firstPage/firstT-02.png +0 -0
  207. package/dist/assets/h5/firstPage/firstT-03.png +0 -0
  208. package/dist/assets/h5/firstPage/home-bottom-bg.png +0 -0
  209. package/dist/assets/h5/firstPage/home-top-logo.png +0 -0
  210. package/dist/assets/h5/firstPage/home-two1.svg +44 -0
  211. package/dist/assets/h5/firstPage/home-two2.svg +44 -0
  212. package/dist/assets/h5/firstPage/home-two3.svg +33 -0
  213. package/dist/assets/h5/firstPage/logo.svg +20 -0
  214. package/dist/assets/h5/firstPage/nine-p-img-01.svg +14 -0
  215. package/dist/assets/h5/firstPage/nine-p-img-02.svg +22 -0
  216. package/dist/assets/h5/firstPage/nine-p-img-03.svg +11 -0
  217. package/dist/assets/h5/firstPage/nine-p-img-04.svg +12 -0
  218. package/dist/assets/h5/firstPage/six-p-img-01.svg +505 -0
  219. package/dist/assets/h5/firstPage/six-p-img-02.png +0 -0
  220. package/dist/assets/h5/firstPage/trade-firsrT-title.png +0 -0
  221. package/dist/assets/h5/firstPage/two-left-img.png +0 -0
  222. package/dist/assets/h5/helpSupport/expand_arrow.svg +3 -0
  223. package/dist/assets/h5/helpSupport/expand_arrow_active.svg +3 -0
  224. package/dist/assets/h5/no-record.svg +11 -0
  225. package/dist/assets/h5/platform-1.png +0 -0
  226. package/dist/assets/h5/platform-2.png +0 -0
  227. package/dist/assets/h5/unlock.png +0 -0
  228. package/dist/assets/h5.png +0 -0
  229. package/dist/assets/icon-arrow-right.svg +4 -0
  230. package/dist/assets/icon-link.svg +4 -0
  231. package/dist/assets/img/add-icon.png +0 -0
  232. package/dist/assets/img/add-icon.svg +4 -0
  233. package/dist/assets/img/add-right-icon.svg +3 -0
  234. package/dist/assets/img/arrow-down-w.png +0 -0
  235. package/dist/assets/img/arrowDown.png +0 -0
  236. package/dist/assets/img/arrowRight.png +0 -0
  237. package/dist/assets/img/bread.png +0 -0
  238. package/dist/assets/img/cms/about-top.svg +19 -0
  239. package/dist/assets/img/cms/acdemy-top-img.png +0 -0
  240. package/dist/assets/img/cms/dapps.png +0 -0
  241. package/dist/assets/img/cms/five-pg.png +0 -0
  242. package/dist/assets/img/cms/four-h5-bg.png +0 -0
  243. package/dist/assets/img/cms/four-pc-bg.png +0 -0
  244. package/dist/assets/img/cms/seven-pg.png +0 -0
  245. package/dist/assets/img/cms/six-pg.png +0 -0
  246. package/dist/assets/img/cms/three-pg.png +0 -0
  247. package/dist/assets/img/cms/two-pg.png +0 -0
  248. package/dist/assets/img/coin.png +0 -0
  249. package/dist/assets/img/creator_logo_black.png +0 -0
  250. package/dist/assets/img/date_icon.png +0 -0
  251. package/dist/assets/img/empty.png +0 -0
  252. package/dist/assets/img/favorites-white.png +0 -0
  253. package/dist/assets/img/favorites.png +0 -0
  254. package/dist/assets/img/firstT-bg-01.jpg +0 -0
  255. package/dist/assets/img/firstT-bg-02.jpg +0 -0
  256. package/dist/assets/img/flag2.png +0 -0
  257. package/dist/assets/img/icon-down.png +0 -0
  258. package/dist/assets/img/icon-success.png +0 -0
  259. package/dist/assets/img/loading.png +0 -0
  260. package/dist/assets/img/logo-plain.png +0 -0
  261. package/dist/assets/img/mobi-bg.png +0 -0
  262. package/dist/assets/img/mobi-info.png +0 -0
  263. package/dist/assets/img/mobi.png +0 -0
  264. package/dist/assets/img/morse-dex/Group 2343.png +0 -0
  265. package/dist/assets/img/morse-dex/arrow.png +0 -0
  266. package/dist/assets/img/morse-dex/blabla.png +0 -0
  267. package/dist/assets/img/morse-dex/buddha.png +0 -0
  268. package/dist/assets/img/morse-dex/dory.png +0 -0
  269. package/dist/assets/img/morse-dex/e-item-1.png +0 -0
  270. package/dist/assets/img/morse-dex/e-item-2.png +0 -0
  271. package/dist/assets/img/morse-dex/e-item-3.png +0 -0
  272. package/dist/assets/img/morse-dex/first-bg.png +0 -0
  273. package/dist/assets/img/morse-dex/first-title.png +0 -0
  274. package/dist/assets/img/morse-dex/fishing.png +0 -0
  275. package/dist/assets/img/morse-dex/second-bg-2.png +0 -0
  276. package/dist/assets/img/morse-dex/second-bg.png +0 -0
  277. package/dist/assets/img/morse-dex/second-item-1.png +0 -0
  278. package/dist/assets/img/morse-dex/second-item-2.png +0 -0
  279. package/dist/assets/img/morse-dex/third-card.png +0 -0
  280. package/dist/assets/img/morse-dex/third-img.png +0 -0
  281. package/dist/assets/img/morse-dex/third-item-1.png +0 -0
  282. package/dist/assets/img/morse-dex/third-item-2.png +0 -0
  283. package/dist/assets/img/morse-dex/top-bg-1.png +0 -0
  284. package/dist/assets/img/morse-dex/top-bg-2.png +0 -0
  285. package/dist/assets/img/network-icon.svg +6 -0
  286. package/dist/assets/img/notice-nodata.svg +23 -0
  287. package/dist/assets/img/notice.svg +11 -0
  288. package/dist/assets/img/readAll.svg +16 -0
  289. package/dist/assets/img/readAlled.svg +16 -0
  290. package/dist/assets/img/reqs_no_data.png +0 -0
  291. package/dist/assets/img/tip.png +0 -0
  292. package/dist/assets/img/tips.png +0 -0
  293. package/dist/assets/img/unlock.png +0 -0
  294. package/dist/assets/img/user-login.png +0 -0
  295. package/dist/assets/img/user-logined.png +0 -0
  296. package/dist/assets/img/vote-bg.png +0 -0
  297. package/dist/assets/img/wallet-login-common.png +0 -0
  298. package/dist/assets/img/wallet-login-email.png +0 -0
  299. package/dist/assets/img/walletconnect.png +0 -0
  300. package/dist/assets/img/wiki/icon_arrow_left.png +0 -0
  301. package/dist/assets/img/wiki/icon_arrow_right.png +0 -0
  302. package/dist/assets/img/wiki/icon_down.png +0 -0
  303. package/dist/assets/img/wiki/icon_fi_list.png +0 -0
  304. package/dist/assets/img/wiki/icon_up.png +0 -0
  305. package/dist/assets/img-bg.png +0 -0
  306. package/dist/components/cmsComponents/api/code.js +4 -2
  307. package/dist/components/cmsComponents/api/test.js +4 -2
  308. package/dist/components/cmsComponents/sdk/lib/highlight/lib/core.js +1829 -2044
  309. package/dist/components/cmsComponents/sdk/lib/highlight/lib/index.js +1 -3
  310. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/1c.js +424 -509
  311. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/abnf.js +65 -77
  312. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/accesslog.js +84 -89
  313. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/actionscript.js +80 -86
  314. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ada.js +149 -166
  315. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/angelscript.js +90 -109
  316. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/apache.js +69 -72
  317. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/applescript.js +125 -150
  318. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/arcade.js +144 -150
  319. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/arduino.js +475 -518
  320. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/armasm.js +112 -120
  321. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/asciidoc.js +244 -268
  322. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/aspectj.js +144 -154
  323. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/autohotkey.js +70 -73
  324. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/autoit.js +146 -160
  325. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/avrasm.js +63 -70
  326. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/awk.js +61 -63
  327. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/axapta.js +160 -166
  328. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/bash.js +133 -142
  329. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/basic.js +52 -55
  330. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/bnf.js +25 -27
  331. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/brainfuck.js +30 -36
  332. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/c-like.js +407 -444
  333. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/c.js +247 -267
  334. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/cal.js +77 -91
  335. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/capnproto.js +48 -53
  336. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ceylon.js +67 -73
  337. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/clean.js +25 -30
  338. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/clojure-repl.js +13 -15
  339. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/clojure.js +134 -145
  340. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/cmake.js +52 -54
  341. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/coffeescript.js +304 -322
  342. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/coq.js +65 -69
  343. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/cos.js +119 -127
  344. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/cpp.js +383 -415
  345. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/crmsh.js +88 -91
  346. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/crystal.js +293 -299
  347. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/csharp.js +407 -416
  348. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/csp.js +23 -25
  349. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/css.js +547 -559
  350. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/d.js +215 -244
  351. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dart.js +168 -183
  352. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/delphi.js +112 -115
  353. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/diff.js +71 -73
  354. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/django.js +59 -64
  355. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dns.js +33 -36
  356. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dockerfile.js +20 -22
  357. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dos.js +51 -58
  358. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dsconfig.js +54 -57
  359. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dts.js +125 -136
  360. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/dust.js +31 -33
  361. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ebnf.js +37 -43
  362. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/elixir.js +218 -223
  363. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/elm.js +98 -115
  364. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/erb.js +14 -16
  365. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/erlang-repl.js +52 -60
  366. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/erlang.js +171 -180
  367. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/excel.js +51 -54
  368. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/fix.js +27 -29
  369. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/flix.js +39 -45
  370. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/fortran.js +123 -132
  371. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/fsharp.js +67 -71
  372. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/gams.js +164 -175
  373. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/gauss.js +271 -294
  374. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/gcode.js +74 -77
  375. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/gherkin.js +36 -38
  376. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/glsl.js +115 -118
  377. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/gml.js +871 -875
  378. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/go.js +56 -61
  379. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/golo.js +20 -24
  380. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/gradle.js +31 -35
  381. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/groovy.js +126 -140
  382. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/haml.js +96 -102
  383. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/handlebars.js +232 -273
  384. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/haskell.js +143 -158
  385. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/haxe.js +138 -144
  386. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/hsp.js +45 -52
  387. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/htmlbars.js +245 -292
  388. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/http.js +87 -92
  389. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/hy.js +89 -99
  390. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/inform7.js +57 -59
  391. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ini.js +115 -128
  392. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/irpf90.js +105 -111
  393. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/isbl.js +2973 -3198
  394. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/java.js +146 -160
  395. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/javascript.js +513 -543
  396. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/jboss-cli.js +51 -53
  397. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/json.js +51 -53
  398. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/julia-repl.js +22 -24
  399. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/julia.js +387 -406
  400. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/kotlin.js +236 -258
  401. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/lasso.js +159 -168
  402. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/latex.js +216 -234
  403. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ldif.js +32 -33
  404. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/leaf.js +37 -39
  405. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/less.js +587 -633
  406. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/lisp.js +94 -100
  407. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/livecodeserver.js +169 -174
  408. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/livescript.js +319 -337
  409. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/llvm.js +118 -124
  410. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/lsl.js +1 -9
  411. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/lua.js +64 -70
  412. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/makefile.js +79 -82
  413. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/markdown.js +218 -228
  414. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/mathematica.js +6731 -6752
  415. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/matlab.js +84 -89
  416. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/maxima.js +402 -408
  417. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/mel.js +223 -226
  418. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/mercury.js +99 -109
  419. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/mipsasm.js +95 -98
  420. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/mizar.js +16 -19
  421. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/mojolicious.js +24 -25
  422. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/monkey.js +69 -78
  423. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/moonscript.js +122 -129
  424. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/n1ql.js +59 -65
  425. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/nginx.js +119 -123
  426. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/nim.js +63 -68
  427. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/nix.js +51 -56
  428. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/node-repl.js +24 -26
  429. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/nsis.js +93 -110
  430. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/objectivec.js +103 -109
  431. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ocaml.js +62 -71
  432. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/openscad.js +68 -71
  433. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/oxygene.js +76 -87
  434. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/parser3.js +37 -47
  435. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/perl.js +441 -468
  436. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/pf.js +43 -49
  437. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/pgsql.js +574 -594
  438. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/php-template.js +40 -42
  439. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/php.js +175 -185
  440. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/plaintext.js +8 -10
  441. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/pony.js +66 -79
  442. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/powershell.js +273 -317
  443. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/processing.js +46 -48
  444. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/profile.js +33 -35
  445. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/prolog.js +73 -93
  446. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/properties.js +64 -69
  447. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/protobuf.js +33 -35
  448. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/puppet.js +124 -132
  449. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/purebasic.js +61 -67
  450. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/python-repl.js +24 -26
  451. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/python.js +389 -406
  452. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/q.js +20 -27
  453. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/qml.js +176 -190
  454. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/r.js +171 -187
  455. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/reasonml.js +277 -296
  456. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/rib.js +24 -27
  457. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/roboconf.js +62 -69
  458. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/routeros.js +139 -150
  459. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/rsl.js +35 -39
  460. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ruby.js +314 -339
  461. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/ruleslanguage.js +63 -67
  462. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/rust.js +126 -132
  463. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/sas.js +114 -124
  464. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/scala.js +115 -126
  465. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/scheme.js +168 -188
  466. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/scilab.js +56 -60
  467. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/scss.js +508 -518
  468. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/shell.js +17 -19
  469. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/smali.js +119 -125
  470. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/smalltalk.js +50 -52
  471. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/sml.js +63 -70
  472. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/sqf.js +426 -436
  473. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/sql.js +643 -662
  474. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/sql_more.js +155 -162
  475. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/stan.js +525 -536
  476. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/stata.js +40 -45
  477. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/step21.js +53 -56
  478. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/stylus.js +553 -580
  479. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/subunit.js +41 -43
  480. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/swift.js +679 -770
  481. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/taggerscript.js +38 -43
  482. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/tap.js +42 -44
  483. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/tcl.js +68 -82
  484. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/thrift.js +33 -38
  485. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/tp.js +80 -85
  486. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/twig.js +54 -63
  487. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/typescript.js +587 -625
  488. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/vala.js +48 -52
  489. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/vbnet.js +156 -178
  490. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/vbscript-html.js +11 -13
  491. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/vbscript.js +58 -71
  492. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/verilog.js +113 -120
  493. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/vhdl.js +53 -61
  494. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/vim.js +107 -111
  495. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/x86asm.js +138 -152
  496. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/xl.js +75 -83
  497. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/xml.js +209 -230
  498. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/xquery.js +161 -179
  499. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/yaml.js +154 -164
  500. package/dist/components/cmsComponents/sdk/lib/highlight/lib/languages/zephir.js +118 -125
  501. package/dist/components/cmsComponents/wiki/lib/highlight/lib/core.js +1829 -2044
  502. package/dist/components/cmsComponents/wiki/lib/highlight/lib/index.js +1 -3
  503. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/1c.js +424 -509
  504. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/abnf.js +65 -77
  505. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/accesslog.js +84 -89
  506. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/actionscript.js +80 -86
  507. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ada.js +149 -166
  508. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/angelscript.js +90 -109
  509. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/apache.js +69 -72
  510. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/applescript.js +125 -150
  511. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/arcade.js +144 -150
  512. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/arduino.js +475 -518
  513. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/armasm.js +112 -120
  514. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/asciidoc.js +244 -268
  515. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/aspectj.js +144 -154
  516. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/autohotkey.js +70 -73
  517. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/autoit.js +146 -160
  518. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/avrasm.js +63 -70
  519. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/awk.js +61 -63
  520. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/axapta.js +160 -166
  521. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/bash.js +133 -142
  522. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/basic.js +52 -55
  523. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/bnf.js +25 -27
  524. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/brainfuck.js +30 -36
  525. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/c-like.js +407 -444
  526. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/c.js +247 -267
  527. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/cal.js +77 -91
  528. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/capnproto.js +48 -53
  529. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ceylon.js +67 -73
  530. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/clean.js +25 -30
  531. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/clojure-repl.js +13 -15
  532. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/clojure.js +134 -145
  533. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/cmake.js +52 -54
  534. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/coffeescript.js +304 -322
  535. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/coq.js +65 -69
  536. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/cos.js +119 -127
  537. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/cpp.js +383 -415
  538. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/crmsh.js +88 -91
  539. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/crystal.js +293 -299
  540. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/csharp.js +407 -416
  541. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/csp.js +23 -25
  542. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/css.js +547 -559
  543. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/d.js +215 -244
  544. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dart.js +168 -183
  545. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/delphi.js +112 -115
  546. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/diff.js +71 -73
  547. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/django.js +59 -64
  548. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dns.js +33 -36
  549. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dockerfile.js +20 -22
  550. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dos.js +51 -58
  551. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dsconfig.js +54 -57
  552. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dts.js +125 -136
  553. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/dust.js +31 -33
  554. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ebnf.js +37 -43
  555. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/elixir.js +218 -223
  556. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/elm.js +98 -115
  557. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/erb.js +14 -16
  558. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/erlang-repl.js +52 -60
  559. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/erlang.js +171 -180
  560. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/excel.js +51 -54
  561. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/fix.js +27 -29
  562. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/flix.js +39 -45
  563. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/fortran.js +123 -132
  564. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/fsharp.js +67 -71
  565. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/gams.js +164 -175
  566. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/gauss.js +271 -294
  567. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/gcode.js +74 -77
  568. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/gherkin.js +36 -38
  569. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/glsl.js +115 -118
  570. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/gml.js +871 -875
  571. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/go.js +56 -61
  572. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/golo.js +20 -24
  573. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/gradle.js +31 -35
  574. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/groovy.js +126 -140
  575. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/haml.js +96 -102
  576. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/handlebars.js +232 -273
  577. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/haskell.js +143 -158
  578. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/haxe.js +138 -144
  579. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/hsp.js +45 -52
  580. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/htmlbars.js +245 -292
  581. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/http.js +87 -92
  582. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/hy.js +89 -99
  583. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/inform7.js +57 -59
  584. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ini.js +115 -128
  585. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/irpf90.js +105 -111
  586. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/isbl.js +2973 -3198
  587. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/java.js +146 -160
  588. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/javascript.js +513 -543
  589. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/jboss-cli.js +51 -53
  590. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/json.js +51 -53
  591. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/julia-repl.js +22 -24
  592. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/julia.js +387 -406
  593. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/kotlin.js +236 -258
  594. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/lasso.js +159 -168
  595. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/latex.js +216 -234
  596. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ldif.js +32 -33
  597. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/leaf.js +37 -39
  598. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/less.js +587 -633
  599. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/lisp.js +94 -100
  600. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/livecodeserver.js +169 -174
  601. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/livescript.js +319 -337
  602. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/llvm.js +118 -124
  603. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/lsl.js +1 -9
  604. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/lua.js +64 -70
  605. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/makefile.js +79 -82
  606. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/markdown.js +218 -228
  607. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/mathematica.js +6731 -6752
  608. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/matlab.js +84 -89
  609. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/maxima.js +402 -408
  610. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/mel.js +223 -226
  611. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/mercury.js +99 -109
  612. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/mipsasm.js +95 -98
  613. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/mizar.js +16 -19
  614. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/mojolicious.js +24 -25
  615. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/monkey.js +69 -78
  616. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/moonscript.js +122 -129
  617. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/n1ql.js +59 -65
  618. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/nginx.js +119 -123
  619. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/nim.js +63 -68
  620. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/nix.js +51 -56
  621. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/node-repl.js +24 -26
  622. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/nsis.js +93 -110
  623. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/objectivec.js +103 -109
  624. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ocaml.js +62 -71
  625. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/openscad.js +68 -71
  626. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/oxygene.js +76 -87
  627. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/parser3.js +37 -47
  628. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/perl.js +441 -468
  629. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/pf.js +43 -49
  630. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/pgsql.js +574 -594
  631. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/php-template.js +40 -42
  632. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/php.js +175 -185
  633. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/plaintext.js +8 -10
  634. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/pony.js +66 -79
  635. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/powershell.js +273 -317
  636. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/processing.js +46 -48
  637. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/profile.js +33 -35
  638. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/prolog.js +73 -93
  639. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/properties.js +64 -69
  640. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/protobuf.js +33 -35
  641. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/puppet.js +124 -132
  642. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/purebasic.js +61 -67
  643. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/python-repl.js +24 -26
  644. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/python.js +389 -406
  645. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/q.js +20 -27
  646. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/qml.js +176 -190
  647. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/r.js +171 -187
  648. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/reasonml.js +277 -296
  649. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/rib.js +24 -27
  650. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/roboconf.js +62 -69
  651. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/routeros.js +139 -150
  652. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/rsl.js +35 -39
  653. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ruby.js +314 -339
  654. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/ruleslanguage.js +63 -67
  655. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/rust.js +126 -132
  656. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/sas.js +114 -124
  657. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/scala.js +115 -126
  658. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/scheme.js +168 -188
  659. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/scilab.js +56 -60
  660. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/scss.js +508 -518
  661. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/shell.js +17 -19
  662. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/smali.js +119 -125
  663. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/smalltalk.js +50 -52
  664. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/sml.js +63 -70
  665. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/sqf.js +426 -436
  666. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/sql.js +643 -662
  667. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/sql_more.js +155 -162
  668. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/stan.js +525 -536
  669. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/stata.js +40 -45
  670. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/step21.js +53 -56
  671. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/stylus.js +553 -580
  672. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/subunit.js +41 -43
  673. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/swift.js +679 -770
  674. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/taggerscript.js +38 -43
  675. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/tap.js +42 -44
  676. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/tcl.js +68 -82
  677. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/thrift.js +33 -38
  678. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/tp.js +80 -85
  679. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/twig.js +54 -63
  680. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/typescript.js +587 -625
  681. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/vala.js +48 -52
  682. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/vbnet.js +156 -178
  683. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/vbscript-html.js +11 -13
  684. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/vbscript.js +58 -71
  685. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/verilog.js +113 -120
  686. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/vhdl.js +53 -61
  687. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/vim.js +107 -111
  688. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/x86asm.js +138 -152
  689. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/xl.js +75 -83
  690. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/xml.js +209 -230
  691. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/xquery.js +161 -179
  692. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/yaml.js +154 -164
  693. package/dist/components/cmsComponents/wiki/lib/highlight/lib/languages/zephir.js +118 -125
  694. package/dist/components/index.js +220 -115
  695. package/package.json +3 -2
@@ -3,62 +3,54 @@ function deepFreeze(obj) {
3
3
  obj.clear = obj.delete = obj.set = function () {
4
4
  throw new Error('map is read-only');
5
5
  };
6
- } else if (obj instanceof Set) {
6
+ }
7
+ else if (obj instanceof Set) {
7
8
  obj.add = obj.clear = obj.delete = function () {
8
9
  throw new Error('set is read-only');
9
10
  };
10
11
  }
11
-
12
12
  // Freeze self
13
13
  Object.freeze(obj);
14
-
15
14
  Object.getOwnPropertyNames(obj).forEach(function (name) {
16
15
  var prop = obj[name];
17
-
18
16
  // Freeze prop if it is an object
19
17
  if (typeof prop == 'object' && !Object.isFrozen(prop)) {
20
18
  deepFreeze(prop);
21
19
  }
22
20
  });
23
-
24
21
  return obj;
25
22
  }
26
-
27
23
  var deepFreezeEs6 = deepFreeze;
28
24
  var _default = deepFreeze;
29
25
  deepFreezeEs6.default = _default;
30
-
31
26
  /** @implements CallbackResponse */
32
27
  class Response {
33
- /**
34
- * @param {CompiledMode} mode
35
- */
36
- constructor(mode) {
37
- // eslint-disable-next-line no-undefined
38
- if (mode.data === undefined) mode.data = {};
39
-
40
- this.data = mode.data;
41
- this.isMatchIgnored = false;
42
- }
43
-
44
- ignoreMatch() {
45
- this.isMatchIgnored = true;
46
- }
28
+ /**
29
+ * @param {CompiledMode} mode
30
+ */
31
+ constructor(mode) {
32
+ // eslint-disable-next-line no-undefined
33
+ if (mode.data === undefined)
34
+ mode.data = {};
35
+ this.data = mode.data;
36
+ this.isMatchIgnored = false;
37
+ }
38
+ ignoreMatch() {
39
+ this.isMatchIgnored = true;
40
+ }
47
41
  }
48
-
49
42
  /**
50
43
  * @param {string} value
51
44
  * @returns {string}
52
45
  */
53
46
  function escapeHTML(value) {
54
- return value
55
- .replace(/&/g, '&')
56
- .replace(/</g, '&lt;')
57
- .replace(/>/g, '&gt;')
58
- .replace(/"/g, '&quot;')
59
- .replace(/'/g, '&#x27;');
47
+ return value
48
+ .replace(/&/g, '&amp;')
49
+ .replace(/</g, '&lt;')
50
+ .replace(/>/g, '&gt;')
51
+ .replace(/"/g, '&quot;')
52
+ .replace(/'/g, '&#x27;');
60
53
  }
61
-
62
54
  /**
63
55
  * performs a shallow merge of multiple objects into one
64
56
  *
@@ -68,20 +60,18 @@ function escapeHTML(value) {
68
60
  * @returns {T} a single new object
69
61
  */
70
62
  function inherit(original, ...objects) {
71
- /** @type Record<string,any> */
72
- const result = Object.create(null);
73
-
74
- for (const key in original) {
75
- result[key] = original[key];
76
- }
77
- objects.forEach(function(obj) {
78
- for (const key in obj) {
79
- result[key] = obj[key];
80
- }
81
- });
82
- return /** @type {T} */ (result);
63
+ /** @type Record<string,any> */
64
+ const result = Object.create(null);
65
+ for (const key in original) {
66
+ result[key] = original[key];
67
+ }
68
+ objects.forEach(function (obj) {
69
+ for (const key in obj) {
70
+ result[key] = obj[key];
71
+ }
72
+ });
73
+ return /** @type {T} */ (result);
83
74
  }
84
-
85
75
  /**
86
76
  * @typedef {object} Renderer
87
77
  * @property {(text: string) => void} addText
@@ -89,176 +79,157 @@ function inherit(original, ...objects) {
89
79
  * @property {(node: Node) => void} closeNode
90
80
  * @property {() => string} value
91
81
  */
92
-
93
82
  /** @typedef {{kind?: string, sublanguage?: boolean}} Node */
94
83
  /** @typedef {{walk: (r: Renderer) => void}} Tree */
95
84
  /** */
96
-
97
85
  const SPAN_CLOSE = '</span>';
98
-
99
86
  /**
100
87
  * Determines if a node needs to be wrapped in <span>
101
88
  *
102
89
  * @param {Node} node */
103
90
  const emitsWrappingTags = (node) => {
104
- return !!node.kind;
91
+ return !!node.kind;
105
92
  };
106
-
107
93
  /** @type {Renderer} */
108
94
  class HTMLRenderer {
109
- /**
110
- * Creates a new HTMLRenderer
111
- *
112
- * @param {Tree} parseTree - the parse tree (must support `walk` API)
113
- * @param {{classPrefix: string}} options
114
- */
115
- constructor(parseTree, options) {
116
- this.buffer = "";
117
- this.classPrefix = options.classPrefix;
118
- parseTree.walk(this);
119
- }
120
-
121
- /**
122
- * Adds texts to the output stream
123
- *
124
- * @param {string} text */
125
- addText(text) {
126
- this.buffer += escapeHTML(text);
127
- }
128
-
129
- /**
130
- * Adds a node open to the output stream (if needed)
131
- *
132
- * @param {Node} node */
133
- openNode(node) {
134
- if (!emitsWrappingTags(node)) return;
135
-
136
- let className = node.kind;
137
- if (!node.sublanguage) {
138
- className = `${this.classPrefix}${className}`;
95
+ /**
96
+ * Creates a new HTMLRenderer
97
+ *
98
+ * @param {Tree} parseTree - the parse tree (must support `walk` API)
99
+ * @param {{classPrefix: string}} options
100
+ */
101
+ constructor(parseTree, options) {
102
+ this.buffer = "";
103
+ this.classPrefix = options.classPrefix;
104
+ parseTree.walk(this);
105
+ }
106
+ /**
107
+ * Adds texts to the output stream
108
+ *
109
+ * @param {string} text */
110
+ addText(text) {
111
+ this.buffer += escapeHTML(text);
112
+ }
113
+ /**
114
+ * Adds a node open to the output stream (if needed)
115
+ *
116
+ * @param {Node} node */
117
+ openNode(node) {
118
+ if (!emitsWrappingTags(node))
119
+ return;
120
+ let className = node.kind;
121
+ if (!node.sublanguage) {
122
+ className = `${this.classPrefix}${className}`;
123
+ }
124
+ this.span(className);
125
+ }
126
+ /**
127
+ * Adds a node close to the output stream (if needed)
128
+ *
129
+ * @param {Node} node */
130
+ closeNode(node) {
131
+ if (!emitsWrappingTags(node))
132
+ return;
133
+ this.buffer += SPAN_CLOSE;
134
+ }
135
+ /**
136
+ * returns the accumulated buffer
137
+ */
138
+ value() {
139
+ return this.buffer;
140
+ }
141
+ // helpers
142
+ /**
143
+ * Builds a span element
144
+ *
145
+ * @param {string} className */
146
+ span(className) {
147
+ this.buffer += `<span class="${className}">`;
139
148
  }
140
- this.span(className);
141
- }
142
-
143
- /**
144
- * Adds a node close to the output stream (if needed)
145
- *
146
- * @param {Node} node */
147
- closeNode(node) {
148
- if (!emitsWrappingTags(node)) return;
149
-
150
- this.buffer += SPAN_CLOSE;
151
- }
152
-
153
- /**
154
- * returns the accumulated buffer
155
- */
156
- value() {
157
- return this.buffer;
158
- }
159
-
160
- // helpers
161
-
162
- /**
163
- * Builds a span element
164
- *
165
- * @param {string} className */
166
- span(className) {
167
- this.buffer += `<span class="${className}">`;
168
- }
169
149
  }
170
-
171
150
  /** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} | string} Node */
172
151
  /** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} } DataNode */
173
152
  /** */
174
-
175
153
  class TokenTree {
176
- constructor() {
177
- /** @type DataNode */
178
- this.rootNode = { children: [] };
179
- this.stack = [this.rootNode];
180
- }
181
-
182
- get top() {
183
- return this.stack[this.stack.length - 1];
184
- }
185
-
186
- get root() { return this.rootNode; }
187
-
188
- /** @param {Node} node */
189
- add(node) {
190
- this.top.children.push(node);
191
- }
192
-
193
- /** @param {string} kind */
194
- openNode(kind) {
195
- /** @type Node */
196
- const node = { kind, children: [] };
197
- this.add(node);
198
- this.stack.push(node);
199
- }
200
-
201
- closeNode() {
202
- if (this.stack.length > 1) {
203
- return this.stack.pop();
154
+ constructor() {
155
+ /** @type DataNode */
156
+ this.rootNode = { children: [] };
157
+ this.stack = [this.rootNode];
158
+ }
159
+ get top() {
160
+ return this.stack[this.stack.length - 1];
161
+ }
162
+ get root() { return this.rootNode; }
163
+ /** @param {Node} node */
164
+ add(node) {
165
+ this.top.children.push(node);
166
+ }
167
+ /** @param {string} kind */
168
+ openNode(kind) {
169
+ /** @type Node */
170
+ const node = { kind, children: [] };
171
+ this.add(node);
172
+ this.stack.push(node);
173
+ }
174
+ closeNode() {
175
+ if (this.stack.length > 1) {
176
+ return this.stack.pop();
177
+ }
178
+ // eslint-disable-next-line no-undefined
179
+ return undefined;
180
+ }
181
+ closeAllNodes() {
182
+ while (this.closeNode())
183
+ ;
184
+ }
185
+ toJSON() {
186
+ return JSON.stringify(this.rootNode, null, 4);
187
+ }
188
+ /**
189
+ * @typedef { import("./html_renderer").Renderer } Renderer
190
+ * @param {Renderer} builder
191
+ */
192
+ walk(builder) {
193
+ // this does not
194
+ return this.constructor._walk(builder, this.rootNode);
195
+ // this works
196
+ // return TokenTree._walk(builder, this.rootNode);
197
+ }
198
+ /**
199
+ * @param {Renderer} builder
200
+ * @param {Node} node
201
+ */
202
+ static _walk(builder, node) {
203
+ if (typeof node === "string") {
204
+ builder.addText(node);
205
+ }
206
+ else if (node.children) {
207
+ builder.openNode(node);
208
+ node.children.forEach((child) => this._walk(builder, child));
209
+ builder.closeNode(node);
210
+ }
211
+ return builder;
212
+ }
213
+ /**
214
+ * @param {Node} node
215
+ */
216
+ static _collapse(node) {
217
+ if (typeof node === "string")
218
+ return;
219
+ if (!node.children)
220
+ return;
221
+ if (node.children.every(el => typeof el === "string")) {
222
+ // node.text = node.children.join("");
223
+ // delete node.children;
224
+ node.children = [node.children.join("")];
225
+ }
226
+ else {
227
+ node.children.forEach((child) => {
228
+ TokenTree._collapse(child);
229
+ });
230
+ }
204
231
  }
205
- // eslint-disable-next-line no-undefined
206
- return undefined;
207
- }
208
-
209
- closeAllNodes() {
210
- while (this.closeNode());
211
- }
212
-
213
- toJSON() {
214
- return JSON.stringify(this.rootNode, null, 4);
215
- }
216
-
217
- /**
218
- * @typedef { import("./html_renderer").Renderer } Renderer
219
- * @param {Renderer} builder
220
- */
221
- walk(builder) {
222
- // this does not
223
- return this.constructor._walk(builder, this.rootNode);
224
- // this works
225
- // return TokenTree._walk(builder, this.rootNode);
226
- }
227
-
228
- /**
229
- * @param {Renderer} builder
230
- * @param {Node} node
231
- */
232
- static _walk(builder, node) {
233
- if (typeof node === "string") {
234
- builder.addText(node);
235
- } else if (node.children) {
236
- builder.openNode(node);
237
- node.children.forEach((child) => this._walk(builder, child));
238
- builder.closeNode(node);
239
- }
240
- return builder;
241
- }
242
-
243
- /**
244
- * @param {Node} node
245
- */
246
- static _collapse(node) {
247
- if (typeof node === "string") return;
248
- if (!node.children) return;
249
-
250
- if (node.children.every(el => typeof el === "string")) {
251
- // node.text = node.children.join("");
252
- // delete node.children;
253
- node.children = [node.children.join("")];
254
- } else {
255
- node.children.forEach((child) => {
256
- TokenTree._collapse(child);
257
- });
258
- }
259
- }
260
232
  }
261
-
262
233
  /**
263
234
  Currently this is all private API, but this is the minimal API necessary
264
235
  that an Emitter must implement to fully support the parser.
@@ -275,90 +246,83 @@ class TokenTree {
275
246
  - toHTML()
276
247
 
277
248
  */
278
-
279
249
  /**
280
250
  * @implements {Emitter}
281
251
  */
282
252
  class TokenTreeEmitter extends TokenTree {
283
- /**
284
- * @param {*} options
285
- */
286
- constructor(options) {
287
- super();
288
- this.options = options;
289
- }
290
-
291
- /**
292
- * @param {string} text
293
- * @param {string} kind
294
- */
295
- addKeyword(text, kind) {
296
- if (text === "") { return; }
297
-
298
- this.openNode(kind);
299
- this.addText(text);
300
- this.closeNode();
301
- }
302
-
303
- /**
304
- * @param {string} text
305
- */
306
- addText(text) {
307
- if (text === "") { return; }
308
-
309
- this.add(text);
310
- }
311
-
312
- /**
313
- * @param {Emitter & {root: DataNode}} emitter
314
- * @param {string} name
315
- */
316
- addSublanguage(emitter, name) {
317
- /** @type DataNode */
318
- const node = emitter.root;
319
- node.kind = name;
320
- node.sublanguage = true;
321
- this.add(node);
322
- }
323
-
324
- toHTML() {
325
- const renderer = new HTMLRenderer(this, this.options);
326
- return renderer.value();
327
- }
328
-
329
- finalize() {
330
- return true;
331
- }
253
+ /**
254
+ * @param {*} options
255
+ */
256
+ constructor(options) {
257
+ super();
258
+ this.options = options;
259
+ }
260
+ /**
261
+ * @param {string} text
262
+ * @param {string} kind
263
+ */
264
+ addKeyword(text, kind) {
265
+ if (text === "") {
266
+ return;
267
+ }
268
+ this.openNode(kind);
269
+ this.addText(text);
270
+ this.closeNode();
271
+ }
272
+ /**
273
+ * @param {string} text
274
+ */
275
+ addText(text) {
276
+ if (text === "") {
277
+ return;
278
+ }
279
+ this.add(text);
280
+ }
281
+ /**
282
+ * @param {Emitter & {root: DataNode}} emitter
283
+ * @param {string} name
284
+ */
285
+ addSublanguage(emitter, name) {
286
+ /** @type DataNode */
287
+ const node = emitter.root;
288
+ node.kind = name;
289
+ node.sublanguage = true;
290
+ this.add(node);
291
+ }
292
+ toHTML() {
293
+ const renderer = new HTMLRenderer(this, this.options);
294
+ return renderer.value();
295
+ }
296
+ finalize() {
297
+ return true;
298
+ }
332
299
  }
333
-
334
300
  /**
335
301
  * @param {string} value
336
302
  * @returns {RegExp}
337
303
  * */
338
304
  function escape(value) {
339
- return new RegExp(value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');
305
+ return new RegExp(value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');
340
306
  }
341
-
342
307
  /**
343
308
  * @param {RegExp | string } re
344
309
  * @returns {string}
345
310
  */
346
311
  function source(re) {
347
- if (!re) return null;
348
- if (typeof re === "string") return re;
349
-
350
- return re.source;
312
+ if (!re)
313
+ return null;
314
+ if (typeof re === "string")
315
+ return re;
316
+ return re.source;
351
317
  }
352
-
353
318
  /**
354
319
  * @param {...(RegExp | string) } args
355
320
  * @returns {string}
356
321
  */
357
322
  function concat(...args) {
358
- const joined = args.map((x) => source(x)).join("");
359
- return joined;
323
+ const joined = args.map((x) => source(x)).join("");
324
+ return joined;
360
325
  }
361
-
362
326
  /**
363
327
  * Any of the passed expresssions may match
364
328
  *
@@ -367,28 +331,25 @@ function concat(...args) {
367
331
  * @returns {string}
368
332
  */
369
333
  function either(...args) {
370
- const joined = '(' + args.map((x) => source(x)).join("|") + ")";
371
- return joined;
334
+ const joined = '(' + args.map((x) => source(x)).join("|") + ")";
335
+ return joined;
372
336
  }
373
-
374
337
  /**
375
338
  * @param {RegExp} re
376
339
  * @returns {number}
377
340
  */
378
341
  function countMatchGroups(re) {
379
- return (new RegExp(re.toString() + '|')).exec('').length - 1;
342
+ return (new RegExp(re.toString() + '|')).exec('').length - 1;
380
343
  }
381
-
382
344
  /**
383
345
  * Does lexeme start with a regular expression match at the beginning
384
346
  * @param {RegExp} re
385
347
  * @param {string} lexeme
386
348
  */
387
349
  function startsWith(re, lexeme) {
388
- const match = re && re.exec(lexeme);
389
- return match && match.index === 0;
350
+ const match = re && re.exec(lexeme);
351
+ return match && match.index === 0;
390
352
  }
391
-
392
353
  // BACKREF_RE matches an open parenthesis or backreference. To avoid
393
354
  // an incorrect parse, it additionally matches the following:
394
355
  // - [...] elements, where the meaning of parentheses and escapes change
@@ -397,7 +358,6 @@ function startsWith(re, lexeme) {
397
358
  // - non-matching or lookahead parentheses, which do not capture. These
398
359
  // follow the '(' with a '?'.
399
360
  const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
400
-
401
361
  // join logically computes regexps.join(separator), but fixes the
402
362
  // backreferences so they continue to match.
403
363
  // it also places each individual regular expression into it's own
@@ -409,36 +369,34 @@ const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
409
369
  * @returns {string}
410
370
  */
411
371
  function join(regexps, separator = "|") {
412
- let numCaptures = 0;
413
-
414
- return regexps.map((regex) => {
415
- numCaptures += 1;
416
- const offset = numCaptures;
417
- let re = source(regex);
418
- let out = '';
419
-
420
- while (re.length > 0) {
421
- const match = BACKREF_RE.exec(re);
422
- if (!match) {
423
- out += re;
424
- break;
425
- }
426
- out += re.substring(0, match.index);
427
- re = re.substring(match.index + match[0].length);
428
- if (match[0][0] === '\\' && match[1]) {
429
- // Adjust the backreference.
430
- out += '\\' + String(Number(match[1]) + offset);
431
- } else {
432
- out += match[0];
433
- if (match[0] === '(') {
434
- numCaptures++;
435
- }
436
- }
437
- }
438
- return out;
439
- }).map(re => `(${re})`).join(separator);
372
+ let numCaptures = 0;
373
+ return regexps.map((regex) => {
374
+ numCaptures += 1;
375
+ const offset = numCaptures;
376
+ let re = source(regex);
377
+ let out = '';
378
+ while (re.length > 0) {
379
+ const match = BACKREF_RE.exec(re);
380
+ if (!match) {
381
+ out += re;
382
+ break;
383
+ }
384
+ out += re.substring(0, match.index);
385
+ re = re.substring(match.index + match[0].length);
386
+ if (match[0][0] === '\\' && match[1]) {
387
+ // Adjust the backreference.
388
+ out += '\\' + String(Number(match[1]) + offset);
389
+ }
390
+ else {
391
+ out += match[0];
392
+ if (match[0] === '(') {
393
+ numCaptures++;
394
+ }
395
+ }
396
+ }
397
+ return out;
398
+ }).map(re => `(${re})`).join(separator);
440
399
  }
441
-
442
400
  // Common regexps
443
401
  const MATCH_NOTHING_RE = /\b\B/;
444
402
  const IDENT_RE = '[a-zA-Z]\\w*';
@@ -447,51 +405,46 @@ const NUMBER_RE = '\\b\\d+(\\.\\d+)?';
447
405
  const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
448
406
  const BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
449
407
  const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
450
-
451
408
  /**
452
409
  * @param { Partial<Mode> & {binary?: string | RegExp} } opts
453
410
  */
454
411
  const SHEBANG = (opts = {}) => {
455
- const beginShebang = /^#![ ]*\//;
456
- if (opts.binary) {
457
- opts.begin = concat(
458
- beginShebang,
459
- /.*\b/,
460
- opts.binary,
461
- /\b.*/);
462
- }
463
- return inherit({
464
- className: 'meta',
465
- begin: beginShebang,
466
- end: /$/,
467
- relevance: 0,
468
- /** @type {ModeCallback} */
469
- "on:begin": (m, resp) => {
470
- if (m.index !== 0) resp.ignoreMatch();
471
- }
472
- }, opts);
412
+ const beginShebang = /^#![ ]*\//;
413
+ if (opts.binary) {
414
+ opts.begin = concat(beginShebang, /.*\b/, opts.binary, /\b.*/);
415
+ }
416
+ return inherit({
417
+ className: 'meta',
418
+ begin: beginShebang,
419
+ end: /$/,
420
+ relevance: 0,
421
+ /** @type {ModeCallback} */
422
+ "on:begin": (m, resp) => {
423
+ if (m.index !== 0)
424
+ resp.ignoreMatch();
425
+ }
426
+ }, opts);
473
427
  };
474
-
475
428
  // Common modes
476
429
  const BACKSLASH_ESCAPE = {
477
- begin: '\\\\[\\s\\S]', relevance: 0
430
+ begin: '\\\\[\\s\\S]', relevance: 0
478
431
  };
479
432
  const APOS_STRING_MODE = {
480
- className: 'string',
481
- begin: '\'',
482
- end: '\'',
483
- illegal: '\\n',
484
- contains: [BACKSLASH_ESCAPE]
433
+ className: 'string',
434
+ begin: '\'',
435
+ end: '\'',
436
+ illegal: '\\n',
437
+ contains: [BACKSLASH_ESCAPE]
485
438
  };
486
439
  const QUOTE_STRING_MODE = {
487
- className: 'string',
488
- begin: '"',
489
- end: '"',
490
- illegal: '\\n',
491
- contains: [BACKSLASH_ESCAPE]
440
+ className: 'string',
441
+ begin: '"',
442
+ end: '"',
443
+ illegal: '\\n',
444
+ contains: [BACKSLASH_ESCAPE]
492
445
  };
493
446
  const PHRASAL_WORDS_MODE = {
494
- begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
447
+ begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
495
448
  };
496
449
  /**
497
450
  * Creates a comment mode
@@ -501,95 +454,91 @@ const PHRASAL_WORDS_MODE = {
501
454
  * @param {Mode | {}} [modeOptions]
502
455
  * @returns {Partial<Mode>}
503
456
  */
504
- const COMMENT = function(begin, end, modeOptions = {}) {
505
- const mode = inherit(
506
- {
507
- className: 'comment',
508
- begin,
509
- end,
510
- contains: []
511
- },
512
- modeOptions
513
- );
514
- mode.contains.push(PHRASAL_WORDS_MODE);
515
- mode.contains.push({
516
- className: 'doctag',
517
- begin: '(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):',
518
- relevance: 0
519
- });
520
- return mode;
457
+ const COMMENT = function (begin, end, modeOptions = {}) {
458
+ const mode = inherit({
459
+ className: 'comment',
460
+ begin,
461
+ end,
462
+ contains: []
463
+ }, modeOptions);
464
+ mode.contains.push(PHRASAL_WORDS_MODE);
465
+ mode.contains.push({
466
+ className: 'doctag',
467
+ begin: '(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):',
468
+ relevance: 0
469
+ });
470
+ return mode;
521
471
  };
522
472
  const C_LINE_COMMENT_MODE = COMMENT('//', '$');
523
473
  const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/');
524
474
  const HASH_COMMENT_MODE = COMMENT('#', '$');
525
475
  const NUMBER_MODE = {
526
- className: 'number',
527
- begin: NUMBER_RE,
528
- relevance: 0
476
+ className: 'number',
477
+ begin: NUMBER_RE,
478
+ relevance: 0
529
479
  };
530
480
  const C_NUMBER_MODE = {
531
- className: 'number',
532
- begin: C_NUMBER_RE,
533
- relevance: 0
481
+ className: 'number',
482
+ begin: C_NUMBER_RE,
483
+ relevance: 0
534
484
  };
535
485
  const BINARY_NUMBER_MODE = {
536
- className: 'number',
537
- begin: BINARY_NUMBER_RE,
538
- relevance: 0
486
+ className: 'number',
487
+ begin: BINARY_NUMBER_RE,
488
+ relevance: 0
539
489
  };
540
490
  const CSS_NUMBER_MODE = {
541
- className: 'number',
542
- begin: NUMBER_RE + '(' +
543
- '%|em|ex|ch|rem' +
544
- '|vw|vh|vmin|vmax' +
545
- '|cm|mm|in|pt|pc|px' +
546
- '|deg|grad|rad|turn' +
547
- '|s|ms' +
548
- '|Hz|kHz' +
549
- '|dpi|dpcm|dppx' +
550
- ')?',
551
- relevance: 0
491
+ className: 'number',
492
+ begin: NUMBER_RE + '(' +
493
+ '%|em|ex|ch|rem' +
494
+ '|vw|vh|vmin|vmax' +
495
+ '|cm|mm|in|pt|pc|px' +
496
+ '|deg|grad|rad|turn' +
497
+ '|s|ms' +
498
+ '|Hz|kHz' +
499
+ '|dpi|dpcm|dppx' +
500
+ ')?',
501
+ relevance: 0
552
502
  };
553
503
  const REGEXP_MODE = {
554
- // this outer rule makes sure we actually have a WHOLE regex and not simply
555
- // an expression such as:
556
- //
557
- // 3 / something
558
- //
559
- // (which will then blow up when regex's `illegal` sees the newline)
560
- begin: /(?=\/[^/\n]*\/)/,
561
- contains: [{
562
- className: 'regexp',
563
- begin: /\//,
564
- end: /\/[gimuy]*/,
565
- illegal: /\n/,
566
- contains: [
567
- BACKSLASH_ESCAPE,
568
- {
569
- begin: /\[/,
570
- end: /\]/,
571
- relevance: 0,
572
- contains: [BACKSLASH_ESCAPE]
573
- }
574
- ]
575
- }]
504
+ // this outer rule makes sure we actually have a WHOLE regex and not simply
505
+ // an expression such as:
506
+ //
507
+ // 3 / something
508
+ //
509
+ // (which will then blow up when regex's `illegal` sees the newline)
510
+ begin: /(?=\/[^/\n]*\/)/,
511
+ contains: [{
512
+ className: 'regexp',
513
+ begin: /\//,
514
+ end: /\/[gimuy]*/,
515
+ illegal: /\n/,
516
+ contains: [
517
+ BACKSLASH_ESCAPE,
518
+ {
519
+ begin: /\[/,
520
+ end: /\]/,
521
+ relevance: 0,
522
+ contains: [BACKSLASH_ESCAPE]
523
+ }
524
+ ]
525
+ }]
576
526
  };
577
527
  const TITLE_MODE = {
578
- className: 'title',
579
- begin: IDENT_RE,
580
- relevance: 0
528
+ className: 'title',
529
+ begin: IDENT_RE,
530
+ relevance: 0
581
531
  };
582
532
  const UNDERSCORE_TITLE_MODE = {
583
- className: 'title',
584
- begin: UNDERSCORE_IDENT_RE,
585
- relevance: 0
533
+ className: 'title',
534
+ begin: UNDERSCORE_IDENT_RE,
535
+ relevance: 0
586
536
  };
587
537
  const METHOD_GUARD = {
588
- // excludes method names from keyword processing
589
- begin: '\\.\\s*' + UNDERSCORE_IDENT_RE,
590
- relevance: 0
538
+ // excludes method names from keyword processing
539
+ begin: '\\.\\s*' + UNDERSCORE_IDENT_RE,
540
+ relevance: 0
591
541
  };
592
-
593
542
  /**
594
543
  * Adds end same as begin mechanics to a mode
595
544
  *
@@ -597,17 +546,16 @@ const METHOD_GUARD = {
597
546
  * group is what is used for comparison
598
547
  * @param {Partial<Mode>} mode
599
548
  */
600
- const END_SAME_AS_BEGIN = function(mode) {
601
- return Object.assign(mode,
602
- {
603
- /** @type {ModeCallback} */
604
- 'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; },
605
- /** @type {ModeCallback} */
606
- 'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); }
549
+ const END_SAME_AS_BEGIN = function (mode) {
550
+ return Object.assign(mode, {
551
+ /** @type {ModeCallback} */
552
+ 'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; },
553
+ /** @type {ModeCallback} */
554
+ 'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1])
555
+ resp.ignoreMatch(); }
607
556
  });
608
557
  };
609
-
610
- var MODES = /*#__PURE__*/Object.freeze({
558
+ var MODES = /*#__PURE__*/ Object.freeze({
611
559
  __proto__: null,
612
560
  MATCH_NOTHING_RE: MATCH_NOTHING_RE,
613
561
  IDENT_RE: IDENT_RE,
@@ -635,21 +583,16 @@ var MODES = /*#__PURE__*/Object.freeze({
635
583
  METHOD_GUARD: METHOD_GUARD,
636
584
  END_SAME_AS_BEGIN: END_SAME_AS_BEGIN
637
585
  });
638
-
639
586
  // Grammar extensions / plugins
640
587
  // See: https://github.com/highlightjs/highlight.js/issues/2833
641
-
642
588
  // Grammar extensions allow "syntactic sugar" to be added to the grammar modes
643
589
  // without requiring any underlying changes to the compiler internals.
644
-
645
590
  // `compileMatch` being the perfect small example of now allowing a grammar
646
591
  // author to write `match` when they desire to match a single expression rather
647
592
  // than being forced to use `begin`. The extension then just moves `match` into
648
593
  // `begin` when it runs. Ie, no features have been added, but we've just made
649
594
  // the experience of writing (and reading grammars) a little bit nicer.
650
-
651
595
  // ------
652
-
653
596
  // TODO: We need negative look-behind support to do this properly
654
597
  /**
655
598
  * Skip a match if it has a preceding dot
@@ -661,85 +604,80 @@ var MODES = /*#__PURE__*/Object.freeze({
661
604
  * @param {CallbackResponse} response
662
605
  */
663
606
  function skipIfhasPrecedingDot(match, response) {
664
- const before = match.input[match.index - 1];
665
- if (before === ".") {
666
- response.ignoreMatch();
667
- }
607
+ const before = match.input[match.index - 1];
608
+ if (before === ".") {
609
+ response.ignoreMatch();
610
+ }
668
611
  }
669
-
670
-
671
612
  /**
672
613
  * `beginKeywords` syntactic sugar
673
614
  * @type {CompilerExt}
674
615
  */
675
616
  function beginKeywords(mode, parent) {
676
- if (!parent) return;
677
- if (!mode.beginKeywords) return;
678
-
679
- // for languages with keywords that include non-word characters checking for
680
- // a word boundary is not sufficient, so instead we check for a word boundary
681
- // or whitespace - this does no harm in any case since our keyword engine
682
- // doesn't allow spaces in keywords anyways and we still check for the boundary
683
- // first
684
- mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)';
685
- mode.__beforeBegin = skipIfhasPrecedingDot;
686
- mode.keywords = mode.keywords || mode.beginKeywords;
687
- delete mode.beginKeywords;
688
-
689
- // prevents double relevance, the keywords themselves provide
690
- // relevance, the mode doesn't need to double it
691
- // eslint-disable-next-line no-undefined
692
- if (mode.relevance === undefined) mode.relevance = 0;
617
+ if (!parent)
618
+ return;
619
+ if (!mode.beginKeywords)
620
+ return;
621
+ // for languages with keywords that include non-word characters checking for
622
+ // a word boundary is not sufficient, so instead we check for a word boundary
623
+ // or whitespace - this does no harm in any case since our keyword engine
624
+ // doesn't allow spaces in keywords anyways and we still check for the boundary
625
+ // first
626
+ mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)';
627
+ mode.__beforeBegin = skipIfhasPrecedingDot;
628
+ mode.keywords = mode.keywords || mode.beginKeywords;
629
+ delete mode.beginKeywords;
630
+ // prevents double relevance, the keywords themselves provide
631
+ // relevance, the mode doesn't need to double it
632
+ // eslint-disable-next-line no-undefined
633
+ if (mode.relevance === undefined)
634
+ mode.relevance = 0;
693
635
  }
694
-
695
636
  /**
696
637
  * Allow `illegal` to contain an array of illegal values
697
638
  * @type {CompilerExt}
698
639
  */
699
640
  function compileIllegal(mode, _parent) {
700
- if (!Array.isArray(mode.illegal)) return;
701
-
702
- mode.illegal = either(...mode.illegal);
641
+ if (!Array.isArray(mode.illegal))
642
+ return;
643
+ mode.illegal = either(...mode.illegal);
703
644
  }
704
-
705
645
  /**
706
646
  * `match` to match a single expression for readability
707
647
  * @type {CompilerExt}
708
648
  */
709
649
  function compileMatch(mode, _parent) {
710
- if (!mode.match) return;
711
- if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
712
-
713
- mode.begin = mode.match;
714
- delete mode.match;
650
+ if (!mode.match)
651
+ return;
652
+ if (mode.begin || mode.end)
653
+ throw new Error("begin & end are not supported with match");
654
+ mode.begin = mode.match;
655
+ delete mode.match;
715
656
  }
716
-
717
657
  /**
718
658
  * provides the default 1 relevance to all modes
719
659
  * @type {CompilerExt}
720
660
  */
721
661
  function compileRelevance(mode, _parent) {
722
- // eslint-disable-next-line no-undefined
723
- if (mode.relevance === undefined) mode.relevance = 1;
662
+ // eslint-disable-next-line no-undefined
663
+ if (mode.relevance === undefined)
664
+ mode.relevance = 1;
724
665
  }
725
-
726
666
  // keywords that should have no default relevance value
727
667
  const COMMON_KEYWORDS = [
728
- 'of',
729
- 'and',
730
- 'for',
731
- 'in',
732
- 'not',
733
- 'or',
734
- 'if',
735
- 'then',
736
- 'parent', // common variable name
737
- 'list', // common variable name
738
- 'value' // common variable name
668
+ 'of',
669
+ 'and',
670
+ 'for',
671
+ 'in',
672
+ 'not',
673
+ 'or',
674
+ 'if',
675
+ 'then',
676
+ 'parent', // common variable name
677
+ 'list', // common variable name
678
+ 'value' // common variable name
739
679
  ];
740
-
741
680
  const DEFAULT_KEYWORD_CLASSNAME = "keyword";
742
-
743
681
  /**
744
682
  * Given raw keywords from a language definition, compile them.
745
683
  *
@@ -747,47 +685,42 @@ const DEFAULT_KEYWORD_CLASSNAME = "keyword";
747
685
  * @param {boolean} caseInsensitive
748
686
  */
749
687
  function compileKeywords(rawKeywords, caseInsensitive, className = DEFAULT_KEYWORD_CLASSNAME) {
750
- /** @type KeywordDict */
751
- const compiledKeywords = {};
752
-
753
- // input can be a string of keywords, an array of keywords, or a object with
754
- // named keys representing className (which can then point to a string or array)
755
- if (typeof rawKeywords === 'string') {
756
- compileList(className, rawKeywords.split(" "));
757
- } else if (Array.isArray(rawKeywords)) {
758
- compileList(className, rawKeywords);
759
- } else {
760
- Object.keys(rawKeywords).forEach(function(className) {
761
- // collapse all our objects back into the parent object
762
- Object.assign(
763
- compiledKeywords,
764
- compileKeywords(rawKeywords[className], caseInsensitive, className)
765
- );
766
- });
767
- }
768
- return compiledKeywords;
769
-
770
- // ---
771
-
772
- /**
773
- * Compiles an individual list of keywords
774
- *
775
- * Ex: "for if when while|5"
776
- *
777
- * @param {string} className
778
- * @param {Array<string>} keywordList
779
- */
780
- function compileList(className, keywordList) {
781
- if (caseInsensitive) {
782
- keywordList = keywordList.map(x => x.toLowerCase());
783
- }
784
- keywordList.forEach(function(keyword) {
785
- const pair = keyword.split('|');
786
- compiledKeywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
787
- });
788
- }
688
+ /** @type KeywordDict */
689
+ const compiledKeywords = {};
690
+ // input can be a string of keywords, an array of keywords, or a object with
691
+ // named keys representing className (which can then point to a string or array)
692
+ if (typeof rawKeywords === 'string') {
693
+ compileList(className, rawKeywords.split(" "));
694
+ }
695
+ else if (Array.isArray(rawKeywords)) {
696
+ compileList(className, rawKeywords);
697
+ }
698
+ else {
699
+ Object.keys(rawKeywords).forEach(function (className) {
700
+ // collapse all our objects back into the parent object
701
+ Object.assign(compiledKeywords, compileKeywords(rawKeywords[className], caseInsensitive, className));
702
+ });
703
+ }
704
+ return compiledKeywords;
705
+ // ---
706
+ /**
707
+ * Compiles an individual list of keywords
708
+ *
709
+ * Ex: "for if when while|5"
710
+ *
711
+ * @param {string} className
712
+ * @param {Array<string>} keywordList
713
+ */
714
+ function compileList(className, keywordList) {
715
+ if (caseInsensitive) {
716
+ keywordList = keywordList.map(x => x.toLowerCase());
717
+ }
718
+ keywordList.forEach(function (keyword) {
719
+ const pair = keyword.split('|');
720
+ compiledKeywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
721
+ });
722
+ }
789
723
  }
790
-
791
724
  /**
792
725
  * Returns the proper score for a given keyword
793
726
  *
@@ -797,25 +730,21 @@ function compileKeywords(rawKeywords, caseInsensitive, className = DEFAULT_KEYWO
797
730
  * @param {string} [providedScore]
798
731
  */
799
732
  function scoreForKeyword(keyword, providedScore) {
800
- // manual scores always win over common keywords
801
- // so you can force a score of 1 if you really insist
802
- if (providedScore) {
803
- return Number(providedScore);
804
- }
805
-
806
- return commonKeyword(keyword) ? 0 : 1;
733
+ // manual scores always win over common keywords
734
+ // so you can force a score of 1 if you really insist
735
+ if (providedScore) {
736
+ return Number(providedScore);
737
+ }
738
+ return commonKeyword(keyword) ? 0 : 1;
807
739
  }
808
-
809
740
  /**
810
741
  * Determines if a given keyword is common or not
811
742
  *
812
743
  * @param {string} keyword */
813
744
  function commonKeyword(keyword) {
814
- return COMMON_KEYWORDS.includes(keyword.toLowerCase());
745
+ return COMMON_KEYWORDS.includes(keyword.toLowerCase());
815
746
  }
816
-
817
747
  // compilation
818
-
819
748
  /**
820
749
  * Compiles a language definition result
821
750
  *
@@ -826,351 +755,316 @@ function commonKeyword(keyword) {
826
755
  * @returns {CompiledLanguage}
827
756
  */
828
757
  function compileLanguage(language, { plugins }) {
829
- /**
830
- * Builds a regex with the case sensativility of the current language
831
- *
832
- * @param {RegExp | string} value
833
- * @param {boolean} [global]
834
- */
835
- function langRe(value, global) {
836
- return new RegExp(
837
- source(value),
838
- 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
839
- );
840
- }
841
-
842
- /**
843
- Stores multiple regular expressions and allows you to quickly search for
844
- them all in a string simultaneously - returning the first match. It does
845
- this by creating a huge (a|b|c) regex - each individual item wrapped with ()
846
- and joined by `|` - using match groups to track position. When a match is
847
- found checking which position in the array has content allows us to figure
848
- out which of the original regexes / match groups triggered the match.
849
-
850
- The match object itself (the result of `Regex.exec`) is returned but also
851
- enhanced by merging in any meta-data that was registered with the regex.
852
- This is how we keep track of which mode matched, and what type of rule
853
- (`illegal`, `begin`, end, etc).
854
- */
855
- class MultiRegex {
856
- constructor() {
857
- this.matchIndexes = {};
858
- // @ts-ignore
859
- this.regexes = [];
860
- this.matchAt = 1;
861
- this.position = 0;
862
- }
863
-
864
- // @ts-ignore
865
- addRule(re, opts) {
866
- opts.position = this.position++;
867
- // @ts-ignore
868
- this.matchIndexes[this.matchAt] = opts;
869
- this.regexes.push([opts, re]);
870
- this.matchAt += countMatchGroups(re) + 1;
758
+ /**
759
+ * Builds a regex with the case sensativility of the current language
760
+ *
761
+ * @param {RegExp | string} value
762
+ * @param {boolean} [global]
763
+ */
764
+ function langRe(value, global) {
765
+ return new RegExp(source(value), 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : ''));
871
766
  }
872
-
873
- compile() {
874
- if (this.regexes.length === 0) {
875
- // avoids the need to check length every time exec is called
767
+ /**
768
+ Stores multiple regular expressions and allows you to quickly search for
769
+ them all in a string simultaneously - returning the first match. It does
770
+ this by creating a huge (a|b|c) regex - each individual item wrapped with ()
771
+ and joined by `|` - using match groups to track position. When a match is
772
+ found checking which position in the array has content allows us to figure
773
+ out which of the original regexes / match groups triggered the match.
774
+
775
+ The match object itself (the result of `Regex.exec`) is returned but also
776
+ enhanced by merging in any meta-data that was registered with the regex.
777
+ This is how we keep track of which mode matched, and what type of rule
778
+ (`illegal`, `begin`, end, etc).
779
+ */
780
+ class MultiRegex {
781
+ constructor() {
782
+ this.matchIndexes = {};
783
+ // @ts-ignore
784
+ this.regexes = [];
785
+ this.matchAt = 1;
786
+ this.position = 0;
787
+ }
876
788
  // @ts-ignore
877
- this.exec = () => null;
878
- }
879
- const terminators = this.regexes.map(el => el[1]);
880
- this.matcherRe = langRe(join(terminators), true);
881
- this.lastIndex = 0;
882
- }
883
-
884
- /** @param {string} s */
885
- exec(s) {
886
- this.matcherRe.lastIndex = this.lastIndex;
887
- const match = this.matcherRe.exec(s);
888
- if (!match) { return null; }
889
-
890
- // eslint-disable-next-line no-undefined
891
- const i = match.findIndex((el, i) => i > 0 && el !== undefined);
892
- // @ts-ignore
893
- const matchData = this.matchIndexes[i];
894
- // trim off any earlier non-relevant match groups (ie, the other regex
895
- // match groups that make up the multi-matcher)
896
- match.splice(0, i);
897
-
898
- return Object.assign(match, matchData);
899
- }
900
- }
901
-
902
- /*
903
- Created to solve the key deficiently with MultiRegex - there is no way to
904
- test for multiple matches at a single location. Why would we need to do
905
- that? In the future a more dynamic engine will allow certain matches to be
906
- ignored. An example: if we matched say the 3rd regex in a large group but
907
- decided to ignore it - we'd need to started testing again at the 4th
908
- regex... but MultiRegex itself gives us no real way to do that.
909
-
910
- So what this class creates MultiRegexs on the fly for whatever search
911
- position they are needed.
912
-
913
- NOTE: These additional MultiRegex objects are created dynamically. For most
914
- grammars most of the time we will never actually need anything more than the
915
- first MultiRegex - so this shouldn't have too much overhead.
916
-
917
- Say this is our search group, and we match regex3, but wish to ignore it.
918
-
919
- regex1 | regex2 | regex3 | regex4 | regex5 ' ie, startAt = 0
920
-
921
- What we need is a new MultiRegex that only includes the remaining
922
- possibilities:
923
-
924
- regex4 | regex5 ' ie, startAt = 3
925
-
926
- This class wraps all that complexity up in a simple API... `startAt` decides
927
- where in the array of expressions to start doing the matching. It
928
- auto-increments, so if a match is found at position 2, then startAt will be
929
- set to 3. If the end is reached startAt will return to 0.
930
-
931
- MOST of the time the parser will be setting startAt manually to 0.
932
- */
933
- class ResumableMultiRegex {
934
- constructor() {
935
- // @ts-ignore
936
- this.rules = [];
937
- // @ts-ignore
938
- this.multiRegexes = [];
939
- this.count = 0;
940
-
941
- this.lastIndex = 0;
942
- this.regexIndex = 0;
789
+ addRule(re, opts) {
790
+ opts.position = this.position++;
791
+ // @ts-ignore
792
+ this.matchIndexes[this.matchAt] = opts;
793
+ this.regexes.push([opts, re]);
794
+ this.matchAt += countMatchGroups(re) + 1;
795
+ }
796
+ compile() {
797
+ if (this.regexes.length === 0) {
798
+ // avoids the need to check length every time exec is called
799
+ // @ts-ignore
800
+ this.exec = () => null;
801
+ }
802
+ const terminators = this.regexes.map(el => el[1]);
803
+ this.matcherRe = langRe(join(terminators), true);
804
+ this.lastIndex = 0;
805
+ }
806
+ /** @param {string} s */
807
+ exec(s) {
808
+ this.matcherRe.lastIndex = this.lastIndex;
809
+ const match = this.matcherRe.exec(s);
810
+ if (!match) {
811
+ return null;
812
+ }
813
+ // eslint-disable-next-line no-undefined
814
+ const i = match.findIndex((el, i) => i > 0 && el !== undefined);
815
+ // @ts-ignore
816
+ const matchData = this.matchIndexes[i];
817
+ // trim off any earlier non-relevant match groups (ie, the other regex
818
+ // match groups that make up the multi-matcher)
819
+ match.splice(0, i);
820
+ return Object.assign(match, matchData);
821
+ }
943
822
  }
944
-
945
- // @ts-ignore
946
- getMatcher(index) {
947
- if (this.multiRegexes[index]) return this.multiRegexes[index];
948
-
949
- const matcher = new MultiRegex();
950
- this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
951
- matcher.compile();
952
- this.multiRegexes[index] = matcher;
953
- return matcher;
823
+ /*
824
+ Created to solve the key deficiently with MultiRegex - there is no way to
825
+ test for multiple matches at a single location. Why would we need to do
826
+ that? In the future a more dynamic engine will allow certain matches to be
827
+ ignored. An example: if we matched say the 3rd regex in a large group but
828
+ decided to ignore it - we'd need to started testing again at the 4th
829
+ regex... but MultiRegex itself gives us no real way to do that.
830
+
831
+ So what this class creates MultiRegexs on the fly for whatever search
832
+ position they are needed.
833
+
834
+ NOTE: These additional MultiRegex objects are created dynamically. For most
835
+ grammars most of the time we will never actually need anything more than the
836
+ first MultiRegex - so this shouldn't have too much overhead.
837
+
838
+ Say this is our search group, and we match regex3, but wish to ignore it.
839
+
840
+ regex1 | regex2 | regex3 | regex4 | regex5 ' ie, startAt = 0
841
+
842
+ What we need is a new MultiRegex that only includes the remaining
843
+ possibilities:
844
+
845
+ regex4 | regex5 ' ie, startAt = 3
846
+
847
+ This class wraps all that complexity up in a simple API... `startAt` decides
848
+ where in the array of expressions to start doing the matching. It
849
+ auto-increments, so if a match is found at position 2, then startAt will be
850
+ set to 3. If the end is reached startAt will return to 0.
851
+
852
+ MOST of the time the parser will be setting startAt manually to 0.
853
+ */
854
+ class ResumableMultiRegex {
855
+ constructor() {
856
+ // @ts-ignore
857
+ this.rules = [];
858
+ // @ts-ignore
859
+ this.multiRegexes = [];
860
+ this.count = 0;
861
+ this.lastIndex = 0;
862
+ this.regexIndex = 0;
863
+ }
864
+ // @ts-ignore
865
+ getMatcher(index) {
866
+ if (this.multiRegexes[index])
867
+ return this.multiRegexes[index];
868
+ const matcher = new MultiRegex();
869
+ this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
870
+ matcher.compile();
871
+ this.multiRegexes[index] = matcher;
872
+ return matcher;
873
+ }
874
+ resumingScanAtSamePosition() {
875
+ return this.regexIndex !== 0;
876
+ }
877
+ considerAll() {
878
+ this.regexIndex = 0;
879
+ }
880
+ // @ts-ignore
881
+ addRule(re, opts) {
882
+ this.rules.push([re, opts]);
883
+ if (opts.type === "begin")
884
+ this.count++;
885
+ }
886
+ /** @param {string} s */
887
+ exec(s) {
888
+ const m = this.getMatcher(this.regexIndex);
889
+ m.lastIndex = this.lastIndex;
890
+ let result = m.exec(s);
891
+ // The following is because we have no easy way to say "resume scanning at the
892
+ // existing position but also skip the current rule ONLY". What happens is
893
+ // all prior rules are also skipped which can result in matching the wrong
894
+ // thing. Example of matching "booger":
895
+ // our matcher is [string, "booger", number]
896
+ //
897
+ // ....booger....
898
+ // if "booger" is ignored then we'd really need a regex to scan from the
899
+ // SAME position for only: [string, number] but ignoring "booger" (if it
900
+ // was the first match), a simple resume would scan ahead who knows how
901
+ // far looking only for "number", ignoring potential string matches (or
902
+ // future "booger" matches that might be valid.)
903
+ // So what we do: We execute two matchers, one resuming at the same
904
+ // position, but the second full matcher starting at the position after:
905
+ // /--- resume first regex match here (for [number])
906
+ // |/---- full match here for [string, "booger", number]
907
+ // vv
908
+ // ....booger....
909
+ // Which ever results in a match first is then used. So this 3-4 step
910
+ // process essentially allows us to say "match at this position, excluding
911
+ // a prior rule that was ignored".
912
+ //
913
+ // 1. Match "booger" first, ignore. Also proves that [string] does non match.
914
+ // 2. Resume matching for [number]
915
+ // 3. Match at index + 1 for [string, "booger", number]
916
+ // 4. If #2 and #3 result in matches, which came first?
917
+ if (this.resumingScanAtSamePosition()) {
918
+ if (result && result.index === this.lastIndex)
919
+ ;
920
+ else { // use the second matcher result
921
+ const m2 = this.getMatcher(0);
922
+ m2.lastIndex = this.lastIndex + 1;
923
+ result = m2.exec(s);
924
+ }
925
+ }
926
+ if (result) {
927
+ this.regexIndex += result.position + 1;
928
+ if (this.regexIndex === this.count) {
929
+ // wrap-around to considering all matches again
930
+ this.considerAll();
931
+ }
932
+ }
933
+ return result;
934
+ }
954
935
  }
955
-
956
- resumingScanAtSamePosition() {
957
- return this.regexIndex !== 0;
936
+ /**
937
+ * Given a mode, builds a huge ResumableMultiRegex that can be used to walk
938
+ * the content and find matches.
939
+ *
940
+ * @param {CompiledMode} mode
941
+ * @returns {ResumableMultiRegex}
942
+ */
943
+ function buildModeRegex(mode) {
944
+ const mm = new ResumableMultiRegex();
945
+ mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: "begin" }));
946
+ if (mode.terminatorEnd) {
947
+ mm.addRule(mode.terminatorEnd, { type: "end" });
948
+ }
949
+ if (mode.illegal) {
950
+ mm.addRule(mode.illegal, { type: "illegal" });
951
+ }
952
+ return mm;
958
953
  }
959
-
960
- considerAll() {
961
- this.regexIndex = 0;
954
+ /** skip vs abort vs ignore
955
+ *
956
+ * @skip - The mode is still entered and exited normally (and contains rules apply),
957
+ * but all content is held and added to the parent buffer rather than being
958
+ * output when the mode ends. Mostly used with `sublanguage` to build up
959
+ * a single large buffer than can be parsed by sublanguage.
960
+ *
961
+ * - The mode begin ands ends normally.
962
+ * - Content matched is added to the parent mode buffer.
963
+ * - The parser cursor is moved forward normally.
964
+ *
965
+ * @abort - A hack placeholder until we have ignore. Aborts the mode (as if it
966
+ * never matched) but DOES NOT continue to match subsequent `contains`
967
+ * modes. Abort is bad/suboptimal because it can result in modes
968
+ * farther down not getting applied because an earlier rule eats the
969
+ * content but then aborts.
970
+ *
971
+ * - The mode does not begin.
972
+ * - Content matched by `begin` is added to the mode buffer.
973
+ * - The parser cursor is moved forward accordingly.
974
+ *
975
+ * @ignore - Ignores the mode (as if it never matched) and continues to match any
976
+ * subsequent `contains` modes. Ignore isn't technically possible with
977
+ * the current parser implementation.
978
+ *
979
+ * - The mode does not begin.
980
+ * - Content matched by `begin` is ignored.
981
+ * - The parser cursor is not moved forward.
982
+ */
983
+ /**
984
+ * Compiles an individual mode
985
+ *
986
+ * This can raise an error if the mode contains certain detectable known logic
987
+ * issues.
988
+ * @param {Mode} mode
989
+ * @param {CompiledMode | null} [parent]
990
+ * @returns {CompiledMode | never}
991
+ */
992
+ function compileMode(mode, parent) {
993
+ const cmode = /** @type CompiledMode */ (mode);
994
+ if (mode.isCompiled)
995
+ return cmode;
996
+ [
997
+ // do this early so compiler extensions generally don't have to worry about
998
+ // the distinction between match/begin
999
+ compileMatch
1000
+ ].forEach(ext => ext(mode, parent));
1001
+ language.compilerExtensions.forEach(ext => ext(mode, parent));
1002
+ // __beforeBegin is considered private API, internal use only
1003
+ mode.__beforeBegin = null;
1004
+ [
1005
+ beginKeywords,
1006
+ // do this later so compiler extensions that come earlier have access to the
1007
+ // raw array if they wanted to perhaps manipulate it, etc.
1008
+ compileIllegal,
1009
+ // default to 1 relevance if not specified
1010
+ compileRelevance
1011
+ ].forEach(ext => ext(mode, parent));
1012
+ mode.isCompiled = true;
1013
+ let keywordPattern = null;
1014
+ if (typeof mode.keywords === "object") {
1015
+ keywordPattern = mode.keywords.$pattern;
1016
+ delete mode.keywords.$pattern;
1017
+ }
1018
+ if (mode.keywords) {
1019
+ mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
1020
+ }
1021
+ // both are not allowed
1022
+ if (mode.lexemes && keywordPattern) {
1023
+ throw new Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");
1024
+ }
1025
+ // `mode.lexemes` was the old standard before we added and now recommend
1026
+ // using `keywords.$pattern` to pass the keyword pattern
1027
+ keywordPattern = keywordPattern || mode.lexemes || /\w+/;
1028
+ cmode.keywordPatternRe = langRe(keywordPattern, true);
1029
+ if (parent) {
1030
+ if (!mode.begin)
1031
+ mode.begin = /\B|\b/;
1032
+ cmode.beginRe = langRe(mode.begin);
1033
+ if (mode.endSameAsBegin)
1034
+ mode.end = mode.begin;
1035
+ if (!mode.end && !mode.endsWithParent)
1036
+ mode.end = /\B|\b/;
1037
+ if (mode.end)
1038
+ cmode.endRe = langRe(mode.end);
1039
+ cmode.terminatorEnd = source(mode.end) || '';
1040
+ if (mode.endsWithParent && parent.terminatorEnd) {
1041
+ cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd;
1042
+ }
1043
+ }
1044
+ if (mode.illegal)
1045
+ cmode.illegalRe = langRe(/** @type {RegExp | string} */ (mode.illegal));
1046
+ if (!mode.contains)
1047
+ mode.contains = [];
1048
+ mode.contains = [].concat(...mode.contains.map(function (c) {
1049
+ return expandOrCloneMode(c === 'self' ? mode : c);
1050
+ }));
1051
+ mode.contains.forEach(function (c) { compileMode(/** @type Mode */ (c), cmode); });
1052
+ if (mode.starts) {
1053
+ compileMode(mode.starts, parent);
1054
+ }
1055
+ cmode.matcher = buildModeRegex(cmode);
1056
+ return cmode;
962
1057
  }
963
-
964
- // @ts-ignore
965
- addRule(re, opts) {
966
- this.rules.push([re, opts]);
967
- if (opts.type === "begin") this.count++;
1058
+ if (!language.compilerExtensions)
1059
+ language.compilerExtensions = [];
1060
+ // self is not valid at the top-level
1061
+ if (language.contains && language.contains.includes('self')) {
1062
+ throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
968
1063
  }
969
-
970
- /** @param {string} s */
971
- exec(s) {
972
- const m = this.getMatcher(this.regexIndex);
973
- m.lastIndex = this.lastIndex;
974
- let result = m.exec(s);
975
-
976
- // The following is because we have no easy way to say "resume scanning at the
977
- // existing position but also skip the current rule ONLY". What happens is
978
- // all prior rules are also skipped which can result in matching the wrong
979
- // thing. Example of matching "booger":
980
-
981
- // our matcher is [string, "booger", number]
982
- //
983
- // ....booger....
984
-
985
- // if "booger" is ignored then we'd really need a regex to scan from the
986
- // SAME position for only: [string, number] but ignoring "booger" (if it
987
- // was the first match), a simple resume would scan ahead who knows how
988
- // far looking only for "number", ignoring potential string matches (or
989
- // future "booger" matches that might be valid.)
990
-
991
- // So what we do: We execute two matchers, one resuming at the same
992
- // position, but the second full matcher starting at the position after:
993
-
994
- // /--- resume first regex match here (for [number])
995
- // |/---- full match here for [string, "booger", number]
996
- // vv
997
- // ....booger....
998
-
999
- // Which ever results in a match first is then used. So this 3-4 step
1000
- // process essentially allows us to say "match at this position, excluding
1001
- // a prior rule that was ignored".
1002
- //
1003
- // 1. Match "booger" first, ignore. Also proves that [string] does non match.
1004
- // 2. Resume matching for [number]
1005
- // 3. Match at index + 1 for [string, "booger", number]
1006
- // 4. If #2 and #3 result in matches, which came first?
1007
- if (this.resumingScanAtSamePosition()) {
1008
- if (result && result.index === this.lastIndex) ; else { // use the second matcher result
1009
- const m2 = this.getMatcher(0);
1010
- m2.lastIndex = this.lastIndex + 1;
1011
- result = m2.exec(s);
1012
- }
1013
- }
1014
-
1015
- if (result) {
1016
- this.regexIndex += result.position + 1;
1017
- if (this.regexIndex === this.count) {
1018
- // wrap-around to considering all matches again
1019
- this.considerAll();
1020
- }
1021
- }
1022
-
1023
- return result;
1024
- }
1025
- }
1026
-
1027
- /**
1028
- * Given a mode, builds a huge ResumableMultiRegex that can be used to walk
1029
- * the content and find matches.
1030
- *
1031
- * @param {CompiledMode} mode
1032
- * @returns {ResumableMultiRegex}
1033
- */
1034
- function buildModeRegex(mode) {
1035
- const mm = new ResumableMultiRegex();
1036
-
1037
- mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: "begin" }));
1038
-
1039
- if (mode.terminatorEnd) {
1040
- mm.addRule(mode.terminatorEnd, { type: "end" });
1041
- }
1042
- if (mode.illegal) {
1043
- mm.addRule(mode.illegal, { type: "illegal" });
1044
- }
1045
-
1046
- return mm;
1047
- }
1048
-
1049
- /** skip vs abort vs ignore
1050
- *
1051
- * @skip - The mode is still entered and exited normally (and contains rules apply),
1052
- * but all content is held and added to the parent buffer rather than being
1053
- * output when the mode ends. Mostly used with `sublanguage` to build up
1054
- * a single large buffer than can be parsed by sublanguage.
1055
- *
1056
- * - The mode begin ands ends normally.
1057
- * - Content matched is added to the parent mode buffer.
1058
- * - The parser cursor is moved forward normally.
1059
- *
1060
- * @abort - A hack placeholder until we have ignore. Aborts the mode (as if it
1061
- * never matched) but DOES NOT continue to match subsequent `contains`
1062
- * modes. Abort is bad/suboptimal because it can result in modes
1063
- * farther down not getting applied because an earlier rule eats the
1064
- * content but then aborts.
1065
- *
1066
- * - The mode does not begin.
1067
- * - Content matched by `begin` is added to the mode buffer.
1068
- * - The parser cursor is moved forward accordingly.
1069
- *
1070
- * @ignore - Ignores the mode (as if it never matched) and continues to match any
1071
- * subsequent `contains` modes. Ignore isn't technically possible with
1072
- * the current parser implementation.
1073
- *
1074
- * - The mode does not begin.
1075
- * - Content matched by `begin` is ignored.
1076
- * - The parser cursor is not moved forward.
1077
- */
1078
-
1079
- /**
1080
- * Compiles an individual mode
1081
- *
1082
- * This can raise an error if the mode contains certain detectable known logic
1083
- * issues.
1084
- * @param {Mode} mode
1085
- * @param {CompiledMode | null} [parent]
1086
- * @returns {CompiledMode | never}
1087
- */
1088
- function compileMode(mode, parent) {
1089
- const cmode = /** @type CompiledMode */ (mode);
1090
- if (mode.isCompiled) return cmode;
1091
-
1092
- [
1093
- // do this early so compiler extensions generally don't have to worry about
1094
- // the distinction between match/begin
1095
- compileMatch
1096
- ].forEach(ext => ext(mode, parent));
1097
-
1098
- language.compilerExtensions.forEach(ext => ext(mode, parent));
1099
-
1100
- // __beforeBegin is considered private API, internal use only
1101
- mode.__beforeBegin = null;
1102
-
1103
- [
1104
- beginKeywords,
1105
- // do this later so compiler extensions that come earlier have access to the
1106
- // raw array if they wanted to perhaps manipulate it, etc.
1107
- compileIllegal,
1108
- // default to 1 relevance if not specified
1109
- compileRelevance
1110
- ].forEach(ext => ext(mode, parent));
1111
-
1112
- mode.isCompiled = true;
1113
-
1114
- let keywordPattern = null;
1115
- if (typeof mode.keywords === "object") {
1116
- keywordPattern = mode.keywords.$pattern;
1117
- delete mode.keywords.$pattern;
1118
- }
1119
-
1120
- if (mode.keywords) {
1121
- mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
1122
- }
1123
-
1124
- // both are not allowed
1125
- if (mode.lexemes && keywordPattern) {
1126
- throw new Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");
1127
- }
1128
-
1129
- // `mode.lexemes` was the old standard before we added and now recommend
1130
- // using `keywords.$pattern` to pass the keyword pattern
1131
- keywordPattern = keywordPattern || mode.lexemes || /\w+/;
1132
- cmode.keywordPatternRe = langRe(keywordPattern, true);
1133
-
1134
- if (parent) {
1135
- if (!mode.begin) mode.begin = /\B|\b/;
1136
- cmode.beginRe = langRe(mode.begin);
1137
- if (mode.endSameAsBegin) mode.end = mode.begin;
1138
- if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
1139
- if (mode.end) cmode.endRe = langRe(mode.end);
1140
- cmode.terminatorEnd = source(mode.end) || '';
1141
- if (mode.endsWithParent && parent.terminatorEnd) {
1142
- cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd;
1143
- }
1144
- }
1145
- if (mode.illegal) cmode.illegalRe = langRe(/** @type {RegExp | string} */ (mode.illegal));
1146
- if (!mode.contains) mode.contains = [];
1147
-
1148
- mode.contains = [].concat(...mode.contains.map(function(c) {
1149
- return expandOrCloneMode(c === 'self' ? mode : c);
1150
- }));
1151
- mode.contains.forEach(function(c) { compileMode(/** @type Mode */ (c), cmode); });
1152
-
1153
- if (mode.starts) {
1154
- compileMode(mode.starts, parent);
1155
- }
1156
-
1157
- cmode.matcher = buildModeRegex(cmode);
1158
- return cmode;
1159
- }
1160
-
1161
- if (!language.compilerExtensions) language.compilerExtensions = [];
1162
-
1163
- // self is not valid at the top-level
1164
- if (language.contains && language.contains.includes('self')) {
1165
- throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
1166
- }
1167
-
1168
- // we need a null object, which inherit will guarantee
1169
- language.classNameAliases = inherit(language.classNameAliases || {});
1170
-
1171
- return compileMode(/** @type Mode */ (language));
1064
+ // we need a null object, which inherit will guarantee
1065
+ language.classNameAliases = inherit(language.classNameAliases || {});
1066
+ return compileMode(/** @type Mode */ (language));
1172
1067
  }
1173
-
1174
1068
  /**
1175
1069
  * Determines if a mode has a dependency on it's parent or not
1176
1070
  *
@@ -1183,11 +1077,10 @@ function compileLanguage(language, { plugins }) {
1183
1077
  * @returns {boolean} - is there a dependency on the parent?
1184
1078
  * */
1185
1079
  function dependencyOnParent(mode) {
1186
- if (!mode) return false;
1187
-
1188
- return mode.endsWithParent || dependencyOnParent(mode.starts);
1080
+ if (!mode)
1081
+ return false;
1082
+ return mode.endsWithParent || dependencyOnParent(mode.starts);
1189
1083
  }
1190
-
1191
1084
  /**
1192
1085
  * Expands a mode or clones it if necessary
1193
1086
  *
@@ -1199,1319 +1092,1211 @@ function dependencyOnParent(mode) {
1199
1092
  * @returns {Mode | Mode[]}
1200
1093
  * */
1201
1094
  function expandOrCloneMode(mode) {
1202
- if (mode.variants && !mode.cachedVariants) {
1203
- mode.cachedVariants = mode.variants.map(function(variant) {
1204
- return inherit(mode, { variants: null }, variant);
1205
- });
1206
- }
1207
-
1208
- // EXPAND
1209
- // if we have variants then essentially "replace" the mode with the variants
1210
- // this happens in compileMode, where this function is called from
1211
- if (mode.cachedVariants) {
1212
- return mode.cachedVariants;
1213
- }
1214
-
1215
- // CLONE
1216
- // if we have dependencies on parents then we need a unique
1217
- // instance of ourselves, so we can be reused with many
1218
- // different parents without issue
1219
- if (dependencyOnParent(mode)) {
1220
- return inherit(mode, { starts: mode.starts ? inherit(mode.starts) : null });
1221
- }
1222
-
1223
- if (Object.isFrozen(mode)) {
1224
- return inherit(mode);
1225
- }
1226
-
1227
- // no special dependency issues, just return ourselves
1228
- return mode;
1095
+ if (mode.variants && !mode.cachedVariants) {
1096
+ mode.cachedVariants = mode.variants.map(function (variant) {
1097
+ return inherit(mode, { variants: null }, variant);
1098
+ });
1099
+ }
1100
+ // EXPAND
1101
+ // if we have variants then essentially "replace" the mode with the variants
1102
+ // this happens in compileMode, where this function is called from
1103
+ if (mode.cachedVariants) {
1104
+ return mode.cachedVariants;
1105
+ }
1106
+ // CLONE
1107
+ // if we have dependencies on parents then we need a unique
1108
+ // instance of ourselves, so we can be reused with many
1109
+ // different parents without issue
1110
+ if (dependencyOnParent(mode)) {
1111
+ return inherit(mode, { starts: mode.starts ? inherit(mode.starts) : null });
1112
+ }
1113
+ if (Object.isFrozen(mode)) {
1114
+ return inherit(mode);
1115
+ }
1116
+ // no special dependency issues, just return ourselves
1117
+ return mode;
1229
1118
  }
1230
-
1231
1119
  var version = "10.7.3";
1232
-
1233
1120
  // @ts-nocheck
1234
-
1235
1121
  function hasValueOrEmptyAttribute(value) {
1236
- return Boolean(value || value === "");
1122
+ return Boolean(value || value === "");
1237
1123
  }
1238
-
1239
1124
  function BuildVuePlugin(hljs) {
1240
- const Component = {
1241
- props: ["language", "code", "autodetect"],
1242
- data: function() {
1243
- return {
1244
- detectedLanguage: "",
1245
- unknownLanguage: false
1246
- };
1247
- },
1248
- computed: {
1249
- className() {
1250
- if (this.unknownLanguage) return "";
1251
-
1252
- return "hljs " + this.detectedLanguage;
1253
- },
1254
- highlighted() {
1255
- // no idea what language to use, return raw code
1256
- if (!this.autoDetect && !hljs.getLanguage(this.language)) {
1257
- console.warn(`The language "${this.language}" you specified could not be found.`);
1258
- this.unknownLanguage = true;
1259
- return escapeHTML(this.code);
1125
+ const Component = {
1126
+ props: ["language", "code", "autodetect"],
1127
+ data: function () {
1128
+ return {
1129
+ detectedLanguage: "",
1130
+ unknownLanguage: false
1131
+ };
1132
+ },
1133
+ computed: {
1134
+ className() {
1135
+ if (this.unknownLanguage)
1136
+ return "";
1137
+ return "hljs " + this.detectedLanguage;
1138
+ },
1139
+ highlighted() {
1140
+ // no idea what language to use, return raw code
1141
+ if (!this.autoDetect && !hljs.getLanguage(this.language)) {
1142
+ console.warn(`The language "${this.language}" you specified could not be found.`);
1143
+ this.unknownLanguage = true;
1144
+ return escapeHTML(this.code);
1145
+ }
1146
+ let result = {};
1147
+ if (this.autoDetect) {
1148
+ result = hljs.highlightAuto(this.code);
1149
+ this.detectedLanguage = result.language;
1150
+ }
1151
+ else {
1152
+ result = hljs.highlight(this.language, this.code, this.ignoreIllegals);
1153
+ this.detectedLanguage = this.language;
1154
+ }
1155
+ return result.value;
1156
+ },
1157
+ autoDetect() {
1158
+ return !this.language || hasValueOrEmptyAttribute(this.autodetect);
1159
+ },
1160
+ ignoreIllegals() {
1161
+ return true;
1162
+ }
1163
+ },
1164
+ // this avoids needing to use a whole Vue compilation pipeline just
1165
+ // to build Highlight.js
1166
+ render(createElement) {
1167
+ return createElement("pre", {}, [
1168
+ createElement("code", {
1169
+ class: this.className,
1170
+ domProps: { innerHTML: this.highlighted }
1171
+ })
1172
+ ]);
1260
1173
  }
1261
-
1262
- let result = {};
1263
- if (this.autoDetect) {
1264
- result = hljs.highlightAuto(this.code);
1265
- this.detectedLanguage = result.language;
1266
- } else {
1267
- result = hljs.highlight(this.language, this.code, this.ignoreIllegals);
1268
- this.detectedLanguage = this.language;
1269
- }
1270
- return result.value;
1271
- },
1272
- autoDetect() {
1273
- return !this.language || hasValueOrEmptyAttribute(this.autodetect);
1274
- },
1275
- ignoreIllegals() {
1276
- return true;
1277
- }
1278
- },
1279
- // this avoids needing to use a whole Vue compilation pipeline just
1280
- // to build Highlight.js
1281
- render(createElement) {
1282
- return createElement("pre", {}, [
1283
- createElement("code", {
1284
- class: this.className,
1285
- domProps: { innerHTML: this.highlighted }
1286
- })
1287
- ]);
1288
- }
1289
- // template: `<pre><code :class="className" v-html="highlighted"></code></pre>`
1290
- };
1291
-
1292
- const VuePlugin = {
1293
- install(Vue) {
1294
- Vue.component('highlightjs', Component);
1295
- }
1296
- };
1297
-
1298
- return { Component, VuePlugin };
1174
+ // template: `<pre><code :class="className" v-html="highlighted"></code></pre>`
1175
+ };
1176
+ const VuePlugin = {
1177
+ install(Vue) {
1178
+ Vue.component('highlightjs', Component);
1179
+ }
1180
+ };
1181
+ return { Component, VuePlugin };
1299
1182
  }
1300
-
1301
1183
  /* plugin itself */
1302
-
1303
1184
  /** @type {HLJSPlugin} */
1304
1185
  const mergeHTMLPlugin = {
1305
- "after:highlightElement": ({ el, result, text }) => {
1306
- const originalStream = nodeStream(el);
1307
- if (!originalStream.length) return;
1308
-
1309
- const resultNode = document.createElement('div');
1310
- resultNode.innerHTML = result.value;
1311
- result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
1312
- }
1186
+ "after:highlightElement": ({ el, result, text }) => {
1187
+ const originalStream = nodeStream(el);
1188
+ if (!originalStream.length)
1189
+ return;
1190
+ const resultNode = document.createElement('div');
1191
+ resultNode.innerHTML = result.value;
1192
+ result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
1193
+ }
1313
1194
  };
1314
-
1315
1195
  /* Stream merging support functions */
1316
-
1317
1196
  /**
1318
1197
  * @typedef Event
1319
1198
  * @property {'start'|'stop'} event
1320
1199
  * @property {number} offset
1321
1200
  * @property {Node} node
1322
1201
  */
1323
-
1324
1202
  /**
1325
1203
  * @param {Node} node
1326
1204
  */
1327
1205
  function tag(node) {
1328
- return node.nodeName.toLowerCase();
1206
+ return node.nodeName.toLowerCase();
1329
1207
  }
1330
-
1331
1208
  /**
1332
1209
  * @param {Node} node
1333
1210
  */
1334
1211
  function nodeStream(node) {
1335
- /** @type Event[] */
1336
- const result = [];
1337
- (function _nodeStream(node, offset) {
1338
- for (let child = node.firstChild; child; child = child.nextSibling) {
1339
- if (child.nodeType === 3) {
1340
- offset += child.nodeValue.length;
1341
- } else if (child.nodeType === 1) {
1342
- result.push({
1343
- event: 'start',
1344
- offset: offset,
1345
- node: child
1346
- });
1347
- offset = _nodeStream(child, offset);
1348
- // Prevent void elements from having an end tag that would actually
1349
- // double them in the output. There are more void elements in HTML
1350
- // but we list only those realistically expected in code display.
1351
- if (!tag(child).match(/br|hr|img|input/)) {
1352
- result.push({
1353
- event: 'stop',
1354
- offset: offset,
1355
- node: child
1356
- });
1357
- }
1358
- }
1359
- }
1360
- return offset;
1361
- })(node, 0);
1362
- return result;
1212
+ /** @type Event[] */
1213
+ const result = [];
1214
+ (function _nodeStream(node, offset) {
1215
+ for (let child = node.firstChild; child; child = child.nextSibling) {
1216
+ if (child.nodeType === 3) {
1217
+ offset += child.nodeValue.length;
1218
+ }
1219
+ else if (child.nodeType === 1) {
1220
+ result.push({
1221
+ event: 'start',
1222
+ offset: offset,
1223
+ node: child
1224
+ });
1225
+ offset = _nodeStream(child, offset);
1226
+ // Prevent void elements from having an end tag that would actually
1227
+ // double them in the output. There are more void elements in HTML
1228
+ // but we list only those realistically expected in code display.
1229
+ if (!tag(child).match(/br|hr|img|input/)) {
1230
+ result.push({
1231
+ event: 'stop',
1232
+ offset: offset,
1233
+ node: child
1234
+ });
1235
+ }
1236
+ }
1237
+ }
1238
+ return offset;
1239
+ })(node, 0);
1240
+ return result;
1363
1241
  }
1364
-
1365
1242
  /**
1366
1243
  * @param {any} original - the original stream
1367
1244
  * @param {any} highlighted - stream of the highlighted source
1368
1245
  * @param {string} value - the original source itself
1369
1246
  */
1370
1247
  function mergeStreams(original, highlighted, value) {
1371
- let processed = 0;
1372
- let result = '';
1373
- const nodeStack = [];
1374
-
1375
- function selectStream() {
1376
- if (!original.length || !highlighted.length) {
1377
- return original.length ? original : highlighted;
1248
+ let processed = 0;
1249
+ let result = '';
1250
+ const nodeStack = [];
1251
+ function selectStream() {
1252
+ if (!original.length || !highlighted.length) {
1253
+ return original.length ? original : highlighted;
1254
+ }
1255
+ if (original[0].offset !== highlighted[0].offset) {
1256
+ return (original[0].offset < highlighted[0].offset) ? original : highlighted;
1257
+ }
1258
+ /*
1259
+ To avoid starting the stream just before it should stop the order is
1260
+ ensured that original always starts first and closes last:
1261
+
1262
+ if (event1 == 'start' && event2 == 'start')
1263
+ return original;
1264
+ if (event1 == 'start' && event2 == 'stop')
1265
+ return highlighted;
1266
+ if (event1 == 'stop' && event2 == 'start')
1267
+ return original;
1268
+ if (event1 == 'stop' && event2 == 'stop')
1269
+ return highlighted;
1270
+
1271
+ ... which is collapsed to:
1272
+ */
1273
+ return highlighted[0].event === 'start' ? original : highlighted;
1378
1274
  }
1379
- if (original[0].offset !== highlighted[0].offset) {
1380
- return (original[0].offset < highlighted[0].offset) ? original : highlighted;
1275
+ /**
1276
+ * @param {Node} node
1277
+ */
1278
+ function open(node) {
1279
+ /** @param {Attr} attr */
1280
+ function attributeString(attr) {
1281
+ return ' ' + attr.nodeName + '="' + escapeHTML(attr.value) + '"';
1282
+ }
1283
+ // @ts-ignore
1284
+ result += '<' + tag(node) + [].map.call(node.attributes, attributeString).join('') + '>';
1381
1285
  }
1382
-
1383
- /*
1384
- To avoid starting the stream just before it should stop the order is
1385
- ensured that original always starts first and closes last:
1386
-
1387
- if (event1 == 'start' && event2 == 'start')
1388
- return original;
1389
- if (event1 == 'start' && event2 == 'stop')
1390
- return highlighted;
1391
- if (event1 == 'stop' && event2 == 'start')
1392
- return original;
1393
- if (event1 == 'stop' && event2 == 'stop')
1394
- return highlighted;
1395
-
1396
- ... which is collapsed to:
1397
- */
1398
- return highlighted[0].event === 'start' ? original : highlighted;
1399
- }
1400
-
1401
- /**
1402
- * @param {Node} node
1403
- */
1404
- function open(node) {
1405
- /** @param {Attr} attr */
1406
- function attributeString(attr) {
1407
- return ' ' + attr.nodeName + '="' + escapeHTML(attr.value) + '"';
1408
- }
1409
- // @ts-ignore
1410
- result += '<' + tag(node) + [].map.call(node.attributes, attributeString).join('') + '>';
1411
- }
1412
-
1413
- /**
1414
- * @param {Node} node
1415
- */
1416
- function close(node) {
1417
- result += '</' + tag(node) + '>';
1418
- }
1419
-
1420
- /**
1421
- * @param {Event} event
1422
- */
1423
- function render(event) {
1424
- (event.event === 'start' ? open : close)(event.node);
1425
- }
1426
-
1427
- while (original.length || highlighted.length) {
1428
- let stream = selectStream();
1429
- result += escapeHTML(value.substring(processed, stream[0].offset));
1430
- processed = stream[0].offset;
1431
- if (stream === original) {
1432
- /*
1433
- On any opening or closing tag of the original markup we first close
1434
- the entire highlighted node stack, then render the original tag along
1435
- with all the following original tags at the same offset and then
1436
- reopen all the tags on the highlighted stack.
1437
- */
1438
- nodeStack.reverse().forEach(close);
1439
- do {
1440
- render(stream.splice(0, 1)[0]);
1441
- stream = selectStream();
1442
- } while (stream === original && stream.length && stream[0].offset === processed);
1443
- nodeStack.reverse().forEach(open);
1444
- } else {
1445
- if (stream[0].event === 'start') {
1446
- nodeStack.push(stream[0].node);
1447
- } else {
1448
- nodeStack.pop();
1449
- }
1450
- render(stream.splice(0, 1)[0]);
1451
- }
1452
- }
1453
- return result + escapeHTML(value.substr(processed));
1286
+ /**
1287
+ * @param {Node} node
1288
+ */
1289
+ function close(node) {
1290
+ result += '</' + tag(node) + '>';
1291
+ }
1292
+ /**
1293
+ * @param {Event} event
1294
+ */
1295
+ function render(event) {
1296
+ (event.event === 'start' ? open : close)(event.node);
1297
+ }
1298
+ while (original.length || highlighted.length) {
1299
+ let stream = selectStream();
1300
+ result += escapeHTML(value.substring(processed, stream[0].offset));
1301
+ processed = stream[0].offset;
1302
+ if (stream === original) {
1303
+ /*
1304
+ On any opening or closing tag of the original markup we first close
1305
+ the entire highlighted node stack, then render the original tag along
1306
+ with all the following original tags at the same offset and then
1307
+ reopen all the tags on the highlighted stack.
1308
+ */
1309
+ nodeStack.reverse().forEach(close);
1310
+ do {
1311
+ render(stream.splice(0, 1)[0]);
1312
+ stream = selectStream();
1313
+ } while (stream === original && stream.length && stream[0].offset === processed);
1314
+ nodeStack.reverse().forEach(open);
1315
+ }
1316
+ else {
1317
+ if (stream[0].event === 'start') {
1318
+ nodeStack.push(stream[0].node);
1319
+ }
1320
+ else {
1321
+ nodeStack.pop();
1322
+ }
1323
+ render(stream.splice(0, 1)[0]);
1324
+ }
1325
+ }
1326
+ return result + escapeHTML(value.substr(processed));
1454
1327
  }
1455
-
1456
1328
  /*
1457
1329
 
1458
1330
  For the reasoning behind this please see:
1459
1331
  https://github.com/highlightjs/highlight.js/issues/2880#issuecomment-747275419
1460
1332
 
1461
1333
  */
1462
-
1463
1334
  /**
1464
1335
  * @type {Record<string, boolean>}
1465
1336
  */
1466
1337
  const seenDeprecations = {};
1467
-
1468
1338
  /**
1469
1339
  * @param {string} message
1470
1340
  */
1471
1341
  const error = (message) => {
1472
- console.error(message);
1342
+ console.error(message);
1473
1343
  };
1474
-
1475
1344
  /**
1476
1345
  * @param {string} message
1477
1346
  * @param {any} args
1478
1347
  */
1479
1348
  const warn = (message, ...args) => {
1480
- console.log(`WARN: ${message}`, ...args);
1349
+ console.log(`WARN: ${message}`, ...args);
1481
1350
  };
1482
-
1483
1351
  /**
1484
1352
  * @param {string} version
1485
1353
  * @param {string} message
1486
1354
  */
1487
1355
  const deprecated = (version, message) => {
1488
- if (seenDeprecations[`${version}/${message}`]) return;
1489
-
1490
- console.log(`Deprecated as of ${version}. ${message}`);
1491
- seenDeprecations[`${version}/${message}`] = true;
1356
+ if (seenDeprecations[`${version}/${message}`])
1357
+ return;
1358
+ console.log(`Deprecated as of ${version}. ${message}`);
1359
+ seenDeprecations[`${version}/${message}`] = true;
1492
1360
  };
1493
-
1494
1361
  /*
1495
1362
  Syntax highlighting with language autodetection.
1496
1363
  https://highlightjs.org/
1497
1364
  */
1498
-
1499
1365
  const escape$1 = escapeHTML;
1500
1366
  const inherit$1 = inherit;
1501
1367
  const NO_MATCH = Symbol("nomatch");
1502
-
1503
1368
  /**
1504
1369
  * @param {any} hljs - object that is extended (legacy)
1505
1370
  * @returns {HLJSApi}
1506
1371
  */
1507
- const HLJS = function(hljs) {
1508
- // Global internal variables used within the highlight.js library.
1509
- /** @type {Record<string, Language>} */
1510
- const languages = Object.create(null);
1511
- /** @type {Record<string, string>} */
1512
- const aliases = Object.create(null);
1513
- /** @type {HLJSPlugin[]} */
1514
- const plugins = [];
1515
-
1516
- // safe/production mode - swallows more errors, tries to keep running
1517
- // even if a single syntax or parse hits a fatal error
1518
- let SAFE_MODE = true;
1519
- const fixMarkupRe = /(^(<[^>]+>|\t|)+|\n)/gm;
1520
- const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
1521
- /** @type {Language} */
1522
- const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] };
1523
-
1524
- // Global options used when within external APIs. This is modified when
1525
- // calling the `hljs.configure` function.
1526
- /** @type HLJSOptions */
1527
- let options = {
1528
- noHighlightRe: /^(no-?highlight)$/i,
1529
- languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
1530
- classPrefix: 'hljs-',
1531
- tabReplace: null,
1532
- useBR: false,
1533
- languages: null,
1534
- // beta configuration options, subject to change, welcome to discuss
1535
- // https://github.com/highlightjs/highlight.js/issues/1086
1536
- __emitter: TokenTreeEmitter
1537
- };
1538
-
1539
- /* Utility functions */
1540
-
1541
- /**
1542
- * Tests a language name to see if highlighting should be skipped
1543
- * @param {string} languageName
1544
- */
1545
- function shouldNotHighlight(languageName) {
1546
- return options.noHighlightRe.test(languageName);
1547
- }
1548
-
1549
- /**
1550
- * @param {HighlightedHTMLElement} block - the HTML element to determine language for
1551
- */
1552
- function blockLanguage(block) {
1553
- let classes = block.className + ' ';
1554
-
1555
- classes += block.parentNode ? block.parentNode.className : '';
1556
-
1557
- // language-* takes precedence over non-prefixed class names.
1558
- const match = options.languageDetectRe.exec(classes);
1559
- if (match) {
1560
- const language = getLanguage(match[1]);
1561
- if (!language) {
1562
- warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
1563
- warn("Falling back to no-highlight mode for this block.", block);
1564
- }
1565
- return language ? match[1] : 'no-highlight';
1566
- }
1567
-
1568
- return classes
1569
- .split(/\s+/)
1570
- .find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
1571
- }
1572
-
1573
- /**
1574
- * Core highlighting function.
1575
- *
1576
- * OLD API
1577
- * highlight(lang, code, ignoreIllegals, continuation)
1578
- *
1579
- * NEW API
1580
- * highlight(code, {lang, ignoreIllegals})
1581
- *
1582
- * @param {string} codeOrlanguageName - the language to use for highlighting
1583
- * @param {string | HighlightOptions} optionsOrCode - the code to highlight
1584
- * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1585
- * @param {CompiledMode} [continuation] - current continuation mode, if any
1586
- *
1587
- * @returns {HighlightResult} Result - an object that represents the result
1588
- * @property {string} language - the language name
1589
- * @property {number} relevance - the relevance score
1590
- * @property {string} value - the highlighted HTML code
1591
- * @property {string} code - the original raw code
1592
- * @property {CompiledMode} top - top of the current mode stack
1593
- * @property {boolean} illegal - indicates whether any illegal matches were found
1594
- */
1595
- function highlight(codeOrlanguageName, optionsOrCode, ignoreIllegals, continuation) {
1596
- let code = "";
1597
- let languageName = "";
1598
- if (typeof optionsOrCode === "object") {
1599
- code = codeOrlanguageName;
1600
- ignoreIllegals = optionsOrCode.ignoreIllegals;
1601
- languageName = optionsOrCode.language;
1602
- // continuation not supported at all via the new API
1603
- // eslint-disable-next-line no-undefined
1604
- continuation = undefined;
1605
- } else {
1606
- // old API
1607
- deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
1608
- deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
1609
- languageName = codeOrlanguageName;
1610
- code = optionsOrCode;
1611
- }
1612
-
1613
- /** @type {BeforeHighlightContext} */
1614
- const context = {
1615
- code,
1616
- language: languageName
1372
+ const HLJS = function (hljs) {
1373
+ // Global internal variables used within the highlight.js library.
1374
+ /** @type {Record<string, Language>} */
1375
+ const languages = Object.create(null);
1376
+ /** @type {Record<string, string>} */
1377
+ const aliases = Object.create(null);
1378
+ /** @type {HLJSPlugin[]} */
1379
+ const plugins = [];
1380
+ // safe/production mode - swallows more errors, tries to keep running
1381
+ // even if a single syntax or parse hits a fatal error
1382
+ let SAFE_MODE = true;
1383
+ const fixMarkupRe = /(^(<[^>]+>|\t|)+|\n)/gm;
1384
+ const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
1385
+ /** @type {Language} */
1386
+ const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] };
1387
+ // Global options used when within external APIs. This is modified when
1388
+ // calling the `hljs.configure` function.
1389
+ /** @type HLJSOptions */
1390
+ let options = {
1391
+ noHighlightRe: /^(no-?highlight)$/i,
1392
+ languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
1393
+ classPrefix: 'hljs-',
1394
+ tabReplace: null,
1395
+ useBR: false,
1396
+ languages: null,
1397
+ // beta configuration options, subject to change, welcome to discuss
1398
+ // https://github.com/highlightjs/highlight.js/issues/1086
1399
+ __emitter: TokenTreeEmitter
1617
1400
  };
1618
- // the plugin can change the desired language or the code to be highlighted
1619
- // just be changing the object it was passed
1620
- fire("before:highlight", context);
1621
-
1622
- // a before plugin can usurp the result completely by providing it's own
1623
- // in which case we don't even need to call highlight
1624
- const result = context.result
1625
- ? context.result
1626
- : _highlight(context.language, context.code, ignoreIllegals, continuation);
1627
-
1628
- result.code = context.code;
1629
- // the plugin can change anything in result to suite it
1630
- fire("after:highlight", result);
1631
-
1632
- return result;
1633
- }
1634
-
1635
- /**
1636
- * private highlight that's used internally and does not fire callbacks
1637
- *
1638
- * @param {string} languageName - the language to use for highlighting
1639
- * @param {string} codeToHighlight - the code to highlight
1640
- * @param {boolean?} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1641
- * @param {CompiledMode?} [continuation] - current continuation mode, if any
1642
- * @returns {HighlightResult} - result of the highlight operation
1643
- */
1644
- function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
1401
+ /* Utility functions */
1645
1402
  /**
1646
- * Return keyword data if a match is a keyword
1647
- * @param {CompiledMode} mode - current mode
1648
- * @param {RegExpMatchArray} match - regexp match data
1649
- * @returns {KeywordData | false}
1403
+ * Tests a language name to see if highlighting should be skipped
1404
+ * @param {string} languageName
1650
1405
  */
1651
- function keywordData(mode, match) {
1652
- const matchText = language.case_insensitive ? match[0].toLowerCase() : match[0];
1653
- return Object.prototype.hasOwnProperty.call(mode.keywords, matchText) && mode.keywords[matchText];
1406
+ function shouldNotHighlight(languageName) {
1407
+ return options.noHighlightRe.test(languageName);
1654
1408
  }
1655
-
1656
- function processKeywords() {
1657
- if (!top.keywords) {
1658
- emitter.addText(modeBuffer);
1659
- return;
1660
- }
1661
-
1662
- let lastIndex = 0;
1663
- top.keywordPatternRe.lastIndex = 0;
1664
- let match = top.keywordPatternRe.exec(modeBuffer);
1665
- let buf = "";
1666
-
1667
- while (match) {
1668
- buf += modeBuffer.substring(lastIndex, match.index);
1669
- const data = keywordData(top, match);
1670
- if (data) {
1671
- const [kind, keywordRelevance] = data;
1672
- emitter.addText(buf);
1673
- buf = "";
1674
-
1675
- relevance += keywordRelevance;
1676
- if (kind.startsWith("_")) {
1677
- // _ implied for relevance only, do not highlight
1678
- // by applying a class name
1679
- buf += match[0];
1680
- } else {
1681
- const cssClass = language.classNameAliases[kind] || kind;
1682
- emitter.addKeyword(match[0], cssClass);
1683
- }
1684
- } else {
1685
- buf += match[0];
1686
- }
1687
- lastIndex = top.keywordPatternRe.lastIndex;
1688
- match = top.keywordPatternRe.exec(modeBuffer);
1689
- }
1690
- buf += modeBuffer.substr(lastIndex);
1691
- emitter.addText(buf);
1409
+ /**
1410
+ * @param {HighlightedHTMLElement} block - the HTML element to determine language for
1411
+ */
1412
+ function blockLanguage(block) {
1413
+ let classes = block.className + ' ';
1414
+ classes += block.parentNode ? block.parentNode.className : '';
1415
+ // language-* takes precedence over non-prefixed class names.
1416
+ const match = options.languageDetectRe.exec(classes);
1417
+ if (match) {
1418
+ const language = getLanguage(match[1]);
1419
+ if (!language) {
1420
+ warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
1421
+ warn("Falling back to no-highlight mode for this block.", block);
1422
+ }
1423
+ return language ? match[1] : 'no-highlight';
1424
+ }
1425
+ return classes
1426
+ .split(/\s+/)
1427
+ .find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
1692
1428
  }
1693
-
1694
- function processSubLanguage() {
1695
- if (modeBuffer === "") return;
1696
- /** @type HighlightResult */
1697
- let result = null;
1698
-
1699
- if (typeof top.subLanguage === 'string') {
1700
- if (!languages[top.subLanguage]) {
1701
- emitter.addText(modeBuffer);
1702
- return;
1703
- }
1704
- result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1705
- continuations[top.subLanguage] = /** @type {CompiledMode} */ (result.top);
1706
- } else {
1707
- result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1708
- }
1709
-
1710
- // Counting embedded language score towards the host language may be disabled
1711
- // with zeroing the containing mode relevance. Use case in point is Markdown that
1712
- // allows XML everywhere and makes every XML snippet to have a much larger Markdown
1713
- // score.
1714
- if (top.relevance > 0) {
1715
- relevance += result.relevance;
1716
- }
1717
- emitter.addSublanguage(result.emitter, result.language);
1429
+ /**
1430
+ * Core highlighting function.
1431
+ *
1432
+ * OLD API
1433
+ * highlight(lang, code, ignoreIllegals, continuation)
1434
+ *
1435
+ * NEW API
1436
+ * highlight(code, {lang, ignoreIllegals})
1437
+ *
1438
+ * @param {string} codeOrlanguageName - the language to use for highlighting
1439
+ * @param {string | HighlightOptions} optionsOrCode - the code to highlight
1440
+ * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1441
+ * @param {CompiledMode} [continuation] - current continuation mode, if any
1442
+ *
1443
+ * @returns {HighlightResult} Result - an object that represents the result
1444
+ * @property {string} language - the language name
1445
+ * @property {number} relevance - the relevance score
1446
+ * @property {string} value - the highlighted HTML code
1447
+ * @property {string} code - the original raw code
1448
+ * @property {CompiledMode} top - top of the current mode stack
1449
+ * @property {boolean} illegal - indicates whether any illegal matches were found
1450
+ */
1451
+ function highlight(codeOrlanguageName, optionsOrCode, ignoreIllegals, continuation) {
1452
+ let code = "";
1453
+ let languageName = "";
1454
+ if (typeof optionsOrCode === "object") {
1455
+ code = codeOrlanguageName;
1456
+ ignoreIllegals = optionsOrCode.ignoreIllegals;
1457
+ languageName = optionsOrCode.language;
1458
+ // continuation not supported at all via the new API
1459
+ // eslint-disable-next-line no-undefined
1460
+ continuation = undefined;
1461
+ }
1462
+ else {
1463
+ // old API
1464
+ deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
1465
+ deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
1466
+ languageName = codeOrlanguageName;
1467
+ code = optionsOrCode;
1468
+ }
1469
+ /** @type {BeforeHighlightContext} */
1470
+ const context = {
1471
+ code,
1472
+ language: languageName
1473
+ };
1474
+ // the plugin can change the desired language or the code to be highlighted
1475
+ // just be changing the object it was passed
1476
+ fire("before:highlight", context);
1477
+ // a before plugin can usurp the result completely by providing it's own
1478
+ // in which case we don't even need to call highlight
1479
+ const result = context.result
1480
+ ? context.result
1481
+ : _highlight(context.language, context.code, ignoreIllegals, continuation);
1482
+ result.code = context.code;
1483
+ // the plugin can change anything in result to suite it
1484
+ fire("after:highlight", result);
1485
+ return result;
1718
1486
  }
1719
-
1720
- function processBuffer() {
1721
- if (top.subLanguage != null) {
1722
- processSubLanguage();
1723
- } else {
1724
- processKeywords();
1725
- }
1726
- modeBuffer = '';
1487
+ /**
1488
+ * private highlight that's used internally and does not fire callbacks
1489
+ *
1490
+ * @param {string} languageName - the language to use for highlighting
1491
+ * @param {string} codeToHighlight - the code to highlight
1492
+ * @param {boolean?} [ignoreIllegals] - whether to ignore illegal matches, default is to bail
1493
+ * @param {CompiledMode?} [continuation] - current continuation mode, if any
1494
+ * @returns {HighlightResult} - result of the highlight operation
1495
+ */
1496
+ function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
1497
+ /**
1498
+ * Return keyword data if a match is a keyword
1499
+ * @param {CompiledMode} mode - current mode
1500
+ * @param {RegExpMatchArray} match - regexp match data
1501
+ * @returns {KeywordData | false}
1502
+ */
1503
+ function keywordData(mode, match) {
1504
+ const matchText = language.case_insensitive ? match[0].toLowerCase() : match[0];
1505
+ return Object.prototype.hasOwnProperty.call(mode.keywords, matchText) && mode.keywords[matchText];
1506
+ }
1507
+ function processKeywords() {
1508
+ if (!top.keywords) {
1509
+ emitter.addText(modeBuffer);
1510
+ return;
1511
+ }
1512
+ let lastIndex = 0;
1513
+ top.keywordPatternRe.lastIndex = 0;
1514
+ let match = top.keywordPatternRe.exec(modeBuffer);
1515
+ let buf = "";
1516
+ while (match) {
1517
+ buf += modeBuffer.substring(lastIndex, match.index);
1518
+ const data = keywordData(top, match);
1519
+ if (data) {
1520
+ const [kind, keywordRelevance] = data;
1521
+ emitter.addText(buf);
1522
+ buf = "";
1523
+ relevance += keywordRelevance;
1524
+ if (kind.startsWith("_")) {
1525
+ // _ implied for relevance only, do not highlight
1526
+ // by applying a class name
1527
+ buf += match[0];
1528
+ }
1529
+ else {
1530
+ const cssClass = language.classNameAliases[kind] || kind;
1531
+ emitter.addKeyword(match[0], cssClass);
1532
+ }
1533
+ }
1534
+ else {
1535
+ buf += match[0];
1536
+ }
1537
+ lastIndex = top.keywordPatternRe.lastIndex;
1538
+ match = top.keywordPatternRe.exec(modeBuffer);
1539
+ }
1540
+ buf += modeBuffer.substr(lastIndex);
1541
+ emitter.addText(buf);
1542
+ }
1543
+ function processSubLanguage() {
1544
+ if (modeBuffer === "")
1545
+ return;
1546
+ /** @type HighlightResult */
1547
+ let result = null;
1548
+ if (typeof top.subLanguage === 'string') {
1549
+ if (!languages[top.subLanguage]) {
1550
+ emitter.addText(modeBuffer);
1551
+ return;
1552
+ }
1553
+ result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1554
+ continuations[top.subLanguage] = /** @type {CompiledMode} */ (result.top);
1555
+ }
1556
+ else {
1557
+ result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1558
+ }
1559
+ // Counting embedded language score towards the host language may be disabled
1560
+ // with zeroing the containing mode relevance. Use case in point is Markdown that
1561
+ // allows XML everywhere and makes every XML snippet to have a much larger Markdown
1562
+ // score.
1563
+ if (top.relevance > 0) {
1564
+ relevance += result.relevance;
1565
+ }
1566
+ emitter.addSublanguage(result.emitter, result.language);
1567
+ }
1568
+ function processBuffer() {
1569
+ if (top.subLanguage != null) {
1570
+ processSubLanguage();
1571
+ }
1572
+ else {
1573
+ processKeywords();
1574
+ }
1575
+ modeBuffer = '';
1576
+ }
1577
+ /**
1578
+ * @param {Mode} mode - new mode to start
1579
+ */
1580
+ function startNewMode(mode) {
1581
+ if (mode.className) {
1582
+ emitter.openNode(language.classNameAliases[mode.className] || mode.className);
1583
+ }
1584
+ top = Object.create(mode, { parent: { value: top } });
1585
+ return top;
1586
+ }
1587
+ /**
1588
+ * @param {CompiledMode } mode - the mode to potentially end
1589
+ * @param {RegExpMatchArray} match - the latest match
1590
+ * @param {string} matchPlusRemainder - match plus remainder of content
1591
+ * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode
1592
+ */
1593
+ function endOfMode(mode, match, matchPlusRemainder) {
1594
+ let matched = startsWith(mode.endRe, matchPlusRemainder);
1595
+ if (matched) {
1596
+ if (mode["on:end"]) {
1597
+ const resp = new Response(mode);
1598
+ mode["on:end"](match, resp);
1599
+ if (resp.isMatchIgnored)
1600
+ matched = false;
1601
+ }
1602
+ if (matched) {
1603
+ while (mode.endsParent && mode.parent) {
1604
+ mode = mode.parent;
1605
+ }
1606
+ return mode;
1607
+ }
1608
+ }
1609
+ // even if on:end fires an `ignore` it's still possible
1610
+ // that we might trigger the end node because of a parent mode
1611
+ if (mode.endsWithParent) {
1612
+ return endOfMode(mode.parent, match, matchPlusRemainder);
1613
+ }
1614
+ }
1615
+ /**
1616
+ * Handle matching but then ignoring a sequence of text
1617
+ *
1618
+ * @param {string} lexeme - string containing full match text
1619
+ */
1620
+ function doIgnore(lexeme) {
1621
+ if (top.matcher.regexIndex === 0) {
1622
+ // no more regexs to potentially match here, so we move the cursor forward one
1623
+ // space
1624
+ modeBuffer += lexeme[0];
1625
+ return 1;
1626
+ }
1627
+ else {
1628
+ // no need to move the cursor, we still have additional regexes to try and
1629
+ // match at this very spot
1630
+ resumeScanAtSamePosition = true;
1631
+ return 0;
1632
+ }
1633
+ }
1634
+ /**
1635
+ * Handle the start of a new potential mode match
1636
+ *
1637
+ * @param {EnhancedMatch} match - the current match
1638
+ * @returns {number} how far to advance the parse cursor
1639
+ */
1640
+ function doBeginMatch(match) {
1641
+ const lexeme = match[0];
1642
+ const newMode = match.rule;
1643
+ const resp = new Response(newMode);
1644
+ // first internal before callbacks, then the public ones
1645
+ const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1646
+ for (const cb of beforeCallbacks) {
1647
+ if (!cb)
1648
+ continue;
1649
+ cb(match, resp);
1650
+ if (resp.isMatchIgnored)
1651
+ return doIgnore(lexeme);
1652
+ }
1653
+ if (newMode && newMode.endSameAsBegin) {
1654
+ newMode.endRe = escape(lexeme);
1655
+ }
1656
+ if (newMode.skip) {
1657
+ modeBuffer += lexeme;
1658
+ }
1659
+ else {
1660
+ if (newMode.excludeBegin) {
1661
+ modeBuffer += lexeme;
1662
+ }
1663
+ processBuffer();
1664
+ if (!newMode.returnBegin && !newMode.excludeBegin) {
1665
+ modeBuffer = lexeme;
1666
+ }
1667
+ }
1668
+ startNewMode(newMode);
1669
+ // if (mode["after:begin"]) {
1670
+ // let resp = new Response(mode);
1671
+ // mode["after:begin"](match, resp);
1672
+ // }
1673
+ return newMode.returnBegin ? 0 : lexeme.length;
1674
+ }
1675
+ /**
1676
+ * Handle the potential end of mode
1677
+ *
1678
+ * @param {RegExpMatchArray} match - the current match
1679
+ */
1680
+ function doEndMatch(match) {
1681
+ const lexeme = match[0];
1682
+ const matchPlusRemainder = codeToHighlight.substr(match.index);
1683
+ const endMode = endOfMode(top, match, matchPlusRemainder);
1684
+ if (!endMode) {
1685
+ return NO_MATCH;
1686
+ }
1687
+ const origin = top;
1688
+ if (origin.skip) {
1689
+ modeBuffer += lexeme;
1690
+ }
1691
+ else {
1692
+ if (!(origin.returnEnd || origin.excludeEnd)) {
1693
+ modeBuffer += lexeme;
1694
+ }
1695
+ processBuffer();
1696
+ if (origin.excludeEnd) {
1697
+ modeBuffer = lexeme;
1698
+ }
1699
+ }
1700
+ do {
1701
+ if (top.className) {
1702
+ emitter.closeNode();
1703
+ }
1704
+ if (!top.skip && !top.subLanguage) {
1705
+ relevance += top.relevance;
1706
+ }
1707
+ top = top.parent;
1708
+ } while (top !== endMode.parent);
1709
+ if (endMode.starts) {
1710
+ if (endMode.endSameAsBegin) {
1711
+ endMode.starts.endRe = endMode.endRe;
1712
+ }
1713
+ startNewMode(endMode.starts);
1714
+ }
1715
+ return origin.returnEnd ? 0 : lexeme.length;
1716
+ }
1717
+ function processContinuations() {
1718
+ const list = [];
1719
+ for (let current = top; current !== language; current = current.parent) {
1720
+ if (current.className) {
1721
+ list.unshift(current.className);
1722
+ }
1723
+ }
1724
+ list.forEach(item => emitter.openNode(item));
1725
+ }
1726
+ /** @type {{type?: MatchType, index?: number, rule?: Mode}}} */
1727
+ let lastMatch = {};
1728
+ /**
1729
+ * Process an individual match
1730
+ *
1731
+ * @param {string} textBeforeMatch - text preceeding the match (since the last match)
1732
+ * @param {EnhancedMatch} [match] - the match itself
1733
+ */
1734
+ function processLexeme(textBeforeMatch, match) {
1735
+ const lexeme = match && match[0];
1736
+ // add non-matched text to the current mode buffer
1737
+ modeBuffer += textBeforeMatch;
1738
+ if (lexeme == null) {
1739
+ processBuffer();
1740
+ return 0;
1741
+ }
1742
+ // we've found a 0 width match and we're stuck, so we need to advance
1743
+ // this happens when we have badly behaved rules that have optional matchers to the degree that
1744
+ // sometimes they can end up matching nothing at all
1745
+ // Ref: https://github.com/highlightjs/highlight.js/issues/2140
1746
+ if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1747
+ // spit the "skipped" character that our regex choked on back into the output sequence
1748
+ modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1749
+ if (!SAFE_MODE) {
1750
+ /** @type {AnnotatedError} */
1751
+ const err = new Error('0 width match regex');
1752
+ err.languageName = languageName;
1753
+ err.badRule = lastMatch.rule;
1754
+ throw err;
1755
+ }
1756
+ return 1;
1757
+ }
1758
+ lastMatch = match;
1759
+ if (match.type === "begin") {
1760
+ return doBeginMatch(match);
1761
+ }
1762
+ else if (match.type === "illegal" && !ignoreIllegals) {
1763
+ // illegal match, we do not continue processing
1764
+ /** @type {AnnotatedError} */
1765
+ const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
1766
+ err.mode = top;
1767
+ throw err;
1768
+ }
1769
+ else if (match.type === "end") {
1770
+ const processed = doEndMatch(match);
1771
+ if (processed !== NO_MATCH) {
1772
+ return processed;
1773
+ }
1774
+ }
1775
+ // edge case for when illegal matches $ (end of line) which is technically
1776
+ // a 0 width match but not a begin/end match so it's not caught by the
1777
+ // first handler (when ignoreIllegals is true)
1778
+ if (match.type === "illegal" && lexeme === "") {
1779
+ // advance so we aren't stuck in an infinite loop
1780
+ return 1;
1781
+ }
1782
+ // infinite loops are BAD, this is a last ditch catch all. if we have a
1783
+ // decent number of iterations yet our index (cursor position in our
1784
+ // parsing) still 3x behind our index then something is very wrong
1785
+ // so we bail
1786
+ if (iterations > 100000 && iterations > match.index * 3) {
1787
+ const err = new Error('potential infinite loop, way more iterations than matches');
1788
+ throw err;
1789
+ }
1790
+ /*
1791
+ Why might be find ourselves here? Only one occasion now. An end match that was
1792
+ triggered but could not be completed. When might this happen? When an `endSameasBegin`
1793
+ rule sets the end rule to a specific match. Since the overall mode termination rule that's
1794
+ being used to scan the text isn't recompiled that means that any match that LOOKS like
1795
+ the end (but is not, because it is not an exact match to the beginning) will
1796
+ end up here. A definite end match, but when `doEndMatch` tries to "reapply"
1797
+ the end rule and fails to match, we wind up here, and just silently ignore the end.
1798
+
1799
+ This causes no real harm other than stopping a few times too many.
1800
+ */
1801
+ modeBuffer += lexeme;
1802
+ return lexeme.length;
1803
+ }
1804
+ const language = getLanguage(languageName);
1805
+ if (!language) {
1806
+ error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1807
+ throw new Error('Unknown language: "' + languageName + '"');
1808
+ }
1809
+ const md = compileLanguage(language, { plugins });
1810
+ let result = '';
1811
+ /** @type {CompiledMode} */
1812
+ let top = continuation || md;
1813
+ /** @type Record<string,CompiledMode> */
1814
+ const continuations = {}; // keep continuations for sub-languages
1815
+ const emitter = new options.__emitter(options);
1816
+ processContinuations();
1817
+ let modeBuffer = '';
1818
+ let relevance = 0;
1819
+ let index = 0;
1820
+ let iterations = 0;
1821
+ let resumeScanAtSamePosition = false;
1822
+ try {
1823
+ top.matcher.considerAll();
1824
+ for (;;) {
1825
+ iterations++;
1826
+ if (resumeScanAtSamePosition) {
1827
+ // only regexes not matched previously will now be
1828
+ // considered for a potential match
1829
+ resumeScanAtSamePosition = false;
1830
+ }
1831
+ else {
1832
+ top.matcher.considerAll();
1833
+ }
1834
+ top.matcher.lastIndex = index;
1835
+ const match = top.matcher.exec(codeToHighlight);
1836
+ // console.log("match", match[0], match.rule && match.rule.begin)
1837
+ if (!match)
1838
+ break;
1839
+ const beforeMatch = codeToHighlight.substring(index, match.index);
1840
+ const processedCount = processLexeme(beforeMatch, match);
1841
+ index = match.index + processedCount;
1842
+ }
1843
+ processLexeme(codeToHighlight.substr(index));
1844
+ emitter.closeAllNodes();
1845
+ emitter.finalize();
1846
+ result = emitter.toHTML();
1847
+ return {
1848
+ // avoid possible breakage with v10 clients expecting
1849
+ // this to always be an integer
1850
+ relevance: Math.floor(relevance),
1851
+ value: result,
1852
+ language: languageName,
1853
+ illegal: false,
1854
+ emitter: emitter,
1855
+ top: top
1856
+ };
1857
+ }
1858
+ catch (err) {
1859
+ if (err.message && err.message.includes('Illegal')) {
1860
+ return {
1861
+ illegal: true,
1862
+ illegalBy: {
1863
+ msg: err.message,
1864
+ context: codeToHighlight.slice(index - 100, index + 100),
1865
+ mode: err.mode
1866
+ },
1867
+ sofar: result,
1868
+ relevance: 0,
1869
+ value: escape$1(codeToHighlight),
1870
+ emitter: emitter
1871
+ };
1872
+ }
1873
+ else if (SAFE_MODE) {
1874
+ return {
1875
+ illegal: false,
1876
+ relevance: 0,
1877
+ value: escape$1(codeToHighlight),
1878
+ emitter: emitter,
1879
+ language: languageName,
1880
+ top: top,
1881
+ errorRaised: err
1882
+ };
1883
+ }
1884
+ else {
1885
+ throw err;
1886
+ }
1887
+ }
1727
1888
  }
1728
-
1729
1889
  /**
1730
- * @param {Mode} mode - new mode to start
1890
+ * returns a valid highlight result, without actually doing any actual work,
1891
+ * auto highlight starts with this and it's possible for small snippets that
1892
+ * auto-detection may not find a better match
1893
+ * @param {string} code
1894
+ * @returns {HighlightResult}
1731
1895
  */
1732
- function startNewMode(mode) {
1733
- if (mode.className) {
1734
- emitter.openNode(language.classNameAliases[mode.className] || mode.className);
1735
- }
1736
- top = Object.create(mode, { parent: { value: top } });
1737
- return top;
1896
+ function justTextHighlightResult(code) {
1897
+ const result = {
1898
+ relevance: 0,
1899
+ emitter: new options.__emitter(options),
1900
+ value: escape$1(code),
1901
+ illegal: false,
1902
+ top: PLAINTEXT_LANGUAGE
1903
+ };
1904
+ result.emitter.addText(code);
1905
+ return result;
1738
1906
  }
1739
-
1740
1907
  /**
1741
- * @param {CompiledMode } mode - the mode to potentially end
1742
- * @param {RegExpMatchArray} match - the latest match
1743
- * @param {string} matchPlusRemainder - match plus remainder of content
1744
- * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode
1745
- */
1746
- function endOfMode(mode, match, matchPlusRemainder) {
1747
- let matched = startsWith(mode.endRe, matchPlusRemainder);
1748
-
1749
- if (matched) {
1750
- if (mode["on:end"]) {
1751
- const resp = new Response(mode);
1752
- mode["on:end"](match, resp);
1753
- if (resp.isMatchIgnored) matched = false;
1908
+ Highlighting with language detection. Accepts a string with the code to
1909
+ highlight. Returns an object with the following properties:
1910
+
1911
+ - language (detected language)
1912
+ - relevance (int)
1913
+ - value (an HTML string with highlighting markup)
1914
+ - second_best (object with the same structure for second-best heuristically
1915
+ detected language, may be absent)
1916
+
1917
+ @param {string} code
1918
+ @param {Array<string>} [languageSubset]
1919
+ @returns {AutoHighlightResult}
1920
+ */
1921
+ function highlightAuto(code, languageSubset) {
1922
+ languageSubset = languageSubset || options.languages || Object.keys(languages);
1923
+ const plaintext = justTextHighlightResult(code);
1924
+ const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name => _highlight(name, code, false));
1925
+ results.unshift(plaintext); // plaintext is always an option
1926
+ const sorted = results.sort((a, b) => {
1927
+ // sort base on relevance
1928
+ if (a.relevance !== b.relevance)
1929
+ return b.relevance - a.relevance;
1930
+ // always award the tie to the base language
1931
+ // ie if C++ and Arduino are tied, it's more likely to be C++
1932
+ if (a.language && b.language) {
1933
+ if (getLanguage(a.language).supersetOf === b.language) {
1934
+ return 1;
1935
+ }
1936
+ else if (getLanguage(b.language).supersetOf === a.language) {
1937
+ return -1;
1938
+ }
1939
+ }
1940
+ // otherwise say they are equal, which has the effect of sorting on
1941
+ // relevance while preserving the original ordering - which is how ties
1942
+ // have historically been settled, ie the language that comes first always
1943
+ // wins in the case of a tie
1944
+ return 0;
1945
+ });
1946
+ const [best, secondBest] = sorted;
1947
+ /** @type {AutoHighlightResult} */
1948
+ const result = best;
1949
+ result.second_best = secondBest;
1950
+ return result;
1951
+ }
1952
+ /**
1953
+ Post-processing of the highlighted markup:
1954
+
1955
+ - replace TABs with something more useful
1956
+ - replace real line-breaks with '<br>' for non-pre containers
1957
+
1958
+ @param {string} html
1959
+ @returns {string}
1960
+ */
1961
+ function fixMarkup(html) {
1962
+ if (!(options.tabReplace || options.useBR)) {
1963
+ return html;
1754
1964
  }
1755
-
1756
- if (matched) {
1757
- while (mode.endsParent && mode.parent) {
1758
- mode = mode.parent;
1759
- }
1760
- return mode;
1761
- }
1762
- }
1763
- // even if on:end fires an `ignore` it's still possible
1764
- // that we might trigger the end node because of a parent mode
1765
- if (mode.endsWithParent) {
1766
- return endOfMode(mode.parent, match, matchPlusRemainder);
1767
- }
1965
+ return html.replace(fixMarkupRe, match => {
1966
+ if (match === '\n') {
1967
+ return options.useBR ? '<br>' : match;
1968
+ }
1969
+ else if (options.tabReplace) {
1970
+ return match.replace(/\t/g, options.tabReplace);
1971
+ }
1972
+ return match;
1973
+ });
1768
1974
  }
1769
-
1770
1975
  /**
1771
- * Handle matching but then ignoring a sequence of text
1976
+ * Builds new class name for block given the language name
1772
1977
  *
1773
- * @param {string} lexeme - string containing full match text
1978
+ * @param {HTMLElement} element
1979
+ * @param {string} [currentLang]
1980
+ * @param {string} [resultLang]
1774
1981
  */
1775
- function doIgnore(lexeme) {
1776
- if (top.matcher.regexIndex === 0) {
1777
- // no more regexs to potentially match here, so we move the cursor forward one
1778
- // space
1779
- modeBuffer += lexeme[0];
1780
- return 1;
1781
- } else {
1782
- // no need to move the cursor, we still have additional regexes to try and
1783
- // match at this very spot
1784
- resumeScanAtSamePosition = true;
1785
- return 0;
1786
- }
1982
+ function updateClassName(element, currentLang, resultLang) {
1983
+ const language = currentLang ? aliases[currentLang] : resultLang;
1984
+ element.classList.add("hljs");
1985
+ if (language)
1986
+ element.classList.add(language);
1787
1987
  }
1788
-
1988
+ /** @type {HLJSPlugin} */
1989
+ const brPlugin = {
1990
+ "before:highlightElement": ({ el }) => {
1991
+ if (options.useBR) {
1992
+ el.innerHTML = el.innerHTML.replace(/\n/g, '').replace(/<br[ /]*>/g, '\n');
1993
+ }
1994
+ },
1995
+ "after:highlightElement": ({ result }) => {
1996
+ if (options.useBR) {
1997
+ result.value = result.value.replace(/\n/g, "<br>");
1998
+ }
1999
+ }
2000
+ };
2001
+ const TAB_REPLACE_RE = /^(<[^>]+>|\t)+/gm;
2002
+ /** @type {HLJSPlugin} */
2003
+ const tabReplacePlugin = {
2004
+ "after:highlightElement": ({ result }) => {
2005
+ if (options.tabReplace) {
2006
+ result.value = result.value.replace(TAB_REPLACE_RE, (m) => m.replace(/\t/g, options.tabReplace));
2007
+ }
2008
+ }
2009
+ };
1789
2010
  /**
1790
- * Handle the start of a new potential mode match
2011
+ * Applies highlighting to a DOM node containing code. Accepts a DOM node and
2012
+ * two optional parameters for fixMarkup.
1791
2013
  *
1792
- * @param {EnhancedMatch} match - the current match
1793
- * @returns {number} how far to advance the parse cursor
2014
+ * @param {HighlightedHTMLElement} element - the HTML element to highlight
2015
+ */
2016
+ function highlightElement(element) {
2017
+ /** @type HTMLElement */
2018
+ let node = null;
2019
+ const language = blockLanguage(element);
2020
+ if (shouldNotHighlight(language))
2021
+ return;
2022
+ // support for v10 API
2023
+ fire("before:highlightElement", { el: element, language: language });
2024
+ node = element;
2025
+ const text = node.textContent;
2026
+ const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text);
2027
+ // support for v10 API
2028
+ fire("after:highlightElement", { el: element, result, text });
2029
+ element.innerHTML = result.value;
2030
+ updateClassName(element, language, result.language);
2031
+ element.result = {
2032
+ language: result.language,
2033
+ // TODO: remove with version 11.0
2034
+ re: result.relevance,
2035
+ relavance: result.relevance
2036
+ };
2037
+ if (result.second_best) {
2038
+ element.second_best = {
2039
+ language: result.second_best.language,
2040
+ // TODO: remove with version 11.0
2041
+ re: result.second_best.relevance,
2042
+ relavance: result.second_best.relevance
2043
+ };
2044
+ }
2045
+ }
2046
+ /**
2047
+ * Updates highlight.js global options with the passed options
2048
+ *
2049
+ * @param {Partial<HLJSOptions>} userOptions
1794
2050
  */
1795
- function doBeginMatch(match) {
1796
- const lexeme = match[0];
1797
- const newMode = match.rule;
1798
-
1799
- const resp = new Response(newMode);
1800
- // first internal before callbacks, then the public ones
1801
- const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1802
- for (const cb of beforeCallbacks) {
1803
- if (!cb) continue;
1804
- cb(match, resp);
1805
- if (resp.isMatchIgnored) return doIgnore(lexeme);
1806
- }
1807
-
1808
- if (newMode && newMode.endSameAsBegin) {
1809
- newMode.endRe = escape(lexeme);
1810
- }
1811
-
1812
- if (newMode.skip) {
1813
- modeBuffer += lexeme;
1814
- } else {
1815
- if (newMode.excludeBegin) {
1816
- modeBuffer += lexeme;
1817
- }
1818
- processBuffer();
1819
- if (!newMode.returnBegin && !newMode.excludeBegin) {
1820
- modeBuffer = lexeme;
1821
- }
1822
- }
1823
- startNewMode(newMode);
1824
- // if (mode["after:begin"]) {
1825
- // let resp = new Response(mode);
1826
- // mode["after:begin"](match, resp);
1827
- // }
1828
- return newMode.returnBegin ? 0 : lexeme.length;
2051
+ function configure(userOptions) {
2052
+ if (userOptions.useBR) {
2053
+ deprecated("10.3.0", "'useBR' will be removed entirely in v11.0");
2054
+ deprecated("10.3.0", "Please see https://github.com/highlightjs/highlight.js/issues/2559");
2055
+ }
2056
+ options = inherit$1(options, userOptions);
1829
2057
  }
1830
-
1831
2058
  /**
1832
- * Handle the potential end of mode
2059
+ * Highlights to all <pre><code> blocks on a page
1833
2060
  *
1834
- * @param {RegExpMatchArray} match - the current match
2061
+ * @type {Function & {called?: boolean}}
1835
2062
  */
1836
- function doEndMatch(match) {
1837
- const lexeme = match[0];
1838
- const matchPlusRemainder = codeToHighlight.substr(match.index);
1839
-
1840
- const endMode = endOfMode(top, match, matchPlusRemainder);
1841
- if (!endMode) { return NO_MATCH; }
1842
-
1843
- const origin = top;
1844
- if (origin.skip) {
1845
- modeBuffer += lexeme;
1846
- } else {
1847
- if (!(origin.returnEnd || origin.excludeEnd)) {
1848
- modeBuffer += lexeme;
1849
- }
1850
- processBuffer();
1851
- if (origin.excludeEnd) {
1852
- modeBuffer = lexeme;
1853
- }
1854
- }
1855
- do {
1856
- if (top.className) {
1857
- emitter.closeNode();
1858
- }
1859
- if (!top.skip && !top.subLanguage) {
1860
- relevance += top.relevance;
1861
- }
1862
- top = top.parent;
1863
- } while (top !== endMode.parent);
1864
- if (endMode.starts) {
1865
- if (endMode.endSameAsBegin) {
1866
- endMode.starts.endRe = endMode.endRe;
1867
- }
1868
- startNewMode(endMode.starts);
1869
- }
1870
- return origin.returnEnd ? 0 : lexeme.length;
2063
+ // TODO: remove v12, deprecated
2064
+ const initHighlighting = () => {
2065
+ if (initHighlighting.called)
2066
+ return;
2067
+ initHighlighting.called = true;
2068
+ deprecated("10.6.0", "initHighlighting() is deprecated. Use highlightAll() instead.");
2069
+ const blocks = document.querySelectorAll('pre code');
2070
+ blocks.forEach(highlightElement);
2071
+ };
2072
+ // Higlights all when DOMContentLoaded fires
2073
+ // TODO: remove v12, deprecated
2074
+ function initHighlightingOnLoad() {
2075
+ deprecated("10.6.0", "initHighlightingOnLoad() is deprecated. Use highlightAll() instead.");
2076
+ wantsHighlight = true;
1871
2077
  }
1872
-
1873
- function processContinuations() {
1874
- const list = [];
1875
- for (let current = top; current !== language; current = current.parent) {
1876
- if (current.className) {
1877
- list.unshift(current.className);
2078
+ let wantsHighlight = false;
2079
+ /**
2080
+ * auto-highlights all pre>code elements on the page
2081
+ */
2082
+ function highlightAll() {
2083
+ // if we are called too early in the loading process
2084
+ if (document.readyState === "loading") {
2085
+ wantsHighlight = true;
2086
+ return;
1878
2087
  }
1879
- }
1880
- list.forEach(item => emitter.openNode(item));
2088
+ const blocks = document.querySelectorAll('pre code');
2089
+ blocks.forEach(highlightElement);
2090
+ }
2091
+ function boot() {
2092
+ // if a highlight was requested before DOM was loaded, do now
2093
+ if (wantsHighlight)
2094
+ highlightAll();
2095
+ }
2096
+ // make sure we are in the browser environment
2097
+ if (typeof window !== 'undefined' && window.addEventListener) {
2098
+ window.addEventListener('DOMContentLoaded', boot, false);
1881
2099
  }
1882
-
1883
- /** @type {{type?: MatchType, index?: number, rule?: Mode}}} */
1884
- let lastMatch = {};
1885
-
1886
2100
  /**
1887
- * Process an individual match
2101
+ * Register a language grammar module
1888
2102
  *
1889
- * @param {string} textBeforeMatch - text preceeding the match (since the last match)
1890
- * @param {EnhancedMatch} [match] - the match itself
2103
+ * @param {string} languageName
2104
+ * @param {LanguageFn} languageDefinition
1891
2105
  */
1892
- function processLexeme(textBeforeMatch, match) {
1893
- const lexeme = match && match[0];
1894
-
1895
- // add non-matched text to the current mode buffer
1896
- modeBuffer += textBeforeMatch;
1897
-
1898
- if (lexeme == null) {
1899
- processBuffer();
1900
- return 0;
1901
- }
1902
-
1903
- // we've found a 0 width match and we're stuck, so we need to advance
1904
- // this happens when we have badly behaved rules that have optional matchers to the degree that
1905
- // sometimes they can end up matching nothing at all
1906
- // Ref: https://github.com/highlightjs/highlight.js/issues/2140
1907
- if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1908
- // spit the "skipped" character that our regex choked on back into the output sequence
1909
- modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1910
- if (!SAFE_MODE) {
1911
- /** @type {AnnotatedError} */
1912
- const err = new Error('0 width match regex');
1913
- err.languageName = languageName;
1914
- err.badRule = lastMatch.rule;
1915
- throw err;
1916
- }
1917
- return 1;
1918
- }
1919
- lastMatch = match;
1920
-
1921
- if (match.type === "begin") {
1922
- return doBeginMatch(match);
1923
- } else if (match.type === "illegal" && !ignoreIllegals) {
1924
- // illegal match, we do not continue processing
1925
- /** @type {AnnotatedError} */
1926
- const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
1927
- err.mode = top;
1928
- throw err;
1929
- } else if (match.type === "end") {
1930
- const processed = doEndMatch(match);
1931
- if (processed !== NO_MATCH) {
1932
- return processed;
2106
+ function registerLanguage(languageName, languageDefinition) {
2107
+ let lang = null;
2108
+ try {
2109
+ lang = languageDefinition(hljs);
2110
+ }
2111
+ catch (error$1) {
2112
+ error("Language definition for '{}' could not be registered.".replace("{}", languageName));
2113
+ // hard or soft error
2114
+ if (!SAFE_MODE) {
2115
+ throw error$1;
2116
+ }
2117
+ else {
2118
+ error(error$1);
2119
+ }
2120
+ // languages that have serious errors are replaced with essentially a
2121
+ // "plaintext" stand-in so that the code blocks will still get normal
2122
+ // css classes applied to them - and one bad language won't break the
2123
+ // entire highlighter
2124
+ lang = PLAINTEXT_LANGUAGE;
2125
+ }
2126
+ // give it a temporary name if it doesn't have one in the meta-data
2127
+ if (!lang.name)
2128
+ lang.name = languageName;
2129
+ languages[languageName] = lang;
2130
+ lang.rawDefinition = languageDefinition.bind(null, hljs);
2131
+ if (lang.aliases) {
2132
+ registerAliases(lang.aliases, { languageName });
1933
2133
  }
1934
- }
1935
-
1936
- // edge case for when illegal matches $ (end of line) which is technically
1937
- // a 0 width match but not a begin/end match so it's not caught by the
1938
- // first handler (when ignoreIllegals is true)
1939
- if (match.type === "illegal" && lexeme === "") {
1940
- // advance so we aren't stuck in an infinite loop
1941
- return 1;
1942
- }
1943
-
1944
- // infinite loops are BAD, this is a last ditch catch all. if we have a
1945
- // decent number of iterations yet our index (cursor position in our
1946
- // parsing) still 3x behind our index then something is very wrong
1947
- // so we bail
1948
- if (iterations > 100000 && iterations > match.index * 3) {
1949
- const err = new Error('potential infinite loop, way more iterations than matches');
1950
- throw err;
1951
- }
1952
-
1953
- /*
1954
- Why might be find ourselves here? Only one occasion now. An end match that was
1955
- triggered but could not be completed. When might this happen? When an `endSameasBegin`
1956
- rule sets the end rule to a specific match. Since the overall mode termination rule that's
1957
- being used to scan the text isn't recompiled that means that any match that LOOKS like
1958
- the end (but is not, because it is not an exact match to the beginning) will
1959
- end up here. A definite end match, but when `doEndMatch` tries to "reapply"
1960
- the end rule and fails to match, we wind up here, and just silently ignore the end.
1961
-
1962
- This causes no real harm other than stopping a few times too many.
1963
- */
1964
-
1965
- modeBuffer += lexeme;
1966
- return lexeme.length;
1967
2134
  }
1968
-
1969
- const language = getLanguage(languageName);
1970
- if (!language) {
1971
- error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1972
- throw new Error('Unknown language: "' + languageName + '"');
2135
+ /**
2136
+ * Remove a language grammar module
2137
+ *
2138
+ * @param {string} languageName
2139
+ */
2140
+ function unregisterLanguage(languageName) {
2141
+ delete languages[languageName];
2142
+ for (const alias of Object.keys(aliases)) {
2143
+ if (aliases[alias] === languageName) {
2144
+ delete aliases[alias];
2145
+ }
2146
+ }
1973
2147
  }
1974
-
1975
- const md = compileLanguage(language, { plugins });
1976
- let result = '';
1977
- /** @type {CompiledMode} */
1978
- let top = continuation || md;
1979
- /** @type Record<string,CompiledMode> */
1980
- const continuations = {}; // keep continuations for sub-languages
1981
- const emitter = new options.__emitter(options);
1982
- processContinuations();
1983
- let modeBuffer = '';
1984
- let relevance = 0;
1985
- let index = 0;
1986
- let iterations = 0;
1987
- let resumeScanAtSamePosition = false;
1988
-
1989
- try {
1990
- top.matcher.considerAll();
1991
-
1992
- for (;;) {
1993
- iterations++;
1994
- if (resumeScanAtSamePosition) {
1995
- // only regexes not matched previously will now be
1996
- // considered for a potential match
1997
- resumeScanAtSamePosition = false;
1998
- } else {
1999
- top.matcher.considerAll();
2000
- }
2001
- top.matcher.lastIndex = index;
2002
-
2003
- const match = top.matcher.exec(codeToHighlight);
2004
- // console.log("match", match[0], match.rule && match.rule.begin)
2005
-
2006
- if (!match) break;
2007
-
2008
- const beforeMatch = codeToHighlight.substring(index, match.index);
2009
- const processedCount = processLexeme(beforeMatch, match);
2010
- index = match.index + processedCount;
2011
- }
2012
- processLexeme(codeToHighlight.substr(index));
2013
- emitter.closeAllNodes();
2014
- emitter.finalize();
2015
- result = emitter.toHTML();
2016
-
2017
- return {
2018
- // avoid possible breakage with v10 clients expecting
2019
- // this to always be an integer
2020
- relevance: Math.floor(relevance),
2021
- value: result,
2022
- language: languageName,
2023
- illegal: false,
2024
- emitter: emitter,
2025
- top: top
2026
- };
2027
- } catch (err) {
2028
- if (err.message && err.message.includes('Illegal')) {
2029
- return {
2030
- illegal: true,
2031
- illegalBy: {
2032
- msg: err.message,
2033
- context: codeToHighlight.slice(index - 100, index + 100),
2034
- mode: err.mode
2035
- },
2036
- sofar: result,
2037
- relevance: 0,
2038
- value: escape$1(codeToHighlight),
2039
- emitter: emitter
2040
- };
2041
- } else if (SAFE_MODE) {
2042
- return {
2043
- illegal: false,
2044
- relevance: 0,
2045
- value: escape$1(codeToHighlight),
2046
- emitter: emitter,
2047
- language: languageName,
2048
- top: top,
2049
- errorRaised: err
2050
- };
2051
- } else {
2148
+ /**
2149
+ * @returns {string[]} List of language internal names
2150
+ */
2151
+ function listLanguages() {
2152
+ return Object.keys(languages);
2153
+ }
2154
+ /**
2155
+ intended usage: When one language truly requires another
2156
+
2157
+ Unlike `getLanguage`, this will throw when the requested language
2158
+ is not available.
2159
+
2160
+ @param {string} name - name of the language to fetch/require
2161
+ @returns {Language | never}
2162
+ */
2163
+ function requireLanguage(name) {
2164
+ deprecated("10.4.0", "requireLanguage will be removed entirely in v11.");
2165
+ deprecated("10.4.0", "Please see https://github.com/highlightjs/highlight.js/pull/2844");
2166
+ const lang = getLanguage(name);
2167
+ if (lang) {
2168
+ return lang;
2169
+ }
2170
+ const err = new Error('The \'{}\' language is required, but not loaded.'.replace('{}', name));
2052
2171
  throw err;
2053
- }
2054
2172
  }
2055
- }
2056
-
2057
- /**
2058
- * returns a valid highlight result, without actually doing any actual work,
2059
- * auto highlight starts with this and it's possible for small snippets that
2060
- * auto-detection may not find a better match
2061
- * @param {string} code
2062
- * @returns {HighlightResult}
2063
- */
2064
- function justTextHighlightResult(code) {
2065
- const result = {
2066
- relevance: 0,
2067
- emitter: new options.__emitter(options),
2068
- value: escape$1(code),
2069
- illegal: false,
2070
- top: PLAINTEXT_LANGUAGE
2071
- };
2072
- result.emitter.addText(code);
2073
- return result;
2074
- }
2075
-
2076
- /**
2077
- Highlighting with language detection. Accepts a string with the code to
2078
- highlight. Returns an object with the following properties:
2079
-
2080
- - language (detected language)
2081
- - relevance (int)
2082
- - value (an HTML string with highlighting markup)
2083
- - second_best (object with the same structure for second-best heuristically
2084
- detected language, may be absent)
2085
-
2086
- @param {string} code
2087
- @param {Array<string>} [languageSubset]
2088
- @returns {AutoHighlightResult}
2089
- */
2090
- function highlightAuto(code, languageSubset) {
2091
- languageSubset = languageSubset || options.languages || Object.keys(languages);
2092
- const plaintext = justTextHighlightResult(code);
2093
-
2094
- const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name =>
2095
- _highlight(name, code, false)
2096
- );
2097
- results.unshift(plaintext); // plaintext is always an option
2098
-
2099
- const sorted = results.sort((a, b) => {
2100
- // sort base on relevance
2101
- if (a.relevance !== b.relevance) return b.relevance - a.relevance;
2102
-
2103
- // always award the tie to the base language
2104
- // ie if C++ and Arduino are tied, it's more likely to be C++
2105
- if (a.language && b.language) {
2106
- if (getLanguage(a.language).supersetOf === b.language) {
2107
- return 1;
2108
- } else if (getLanguage(b.language).supersetOf === a.language) {
2109
- return -1;
2110
- }
2111
- }
2112
-
2113
- // otherwise say they are equal, which has the effect of sorting on
2114
- // relevance while preserving the original ordering - which is how ties
2115
- // have historically been settled, ie the language that comes first always
2116
- // wins in the case of a tie
2117
- return 0;
2118
- });
2119
-
2120
- const [best, secondBest] = sorted;
2121
-
2122
- /** @type {AutoHighlightResult} */
2123
- const result = best;
2124
- result.second_best = secondBest;
2125
-
2126
- return result;
2127
- }
2128
-
2129
- /**
2130
- Post-processing of the highlighted markup:
2131
-
2132
- - replace TABs with something more useful
2133
- - replace real line-breaks with '<br>' for non-pre containers
2134
-
2135
- @param {string} html
2136
- @returns {string}
2137
- */
2138
- function fixMarkup(html) {
2139
- if (!(options.tabReplace || options.useBR)) {
2140
- return html;
2173
+ /**
2174
+ * @param {string} name - name of the language to retrieve
2175
+ * @returns {Language | undefined}
2176
+ */
2177
+ function getLanguage(name) {
2178
+ name = (name || '').toLowerCase();
2179
+ return languages[name] || languages[aliases[name]];
2141
2180
  }
2142
-
2143
- return html.replace(fixMarkupRe, match => {
2144
- if (match === '\n') {
2145
- return options.useBR ? '<br>' : match;
2146
- } else if (options.tabReplace) {
2147
- return match.replace(/\t/g, options.tabReplace);
2148
- }
2149
- return match;
2150
- });
2151
- }
2152
-
2153
- /**
2154
- * Builds new class name for block given the language name
2155
- *
2156
- * @param {HTMLElement} element
2157
- * @param {string} [currentLang]
2158
- * @param {string} [resultLang]
2159
- */
2160
- function updateClassName(element, currentLang, resultLang) {
2161
- const language = currentLang ? aliases[currentLang] : resultLang;
2162
-
2163
- element.classList.add("hljs");
2164
- if (language) element.classList.add(language);
2165
- }
2166
-
2167
- /** @type {HLJSPlugin} */
2168
- const brPlugin = {
2169
- "before:highlightElement": ({ el }) => {
2170
- if (options.useBR) {
2171
- el.innerHTML = el.innerHTML.replace(/\n/g, '').replace(/<br[ /]*>/g, '\n');
2172
- }
2173
- },
2174
- "after:highlightElement": ({ result }) => {
2175
- if (options.useBR) {
2176
- result.value = result.value.replace(/\n/g, "<br>");
2177
- }
2178
- }
2179
- };
2180
-
2181
- const TAB_REPLACE_RE = /^(<[^>]+>|\t)+/gm;
2182
- /** @type {HLJSPlugin} */
2183
- const tabReplacePlugin = {
2184
- "after:highlightElement": ({ result }) => {
2185
- if (options.tabReplace) {
2186
- result.value = result.value.replace(TAB_REPLACE_RE, (m) =>
2187
- m.replace(/\t/g, options.tabReplace)
2188
- );
2189
- }
2190
- }
2191
- };
2192
-
2193
- /**
2194
- * Applies highlighting to a DOM node containing code. Accepts a DOM node and
2195
- * two optional parameters for fixMarkup.
2196
- *
2197
- * @param {HighlightedHTMLElement} element - the HTML element to highlight
2198
- */
2199
- function highlightElement(element) {
2200
- /** @type HTMLElement */
2201
- let node = null;
2202
- const language = blockLanguage(element);
2203
-
2204
- if (shouldNotHighlight(language)) return;
2205
-
2206
- // support for v10 API
2207
- fire("before:highlightElement",
2208
- { el: element, language: language });
2209
-
2210
- node = element;
2211
- const text = node.textContent;
2212
- const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text);
2213
-
2214
- // support for v10 API
2215
- fire("after:highlightElement", { el: element, result, text });
2216
-
2217
- element.innerHTML = result.value;
2218
- updateClassName(element, language, result.language);
2219
- element.result = {
2220
- language: result.language,
2221
- // TODO: remove with version 11.0
2222
- re: result.relevance,
2223
- relavance: result.relevance
2224
- };
2225
- if (result.second_best) {
2226
- element.second_best = {
2227
- language: result.second_best.language,
2228
- // TODO: remove with version 11.0
2229
- re: result.second_best.relevance,
2230
- relavance: result.second_best.relevance
2231
- };
2232
- }
2233
- }
2234
-
2235
- /**
2236
- * Updates highlight.js global options with the passed options
2237
- *
2238
- * @param {Partial<HLJSOptions>} userOptions
2239
- */
2240
- function configure(userOptions) {
2241
- if (userOptions.useBR) {
2242
- deprecated("10.3.0", "'useBR' will be removed entirely in v11.0");
2243
- deprecated("10.3.0", "Please see https://github.com/highlightjs/highlight.js/issues/2559");
2244
- }
2245
- options = inherit$1(options, userOptions);
2246
- }
2247
-
2248
- /**
2249
- * Highlights to all <pre><code> blocks on a page
2250
- *
2251
- * @type {Function & {called?: boolean}}
2252
- */
2253
- // TODO: remove v12, deprecated
2254
- const initHighlighting = () => {
2255
- if (initHighlighting.called) return;
2256
- initHighlighting.called = true;
2257
-
2258
- deprecated("10.6.0", "initHighlighting() is deprecated. Use highlightAll() instead.");
2259
-
2260
- const blocks = document.querySelectorAll('pre code');
2261
- blocks.forEach(highlightElement);
2262
- };
2263
-
2264
- // Higlights all when DOMContentLoaded fires
2265
- // TODO: remove v12, deprecated
2266
- function initHighlightingOnLoad() {
2267
- deprecated("10.6.0", "initHighlightingOnLoad() is deprecated. Use highlightAll() instead.");
2268
- wantsHighlight = true;
2269
- }
2270
-
2271
- let wantsHighlight = false;
2272
-
2273
- /**
2274
- * auto-highlights all pre>code elements on the page
2275
- */
2276
- function highlightAll() {
2277
- // if we are called too early in the loading process
2278
- if (document.readyState === "loading") {
2279
- wantsHighlight = true;
2280
- return;
2181
+ /**
2182
+ *
2183
+ * @param {string|string[]} aliasList - single alias or list of aliases
2184
+ * @param {{languageName: string}} opts
2185
+ */
2186
+ function registerAliases(aliasList, { languageName }) {
2187
+ if (typeof aliasList === 'string') {
2188
+ aliasList = [aliasList];
2189
+ }
2190
+ aliasList.forEach(alias => { aliases[alias.toLowerCase()] = languageName; });
2281
2191
  }
2282
-
2283
- const blocks = document.querySelectorAll('pre code');
2284
- blocks.forEach(highlightElement);
2285
- }
2286
-
2287
- function boot() {
2288
- // if a highlight was requested before DOM was loaded, do now
2289
- if (wantsHighlight) highlightAll();
2290
- }
2291
-
2292
- // make sure we are in the browser environment
2293
- if (typeof window !== 'undefined' && window.addEventListener) {
2294
- window.addEventListener('DOMContentLoaded', boot, false);
2295
- }
2296
-
2297
- /**
2298
- * Register a language grammar module
2299
- *
2300
- * @param {string} languageName
2301
- * @param {LanguageFn} languageDefinition
2302
- */
2303
- function registerLanguage(languageName, languageDefinition) {
2304
- let lang = null;
2305
- try {
2306
- lang = languageDefinition(hljs);
2307
- } catch (error$1) {
2308
- error("Language definition for '{}' could not be registered.".replace("{}", languageName));
2309
- // hard or soft error
2310
- if (!SAFE_MODE) { throw error$1; } else { error(error$1); }
2311
- // languages that have serious errors are replaced with essentially a
2312
- // "plaintext" stand-in so that the code blocks will still get normal
2313
- // css classes applied to them - and one bad language won't break the
2314
- // entire highlighter
2315
- lang = PLAINTEXT_LANGUAGE;
2316
- }
2317
- // give it a temporary name if it doesn't have one in the meta-data
2318
- if (!lang.name) lang.name = languageName;
2319
- languages[languageName] = lang;
2320
- lang.rawDefinition = languageDefinition.bind(null, hljs);
2321
-
2322
- if (lang.aliases) {
2323
- registerAliases(lang.aliases, { languageName });
2192
+ /**
2193
+ * Determines if a given language has auto-detection enabled
2194
+ * @param {string} name - name of the language
2195
+ */
2196
+ function autoDetection(name) {
2197
+ const lang = getLanguage(name);
2198
+ return lang && !lang.disableAutodetect;
2324
2199
  }
2325
- }
2326
-
2327
- /**
2328
- * Remove a language grammar module
2329
- *
2330
- * @param {string} languageName
2331
- */
2332
- function unregisterLanguage(languageName) {
2333
- delete languages[languageName];
2334
- for (const alias of Object.keys(aliases)) {
2335
- if (aliases[alias] === languageName) {
2336
- delete aliases[alias];
2337
- }
2338
- }
2339
- }
2340
-
2341
- /**
2342
- * @returns {string[]} List of language internal names
2343
- */
2344
- function listLanguages() {
2345
- return Object.keys(languages);
2346
- }
2347
-
2348
- /**
2349
- intended usage: When one language truly requires another
2350
-
2351
- Unlike `getLanguage`, this will throw when the requested language
2352
- is not available.
2353
-
2354
- @param {string} name - name of the language to fetch/require
2355
- @returns {Language | never}
2356
- */
2357
- function requireLanguage(name) {
2358
- deprecated("10.4.0", "requireLanguage will be removed entirely in v11.");
2359
- deprecated("10.4.0", "Please see https://github.com/highlightjs/highlight.js/pull/2844");
2360
-
2361
- const lang = getLanguage(name);
2362
- if (lang) { return lang; }
2363
-
2364
- const err = new Error('The \'{}\' language is required, but not loaded.'.replace('{}', name));
2365
- throw err;
2366
- }
2367
-
2368
- /**
2369
- * @param {string} name - name of the language to retrieve
2370
- * @returns {Language | undefined}
2371
- */
2372
- function getLanguage(name) {
2373
- name = (name || '').toLowerCase();
2374
- return languages[name] || languages[aliases[name]];
2375
- }
2376
-
2377
- /**
2378
- *
2379
- * @param {string|string[]} aliasList - single alias or list of aliases
2380
- * @param {{languageName: string}} opts
2381
- */
2382
- function registerAliases(aliasList, { languageName }) {
2383
- if (typeof aliasList === 'string') {
2384
- aliasList = [aliasList];
2385
- }
2386
- aliasList.forEach(alias => { aliases[alias.toLowerCase()] = languageName; });
2387
- }
2388
-
2389
- /**
2390
- * Determines if a given language has auto-detection enabled
2391
- * @param {string} name - name of the language
2392
- */
2393
- function autoDetection(name) {
2394
- const lang = getLanguage(name);
2395
- return lang && !lang.disableAutodetect;
2396
- }
2397
-
2398
- /**
2399
- * Upgrades the old highlightBlock plugins to the new
2400
- * highlightElement API
2401
- * @param {HLJSPlugin} plugin
2402
- */
2403
- function upgradePluginAPI(plugin) {
2404
- // TODO: remove with v12
2405
- if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
2406
- plugin["before:highlightElement"] = (data) => {
2407
- plugin["before:highlightBlock"](
2408
- Object.assign({ block: data.el }, data)
2409
- );
2410
- };
2411
- }
2412
- if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
2413
- plugin["after:highlightElement"] = (data) => {
2414
- plugin["after:highlightBlock"](
2415
- Object.assign({ block: data.el }, data)
2416
- );
2417
- };
2418
- }
2419
- }
2420
-
2421
- /**
2422
- * @param {HLJSPlugin} plugin
2423
- */
2424
- function addPlugin(plugin) {
2425
- upgradePluginAPI(plugin);
2426
- plugins.push(plugin);
2427
- }
2428
-
2429
- /**
2430
- *
2431
- * @param {PluginEvent} event
2432
- * @param {any} args
2433
- */
2434
- function fire(event, args) {
2435
- const cb = event;
2436
- plugins.forEach(function(plugin) {
2437
- if (plugin[cb]) {
2438
- plugin[cb](args);
2439
- }
2200
+ /**
2201
+ * Upgrades the old highlightBlock plugins to the new
2202
+ * highlightElement API
2203
+ * @param {HLJSPlugin} plugin
2204
+ */
2205
+ function upgradePluginAPI(plugin) {
2206
+ // TODO: remove with v12
2207
+ if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
2208
+ plugin["before:highlightElement"] = (data) => {
2209
+ plugin["before:highlightBlock"](Object.assign({ block: data.el }, data));
2210
+ };
2211
+ }
2212
+ if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
2213
+ plugin["after:highlightElement"] = (data) => {
2214
+ plugin["after:highlightBlock"](Object.assign({ block: data.el }, data));
2215
+ };
2216
+ }
2217
+ }
2218
+ /**
2219
+ * @param {HLJSPlugin} plugin
2220
+ */
2221
+ function addPlugin(plugin) {
2222
+ upgradePluginAPI(plugin);
2223
+ plugins.push(plugin);
2224
+ }
2225
+ /**
2226
+ *
2227
+ * @param {PluginEvent} event
2228
+ * @param {any} args
2229
+ */
2230
+ function fire(event, args) {
2231
+ const cb = event;
2232
+ plugins.forEach(function (plugin) {
2233
+ if (plugin[cb]) {
2234
+ plugin[cb](args);
2235
+ }
2236
+ });
2237
+ }
2238
+ /**
2239
+ Note: fixMarkup is deprecated and will be removed entirely in v11
2240
+
2241
+ @param {string} arg
2242
+ @returns {string}
2243
+ */
2244
+ function deprecateFixMarkup(arg) {
2245
+ deprecated("10.2.0", "fixMarkup will be removed entirely in v11.0");
2246
+ deprecated("10.2.0", "Please see https://github.com/highlightjs/highlight.js/issues/2534");
2247
+ return fixMarkup(arg);
2248
+ }
2249
+ /**
2250
+ *
2251
+ * @param {HighlightedHTMLElement} el
2252
+ */
2253
+ function deprecateHighlightBlock(el) {
2254
+ deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
2255
+ deprecated("10.7.0", "Please use highlightElement now.");
2256
+ return highlightElement(el);
2257
+ }
2258
+ /* Interface definition */
2259
+ Object.assign(hljs, {
2260
+ highlight,
2261
+ highlightAuto,
2262
+ highlightAll,
2263
+ fixMarkup: deprecateFixMarkup,
2264
+ highlightElement,
2265
+ // TODO: Remove with v12 API
2266
+ highlightBlock: deprecateHighlightBlock,
2267
+ configure,
2268
+ initHighlighting,
2269
+ initHighlightingOnLoad,
2270
+ registerLanguage,
2271
+ unregisterLanguage,
2272
+ listLanguages,
2273
+ getLanguage,
2274
+ registerAliases,
2275
+ requireLanguage,
2276
+ autoDetection,
2277
+ inherit: inherit$1,
2278
+ addPlugin,
2279
+ // plugins for frameworks
2280
+ vuePlugin: BuildVuePlugin(hljs).VuePlugin
2440
2281
  });
2441
- }
2442
-
2443
- /**
2444
- Note: fixMarkup is deprecated and will be removed entirely in v11
2445
-
2446
- @param {string} arg
2447
- @returns {string}
2448
- */
2449
- function deprecateFixMarkup(arg) {
2450
- deprecated("10.2.0", "fixMarkup will be removed entirely in v11.0");
2451
- deprecated("10.2.0", "Please see https://github.com/highlightjs/highlight.js/issues/2534");
2452
-
2453
- return fixMarkup(arg);
2454
- }
2455
-
2456
- /**
2457
- *
2458
- * @param {HighlightedHTMLElement} el
2459
- */
2460
- function deprecateHighlightBlock(el) {
2461
- deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
2462
- deprecated("10.7.0", "Please use highlightElement now.");
2463
-
2464
- return highlightElement(el);
2465
- }
2466
-
2467
- /* Interface definition */
2468
- Object.assign(hljs, {
2469
- highlight,
2470
- highlightAuto,
2471
- highlightAll,
2472
- fixMarkup: deprecateFixMarkup,
2473
- highlightElement,
2474
- // TODO: Remove with v12 API
2475
- highlightBlock: deprecateHighlightBlock,
2476
- configure,
2477
- initHighlighting,
2478
- initHighlightingOnLoad,
2479
- registerLanguage,
2480
- unregisterLanguage,
2481
- listLanguages,
2482
- getLanguage,
2483
- registerAliases,
2484
- requireLanguage,
2485
- autoDetection,
2486
- inherit: inherit$1,
2487
- addPlugin,
2488
- // plugins for frameworks
2489
- vuePlugin: BuildVuePlugin(hljs).VuePlugin
2490
- });
2491
-
2492
- hljs.debugMode = function() { SAFE_MODE = false; };
2493
- hljs.safeMode = function() { SAFE_MODE = true; };
2494
- hljs.versionString = version;
2495
-
2496
- for (const key in MODES) {
2497
- // @ts-ignore
2498
- if (typeof MODES[key] === "object") {
2499
- // @ts-ignore
2500
- deepFreezeEs6(MODES[key]);
2282
+ hljs.debugMode = function () { SAFE_MODE = false; };
2283
+ hljs.safeMode = function () { SAFE_MODE = true; };
2284
+ hljs.versionString = version;
2285
+ for (const key in MODES) {
2286
+ // @ts-ignore
2287
+ if (typeof MODES[key] === "object") {
2288
+ // @ts-ignore
2289
+ deepFreezeEs6(MODES[key]);
2290
+ }
2501
2291
  }
2502
- }
2503
-
2504
- // merge all the modes/regexs into our main object
2505
- Object.assign(hljs, MODES);
2506
-
2507
- // built-in plugins, likely to be moved out of core in the future
2508
- hljs.addPlugin(brPlugin); // slated to be removed in v11
2509
- hljs.addPlugin(mergeHTMLPlugin);
2510
- hljs.addPlugin(tabReplacePlugin);
2511
- return hljs;
2292
+ // merge all the modes/regexs into our main object
2293
+ Object.assign(hljs, MODES);
2294
+ // built-in plugins, likely to be moved out of core in the future
2295
+ hljs.addPlugin(brPlugin); // slated to be removed in v11
2296
+ hljs.addPlugin(mergeHTMLPlugin);
2297
+ hljs.addPlugin(tabReplacePlugin);
2298
+ return hljs;
2512
2299
  };
2513
-
2514
2300
  // export an "instance" of the highlighter
2515
2301
  var highlight = HLJS({});
2516
-
2517
2302
  module.exports = highlight;