svelte-highlight 7.9.0 → 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (466) hide show
  1. package/Highlight.svelte +2 -2
  2. package/HighlightAuto.svelte +2 -2
  3. package/HighlightSvelte.svelte +9 -9
  4. package/LangTag.svelte +2 -18
  5. package/LineNumbers.svelte +15 -2
  6. package/LineNumbers.svelte.d.ts +72 -63
  7. package/README.md +27 -0
  8. package/index.d.ts +2 -2
  9. package/index.js +1 -1
  10. package/langtag.css +17 -0
  11. package/languages/astro.d.ts +2 -0
  12. package/languages/astro.js +57 -0
  13. package/languages/html.d.ts +2 -0
  14. package/languages/html.js +140 -0
  15. package/languages/index.d.ts +18 -12
  16. package/languages/index.js +9 -6
  17. package/languages/svelte.d.ts +2 -0
  18. package/languages/svelte.js +122 -0
  19. package/package.json +3 -2
  20. package/styles/1c-light.css +9 -61
  21. package/styles/3024.css +10 -78
  22. package/styles/3024.js +2 -7
  23. package/styles/a11y-dark.css +10 -56
  24. package/styles/a11y-light.css +9 -59
  25. package/styles/a11y-light.js +1 -7
  26. package/styles/agate.css +15 -90
  27. package/styles/an-old-hope.css +8 -46
  28. package/styles/androidstudio.css +9 -50
  29. package/styles/apathy.css +10 -78
  30. package/styles/apathy.js +2 -7
  31. package/styles/apprentice.css +10 -78
  32. package/styles/apprentice.js +2 -7
  33. package/styles/arduino-light.css +6 -57
  34. package/styles/arta.css +9 -50
  35. package/styles/ascetic.css +4 -27
  36. package/styles/ashes.css +10 -78
  37. package/styles/ashes.js +2 -7
  38. package/styles/atelier-cave-light.css +10 -78
  39. package/styles/atelier-cave-light.js +2 -7
  40. package/styles/atelier-cave.css +10 -78
  41. package/styles/atelier-cave.js +2 -7
  42. package/styles/atelier-dune-light.css +10 -78
  43. package/styles/atelier-dune-light.js +2 -7
  44. package/styles/atelier-dune.css +10 -78
  45. package/styles/atelier-dune.js +2 -7
  46. package/styles/atelier-estuary-light.css +10 -78
  47. package/styles/atelier-estuary-light.js +2 -7
  48. package/styles/atelier-estuary.css +10 -78
  49. package/styles/atelier-estuary.js +2 -7
  50. package/styles/atelier-forest-light.css +10 -78
  51. package/styles/atelier-forest-light.js +2 -7
  52. package/styles/atelier-forest.css +10 -78
  53. package/styles/atelier-forest.js +2 -7
  54. package/styles/atelier-heath-light.css +10 -78
  55. package/styles/atelier-heath-light.js +2 -7
  56. package/styles/atelier-heath.css +10 -78
  57. package/styles/atelier-heath.js +2 -7
  58. package/styles/atelier-lakeside-light.css +10 -78
  59. package/styles/atelier-lakeside-light.js +2 -7
  60. package/styles/atelier-lakeside.css +10 -78
  61. package/styles/atelier-lakeside.js +2 -7
  62. package/styles/atelier-plateau-light.css +10 -78
  63. package/styles/atelier-plateau-light.js +2 -7
  64. package/styles/atelier-plateau.css +10 -78
  65. package/styles/atelier-plateau.js +2 -7
  66. package/styles/atelier-savanna-light.css +10 -78
  67. package/styles/atelier-savanna-light.js +2 -7
  68. package/styles/atelier-savanna.css +10 -78
  69. package/styles/atelier-savanna.js +2 -7
  70. package/styles/atelier-seaside-light.css +10 -78
  71. package/styles/atelier-seaside-light.js +2 -7
  72. package/styles/atelier-seaside.css +10 -78
  73. package/styles/atelier-seaside.js +2 -7
  74. package/styles/atelier-sulphurpool-light.css +10 -78
  75. package/styles/atelier-sulphurpool-light.js +2 -7
  76. package/styles/atelier-sulphurpool.css +10 -78
  77. package/styles/atelier-sulphurpool.js +2 -7
  78. package/styles/atlas.css +10 -78
  79. package/styles/atlas.js +2 -7
  80. package/styles/atom-one-dark-reasonable.css +8 -77
  81. package/styles/atom-one-dark-reasonable.js +1 -2
  82. package/styles/atom-one-dark.css +8 -53
  83. package/styles/atom-one-light.css +8 -53
  84. package/styles/base16-github.css +8 -81
  85. package/styles/base16-github.js +2 -14
  86. package/styles/base16-ir-black.css +10 -78
  87. package/styles/base16-ir-black.js +2 -7
  88. package/styles/base16-monokai.css +10 -78
  89. package/styles/base16-monokai.js +2 -7
  90. package/styles/base16-nord.css +10 -78
  91. package/styles/base16-nord.js +2 -7
  92. package/styles/bespin.css +10 -78
  93. package/styles/bespin.js +2 -7
  94. package/styles/black-metal-bathory.css +10 -78
  95. package/styles/black-metal-bathory.js +2 -7
  96. package/styles/black-metal-burzum.css +10 -78
  97. package/styles/black-metal-burzum.js +2 -7
  98. package/styles/black-metal-dark-funeral.css +10 -78
  99. package/styles/black-metal-dark-funeral.js +2 -7
  100. package/styles/black-metal-gorgoroth.css +10 -78
  101. package/styles/black-metal-gorgoroth.js +2 -7
  102. package/styles/black-metal-immortal.css +10 -78
  103. package/styles/black-metal-immortal.js +2 -7
  104. package/styles/black-metal-khold.css +10 -78
  105. package/styles/black-metal-khold.js +2 -7
  106. package/styles/black-metal-marduk.css +10 -78
  107. package/styles/black-metal-marduk.js +2 -7
  108. package/styles/black-metal-mayhem.css +10 -78
  109. package/styles/black-metal-mayhem.js +2 -7
  110. package/styles/black-metal-nile.css +10 -78
  111. package/styles/black-metal-nile.js +2 -7
  112. package/styles/black-metal-venom.css +10 -78
  113. package/styles/black-metal-venom.js +2 -7
  114. package/styles/black-metal.css +10 -78
  115. package/styles/black-metal.js +2 -7
  116. package/styles/brewer.css +10 -78
  117. package/styles/brewer.js +2 -7
  118. package/styles/bright.css +10 -78
  119. package/styles/bright.js +2 -7
  120. package/styles/brogrammer.css +10 -78
  121. package/styles/brogrammer.js +2 -7
  122. package/styles/brown-paper.css +5 -32
  123. package/styles/brush-trees-dark.css +10 -78
  124. package/styles/brush-trees-dark.js +2 -7
  125. package/styles/brush-trees.css +10 -78
  126. package/styles/brush-trees.js +2 -7
  127. package/styles/chalk.css +10 -78
  128. package/styles/chalk.js +2 -7
  129. package/styles/circus.css +10 -78
  130. package/styles/circus.js +2 -7
  131. package/styles/classic-dark.css +10 -78
  132. package/styles/classic-dark.js +2 -7
  133. package/styles/classic-light.css +10 -78
  134. package/styles/classic-light.js +2 -7
  135. package/styles/codepen-embed.css +6 -35
  136. package/styles/codeschool.css +10 -78
  137. package/styles/codeschool.js +2 -7
  138. package/styles/color-brewer.css +6 -38
  139. package/styles/colors.css +10 -78
  140. package/styles/colors.js +2 -7
  141. package/styles/cupcake.css +10 -78
  142. package/styles/cupcake.js +2 -7
  143. package/styles/cupertino.css +10 -76
  144. package/styles/cupertino.js +2 -7
  145. package/styles/cybertopia-cherry.css +10 -58
  146. package/styles/cybertopia-dimmer.css +10 -58
  147. package/styles/cybertopia-icecap.css +10 -58
  148. package/styles/cybertopia-saturated.css +10 -58
  149. package/styles/danqing.css +10 -78
  150. package/styles/danqing.js +2 -7
  151. package/styles/darcula.css +10 -78
  152. package/styles/darcula.js +2 -7
  153. package/styles/dark-violet.css +10 -78
  154. package/styles/dark-violet.js +2 -7
  155. package/styles/dark.css +5 -31
  156. package/styles/darkmoss.css +10 -78
  157. package/styles/darkmoss.js +2 -7
  158. package/styles/darktooth.css +10 -78
  159. package/styles/darktooth.js +2 -7
  160. package/styles/decaf.css +10 -78
  161. package/styles/decaf.js +2 -7
  162. package/styles/default-dark.css +10 -78
  163. package/styles/default-dark.js +2 -7
  164. package/styles/default-light.css +10 -78
  165. package/styles/default-light.js +2 -7
  166. package/styles/default.css +8 -60
  167. package/styles/devibeans.css +10 -60
  168. package/styles/dirtysea.css +10 -78
  169. package/styles/dirtysea.js +2 -7
  170. package/styles/docco.css +9 -75
  171. package/styles/dracula.css +10 -78
  172. package/styles/dracula.js +2 -7
  173. package/styles/edge-dark.css +8 -84
  174. package/styles/edge-dark.js +2 -17
  175. package/styles/edge-light.css +8 -84
  176. package/styles/edge-light.js +2 -17
  177. package/styles/eighties.css +10 -78
  178. package/styles/eighties.js +2 -7
  179. package/styles/embers.css +10 -78
  180. package/styles/embers.js +2 -7
  181. package/styles/equilibrium-dark.css +10 -78
  182. package/styles/equilibrium-dark.js +2 -7
  183. package/styles/equilibrium-gray-dark.css +10 -78
  184. package/styles/equilibrium-gray-dark.js +2 -7
  185. package/styles/equilibrium-gray-light.css +10 -78
  186. package/styles/equilibrium-gray-light.js +2 -7
  187. package/styles/equilibrium-light.css +10 -78
  188. package/styles/equilibrium-light.js +2 -7
  189. package/styles/espresso.css +10 -78
  190. package/styles/espresso.js +2 -7
  191. package/styles/eva-dim.css +10 -78
  192. package/styles/eva-dim.js +2 -7
  193. package/styles/eva.css +10 -78
  194. package/styles/eva.js +2 -7
  195. package/styles/far.css +6 -38
  196. package/styles/felipec.css +15 -75
  197. package/styles/flat.css +10 -78
  198. package/styles/flat.js +2 -7
  199. package/styles/foundation.css +10 -65
  200. package/styles/framer.css +10 -78
  201. package/styles/framer.js +2 -7
  202. package/styles/fruit-soda.css +10 -78
  203. package/styles/fruit-soda.js +2 -7
  204. package/styles/gigavolt.css +10 -78
  205. package/styles/gigavolt.js +2 -7
  206. package/styles/github-dark-dimmed.css +9 -67
  207. package/styles/github-dark.css +9 -67
  208. package/styles/github.css +9 -67
  209. package/styles/gml.css +2 -44
  210. package/styles/google-dark.css +8 -82
  211. package/styles/google-dark.js +2 -15
  212. package/styles/google-light.css +8 -82
  213. package/styles/google-light.js +2 -15
  214. package/styles/googlecode.css +10 -61
  215. package/styles/gradient-dark.css +12 -69
  216. package/styles/gradient-light.css +12 -71
  217. package/styles/grayscale-dark.css +10 -78
  218. package/styles/grayscale-dark.js +2 -7
  219. package/styles/grayscale-light.css +10 -78
  220. package/styles/grayscale-light.js +2 -7
  221. package/styles/grayscale.css +8 -83
  222. package/styles/green-screen.css +10 -78
  223. package/styles/green-screen.js +2 -7
  224. package/styles/gruvbox-dark-hard.css +10 -78
  225. package/styles/gruvbox-dark-hard.js +2 -7
  226. package/styles/gruvbox-dark-medium.css +10 -78
  227. package/styles/gruvbox-dark-medium.js +2 -7
  228. package/styles/gruvbox-dark-pale.css +10 -78
  229. package/styles/gruvbox-dark-pale.js +2 -7
  230. package/styles/gruvbox-dark-soft.css +10 -78
  231. package/styles/gruvbox-dark-soft.js +2 -7
  232. package/styles/gruvbox-light-hard.css +10 -78
  233. package/styles/gruvbox-light-hard.js +2 -7
  234. package/styles/gruvbox-light-medium.css +10 -78
  235. package/styles/gruvbox-light-medium.js +2 -7
  236. package/styles/gruvbox-light-soft.css +10 -78
  237. package/styles/gruvbox-light-soft.js +2 -7
  238. package/styles/hardcore.css +10 -78
  239. package/styles/hardcore.js +2 -7
  240. package/styles/harmonic16-dark.css +10 -78
  241. package/styles/harmonic16-dark.js +2 -7
  242. package/styles/harmonic16-light.css +10 -78
  243. package/styles/harmonic16-light.js +2 -7
  244. package/styles/heetch-dark.css +10 -78
  245. package/styles/heetch-dark.js +2 -7
  246. package/styles/heetch-light.css +10 -78
  247. package/styles/heetch-light.js +2 -7
  248. package/styles/helios.css +10 -78
  249. package/styles/helios.js +2 -7
  250. package/styles/hopscotch.css +10 -78
  251. package/styles/hopscotch.js +2 -7
  252. package/styles/horizon-dark.css +10 -78
  253. package/styles/horizon-dark.js +2 -7
  254. package/styles/horizon-light.css +10 -78
  255. package/styles/horizon-light.js +2 -7
  256. package/styles/humanoid-dark.css +10 -78
  257. package/styles/humanoid-dark.js +2 -7
  258. package/styles/humanoid-light.css +10 -78
  259. package/styles/humanoid-light.js +2 -7
  260. package/styles/hybrid.css +11 -58
  261. package/styles/ia-dark.css +10 -78
  262. package/styles/ia-dark.js +2 -7
  263. package/styles/ia-light.css +10 -78
  264. package/styles/ia-light.js +2 -7
  265. package/styles/icy-dark.css +10 -78
  266. package/styles/icy-dark.js +2 -7
  267. package/styles/idea.css +8 -71
  268. package/styles/intellij-light.css +6 -77
  269. package/styles/ir-black.css +9 -53
  270. package/styles/isbl-editor-dark.css +7 -69
  271. package/styles/isbl-editor-dark.js +1 -2
  272. package/styles/isbl-editor-light.css +7 -68
  273. package/styles/isotope.css +10 -78
  274. package/styles/isotope.js +2 -7
  275. package/styles/kimber.css +10 -78
  276. package/styles/kimber.js +2 -7
  277. package/styles/kimbie-dark.css +8 -43
  278. package/styles/kimbie-light.css +8 -43
  279. package/styles/lightfair.css +7 -55
  280. package/styles/lioshi.css +7 -50
  281. package/styles/london-tube.css +10 -78
  282. package/styles/london-tube.js +2 -7
  283. package/styles/macintosh.css +10 -76
  284. package/styles/macintosh.js +2 -7
  285. package/styles/magula.css +7 -43
  286. package/styles/marrakesh.css +10 -78
  287. package/styles/marrakesh.js +2 -7
  288. package/styles/materia.css +10 -78
  289. package/styles/materia.js +2 -7
  290. package/styles/material-darker.css +10 -78
  291. package/styles/material-darker.js +2 -7
  292. package/styles/material-lighter.css +10 -78
  293. package/styles/material-lighter.js +2 -7
  294. package/styles/material-palenight.css +10 -78
  295. package/styles/material-palenight.js +2 -7
  296. package/styles/material-vivid.css +10 -78
  297. package/styles/material-vivid.js +2 -7
  298. package/styles/material.css +10 -78
  299. package/styles/material.js +2 -7
  300. package/styles/mellow-purple.css +10 -78
  301. package/styles/mellow-purple.js +2 -7
  302. package/styles/mexico-light.css +10 -78
  303. package/styles/mexico-light.js +2 -7
  304. package/styles/mocha.css +10 -78
  305. package/styles/mocha.js +2 -7
  306. package/styles/mono-blue.css +4 -30
  307. package/styles/monokai-sublime.css +10 -55
  308. package/styles/monokai-sublime.js +1 -2
  309. package/styles/monokai.css +7 -39
  310. package/styles/nebula.css +10 -78
  311. package/styles/nebula.js +2 -7
  312. package/styles/night-owl.css +3 -136
  313. package/styles/night-owl.js +1 -2
  314. package/styles/nnfx-dark.css +12 -80
  315. package/styles/nnfx-light.css +12 -80
  316. package/styles/nord.css +5 -204
  317. package/styles/nord.js +1 -3
  318. package/styles/nova.css +10 -76
  319. package/styles/nova.js +2 -7
  320. package/styles/obsidian.css +8 -52
  321. package/styles/ocean.css +10 -78
  322. package/styles/ocean.js +2 -7
  323. package/styles/oceanicnext.css +10 -78
  324. package/styles/oceanicnext.js +2 -7
  325. package/styles/one-light.css +10 -78
  326. package/styles/one-light.js +2 -7
  327. package/styles/onedark.css +10 -78
  328. package/styles/onedark.js +2 -7
  329. package/styles/outrun-dark.css +10 -78
  330. package/styles/outrun-dark.js +2 -7
  331. package/styles/panda-syntax-dark.css +11 -62
  332. package/styles/panda-syntax-light.css +10 -58
  333. package/styles/papercolor-dark.css +10 -78
  334. package/styles/papercolor-dark.js +2 -7
  335. package/styles/papercolor-light.css +8 -82
  336. package/styles/papercolor-light.js +2 -15
  337. package/styles/paraiso-dark.css +7 -42
  338. package/styles/paraiso-light.css +7 -42
  339. package/styles/paraiso.css +10 -78
  340. package/styles/paraiso.js +2 -7
  341. package/styles/pasque.css +10 -78
  342. package/styles/pasque.js +2 -7
  343. package/styles/phd.css +10 -78
  344. package/styles/phd.js +2 -7
  345. package/styles/pico.css +10 -78
  346. package/styles/pico.js +2 -7
  347. package/styles/pojoaque.css +8 -56
  348. package/styles/pop.css +10 -78
  349. package/styles/pop.js +2 -7
  350. package/styles/porple.css +10 -78
  351. package/styles/porple.js +2 -7
  352. package/styles/purebasic.css +9 -48
  353. package/styles/qtcreator-dark.css +10 -50
  354. package/styles/qtcreator-light.css +7 -57
  355. package/styles/qtcreator-light.js +2 -14
  356. package/styles/qualia.css +10 -78
  357. package/styles/qualia.js +2 -7
  358. package/styles/railscasts.css +10 -78
  359. package/styles/railscasts.js +2 -7
  360. package/styles/rainbow.css +10 -58
  361. package/styles/rebecca.css +10 -78
  362. package/styles/rebecca.js +2 -7
  363. package/styles/ros-pine-dawn.css +10 -78
  364. package/styles/ros-pine-dawn.js +2 -7
  365. package/styles/ros-pine-moon.css +10 -78
  366. package/styles/ros-pine-moon.js +2 -7
  367. package/styles/ros-pine.css +10 -78
  368. package/styles/ros-pine.js +2 -7
  369. package/styles/rose-pine-dawn.css +8 -62
  370. package/styles/rose-pine-dawn.js +1 -7
  371. package/styles/rose-pine-moon.css +8 -62
  372. package/styles/rose-pine-moon.js +1 -7
  373. package/styles/rose-pine.css +8 -62
  374. package/styles/rose-pine.js +1 -7
  375. package/styles/routeros.css +6 -60
  376. package/styles/sagelight.css +10 -78
  377. package/styles/sagelight.js +2 -7
  378. package/styles/sandcastle.css +7 -84
  379. package/styles/sandcastle.js +2 -20
  380. package/styles/school-book.css +5 -35
  381. package/styles/seti-ui.css +10 -78
  382. package/styles/seti-ui.js +2 -7
  383. package/styles/shades-of-purple.css +6 -62
  384. package/styles/shades-of-purple.js +1 -3
  385. package/styles/shapeshifter.css +10 -78
  386. package/styles/shapeshifter.js +2 -7
  387. package/styles/silk-dark.css +10 -78
  388. package/styles/silk-dark.js +2 -7
  389. package/styles/silk-light.css +10 -78
  390. package/styles/silk-light.js +2 -7
  391. package/styles/snazzy.css +10 -78
  392. package/styles/snazzy.js +2 -7
  393. package/styles/solar-flare-light.css +10 -78
  394. package/styles/solar-flare-light.js +2 -7
  395. package/styles/solar-flare.css +10 -78
  396. package/styles/solar-flare.js +2 -7
  397. package/styles/solarized-dark.css +10 -78
  398. package/styles/solarized-dark.js +2 -7
  399. package/styles/solarized-light.css +10 -78
  400. package/styles/solarized-light.js +2 -7
  401. package/styles/spacemacs.css +10 -78
  402. package/styles/spacemacs.js +2 -7
  403. package/styles/srcery.css +10 -56
  404. package/styles/srcery.js +1 -3
  405. package/styles/stackoverflow-dark.css +7 -68
  406. package/styles/stackoverflow-dark.js +1 -5
  407. package/styles/stackoverflow-light.css +7 -68
  408. package/styles/stackoverflow-light.js +1 -5
  409. package/styles/summercamp.css +10 -78
  410. package/styles/summercamp.js +2 -7
  411. package/styles/summerfruit-dark.css +10 -78
  412. package/styles/summerfruit-dark.js +2 -7
  413. package/styles/summerfruit-light.css +10 -78
  414. package/styles/summerfruit-light.js +2 -7
  415. package/styles/sunburst.css +8 -78
  416. package/styles/synth-midnight-terminal-dark.css +10 -78
  417. package/styles/synth-midnight-terminal-dark.js +2 -7
  418. package/styles/synth-midnight-terminal-light.css +10 -78
  419. package/styles/synth-midnight-terminal-light.js +2 -7
  420. package/styles/tango.css +10 -78
  421. package/styles/tango.js +2 -7
  422. package/styles/tender.css +10 -78
  423. package/styles/tender.js +2 -7
  424. package/styles/tokyo-night-dark.css +10 -60
  425. package/styles/tokyo-night-light.css +10 -60
  426. package/styles/tomorrow-night-blue.css +7 -45
  427. package/styles/tomorrow-night-bright.css +7 -45
  428. package/styles/tomorrow-night.css +10 -78
  429. package/styles/tomorrow-night.js +2 -7
  430. package/styles/tomorrow.css +10 -78
  431. package/styles/tomorrow.js +2 -7
  432. package/styles/twilight.css +10 -78
  433. package/styles/twilight.js +2 -7
  434. package/styles/unikitty-dark.css +10 -78
  435. package/styles/unikitty-dark.js +2 -7
  436. package/styles/unikitty-light.css +10 -78
  437. package/styles/unikitty-light.js +2 -7
  438. package/styles/vs.css +6 -44
  439. package/styles/vs2015.css +12 -87
  440. package/styles/vs2015.js +1 -4
  441. package/styles/vulcan.css +7 -82
  442. package/styles/vulcan.js +1 -17
  443. package/styles/windows-10-light.css +10 -78
  444. package/styles/windows-10-light.js +2 -7
  445. package/styles/windows-10.css +10 -78
  446. package/styles/windows-10.js +2 -7
  447. package/styles/windows-95-light.css +10 -78
  448. package/styles/windows-95-light.js +2 -7
  449. package/styles/windows-95.css +10 -78
  450. package/styles/windows-95.js +2 -7
  451. package/styles/windows-high-contrast-light.css +10 -78
  452. package/styles/windows-high-contrast-light.js +2 -7
  453. package/styles/windows-high-contrast.css +10 -78
  454. package/styles/windows-high-contrast.js +2 -7
  455. package/styles/windows-nt-light.css +10 -78
  456. package/styles/windows-nt-light.js +2 -7
  457. package/styles/windows-nt.css +10 -78
  458. package/styles/windows-nt.js +2 -7
  459. package/styles/woodland.css +10 -78
  460. package/styles/woodland.js +2 -7
  461. package/styles/xcode-dusk.css +10 -78
  462. package/styles/xcode-dusk.js +2 -7
  463. package/styles/xcode.css +11 -74
  464. package/styles/xt256.css +8 -68
  465. package/styles/zenburn.css +10 -78
  466. package/styles/zenburn.js +2 -7
package/Highlight.svelte CHANGED
@@ -9,7 +9,7 @@
9
9
  export let langtag = false;
10
10
 
11
11
  import hljs from "highlight.js/lib/core";
12
- import { createEventDispatcher, afterUpdate } from "svelte";
12
+ import { afterUpdate, createEventDispatcher } from "svelte";
13
13
  import LangTag from "./LangTag.svelte";
14
14
 
15
15
  const dispatch = createEventDispatcher();
@@ -27,7 +27,7 @@
27
27
  }
28
28
  </script>
29
29
 
30
- <slot {highlighted}>
30
+ <slot {highlighted} {langtag} languageName={language.name}>
31
31
  <LangTag
32
32
  {...$$restProps}
33
33
  languageName={language.name}
@@ -11,7 +11,7 @@
11
11
  export let langtag = false;
12
12
 
13
13
  import hljs from "highlight.js";
14
- import { createEventDispatcher, afterUpdate } from "svelte";
14
+ import { afterUpdate, createEventDispatcher } from "svelte";
15
15
 
16
16
  /**
17
17
  * @typedef {{ highlighted: string; language: string; }} HighlightEventDetail
@@ -35,7 +35,7 @@
35
35
  ));
36
36
  </script>
37
37
 
38
- <slot {highlighted}>
38
+ <slot {highlighted} {langtag} languageName={language}>
39
39
  <LangTag
40
40
  {...$$restProps}
41
41
  languageName={language}
@@ -8,25 +8,25 @@
8
8
  export let langtag = false;
9
9
 
10
10
  import hljs from "highlight.js/lib/core";
11
- import xml from "highlight.js/lib/languages/xml";
12
- import javascript from "highlight.js/lib/languages/javascript";
13
- import css from "highlight.js/lib/languages/css";
14
- import { createEventDispatcher, afterUpdate } from "svelte";
11
+ import { afterUpdate, createEventDispatcher } from "svelte";
12
+ import svelte from "./languages/svelte";
15
13
 
16
14
  const dispatch = createEventDispatcher();
17
15
 
18
- hljs.registerLanguage("xml", xml);
19
- hljs.registerLanguage("javascript", javascript);
20
- hljs.registerLanguage("css", css);
16
+ /** @type {string} */
17
+ let highlighted = "";
21
18
 
22
19
  afterUpdate(() => {
23
20
  if (highlighted) dispatch("highlight", { highlighted });
24
21
  });
25
22
 
26
- $: highlighted = hljs.highlightAuto(code).value;
23
+ $: {
24
+ hljs.registerLanguage(svelte.name, svelte.register);
25
+ highlighted = hljs.highlight(code, { language: svelte.name }).value;
26
+ }
27
27
  </script>
28
28
 
29
- <slot {highlighted}>
29
+ <slot {highlighted} {langtag} languageName="svelte">
30
30
  <LangTag
31
31
  {...$$restProps}
32
32
  languageName="svelte"
package/LangTag.svelte CHANGED
@@ -12,27 +12,11 @@
12
12
  export let langtag = false;
13
13
  </script>
14
14
 
15
- <pre class:langtag data-language={languageName} {...$$restProps}><code
15
+ <pre class:langtag={langtag} data-language={languageName} {...$$restProps}><code
16
16
  class:hljs={true}
17
17
  >{#if highlighted}{@html highlighted}{:else}{code}{/if}</code
18
18
  ></pre>
19
19
 
20
20
  <style>
21
- .langtag {
22
- position: relative;
23
- }
24
-
25
- .langtag::after {
26
- content: attr(data-language);
27
- position: absolute;
28
- top: var(--langtag-top, 0);
29
- right: var(--langtag-right, 0);
30
- display: flex;
31
- align-items: center;
32
- justify-content: center;
33
- background: var(--langtag-background, inherit);
34
- color: var(--langtag-color, inherit);
35
- border-radius: var(--langtag-border-radius, 0);
36
- padding: var(--langtag-padding, 1em);
37
- }
21
+ @import "./langtag.css";
38
22
  </style>
@@ -14,6 +14,12 @@
14
14
  /** @type {number[]} */
15
15
  export let highlightedLines = [];
16
16
 
17
+ /** @type {import('./languages').LanguageName | (string & {})} */
18
+ export let languageName = "plaintext";
19
+
20
+ /** @type {boolean} */
21
+ export let langtag = false;
22
+
17
23
  const DIGIT_WIDTH = 12;
18
24
  const MIN_DIGITS = 2;
19
25
  const HIGHLIGHTED_BACKGROUND = "rgba(254, 241, 96, 0.2)";
@@ -24,7 +30,12 @@
24
30
  $: width = len * DIGIT_WIDTH;
25
31
  </script>
26
32
 
27
- <div style:overflow-x="auto" {...$$restProps}>
33
+ <div
34
+ class:langtag={langtag}
35
+ data-language={languageName}
36
+ style:overflow-x="auto"
37
+ {...$$restProps}
38
+ >
28
39
  <table>
29
40
  <tbody class:hljs={true}>
30
41
  {#each lines as line, i}
@@ -37,7 +48,7 @@
37
48
  style:left="0"
38
49
  style:text-align="right"
39
50
  style:user-select="none"
40
- style:width={width + "px"}
51
+ style:width={`${width}px`}
41
52
  >
42
53
  <code style:color="var(--line-number-color, currentColor)">
43
54
  {lineNumber}
@@ -65,6 +76,8 @@
65
76
  </div>
66
77
 
67
78
  <style>
79
+ @import "./langtag.css";
80
+
68
81
  pre {
69
82
  margin: 0;
70
83
  }
@@ -1,78 +1,87 @@
1
1
  import type { SvelteComponentTyped } from "svelte";
2
2
  import type { HTMLAttributes } from "svelte/elements";
3
+ import type { LangtagProps } from "./Highlight.svelte";
4
+ import type { LanguageName } from "./languages";
3
5
 
4
- export type LineNumbersProps = HTMLAttributes<HTMLPreElement> & {
5
- /**
6
- * Pass the highlighted `code` to `LineNumbers`.
7
- * @example
8
- * <Highlight language={typescript} {code} let:highlighted>
9
- * <LineNumbers {highlighted} />
10
- * </Highlight>
11
- */
12
- highlighted: string;
6
+ export type LineNumbersProps = HTMLAttributes<HTMLDivElement> &
7
+ LangtagProps & {
8
+ /**
9
+ * Pass the highlighted `code` to `LineNumbers`.
10
+ * @example
11
+ * <Highlight language={typescript} {code} langtag let:highlighted let:langtag let:languageName>
12
+ * <LineNumbers {highlighted} {langtag} {languageName} />
13
+ * </Highlight>
14
+ */
15
+ highlighted: string;
13
16
 
14
- /**
15
- * Set to `true` to hide the border of the line numbers column.
16
- * @default false
17
- */
18
- hideBorder?: boolean;
17
+ /**
18
+ * Provide the language name.
19
+ * @default "plaintext"
20
+ */
21
+ languageName?: LanguageName | (string & {});
19
22
 
20
- /**
21
- * Specify which starting line number should be displayed.
22
- * @default 1
23
- */
24
- startingLineNumber?: number;
23
+ /**
24
+ * Set to `true` to hide the border of the line numbers column.
25
+ * @default false
26
+ */
27
+ hideBorder?: boolean;
25
28
 
26
- /**
27
- * Set to `true` for lines to wrap.
28
- * @default false
29
- */
30
- wrapLines?: boolean;
29
+ /**
30
+ * Specify which starting line number should be displayed.
31
+ * @default 1
32
+ */
33
+ startingLineNumber?: number;
31
34
 
32
- /**
33
- * Specify the line indices to highlight.
34
- * @default []
35
- * @example [0, 1, 9]
36
- */
37
- highlightedLines?: number[];
35
+ /**
36
+ * Set to `true` for lines to wrap.
37
+ * @default false
38
+ */
39
+ wrapLines?: boolean;
38
40
 
39
- /**
40
- * Specify the text color for line numbers.
41
- * Defaults to the current theme color applied to `.hljs code`.
42
- * @default currentColor
43
- * @example "pink"
44
- */
45
- "--line-number-color"?: string;
41
+ /**
42
+ * Specify the line indices to highlight.
43
+ * @default []
44
+ * @example [0, 1, 9]
45
+ */
46
+ highlightedLines?: number[];
46
47
 
47
- /**
48
- * Specify the border color.
49
- * Defaults to the current background color applied to `.hljs`.
50
- * @default currentColor
51
- * @example "#fff"
52
- */
53
- "--border-color"?: string;
48
+ /**
49
+ * Specify the text color for line numbers.
50
+ * Defaults to the current theme color applied to `.hljs code`.
51
+ * @default currentColor
52
+ * @example "pink"
53
+ */
54
+ "--line-number-color"?: string;
54
55
 
55
- /**
56
- * Specify the left padding for `td` elements.
57
- * @default 1em
58
- * @example 0
59
- */
60
- "--padding-left"?: number | string;
56
+ /**
57
+ * Specify the border color.
58
+ * Defaults to the current background color applied to `.hljs`.
59
+ * @default currentColor
60
+ * @example "#fff"
61
+ */
62
+ "--border-color"?: string;
61
63
 
62
- /**
63
- * Specify the right padding for `td` elements.
64
- * @default 1em
65
- * @example 0
66
- */
67
- "--padding-right"?: number | string;
64
+ /**
65
+ * Specify the left padding for `td` elements.
66
+ * @default 1em
67
+ * @example 0
68
+ */
69
+ "--padding-left"?: number | string;
68
70
 
69
- /**
70
- * Specify the background color of highlighted lines.
71
- * @default "rgba(254, 241, 96, 0.2)"
72
- * @example "#fff"
73
- */
74
- "--highlighted-background"?: string;
75
- };
71
+ /**
72
+ * Specify the right padding for `td` elements.
73
+ * @default 1em
74
+ * @example 0
75
+ */
76
+ "--padding-right"?: number | string;
77
+
78
+ /**
79
+ * Specify the background color of highlighted lines.
80
+ * @default "rgba(254, 241, 96, 0.2)"
81
+ * @example "#fff"
82
+ */
83
+ "--highlighted-background"?: string;
84
+ };
76
85
 
77
86
  export type LineNumbersEvents = {};
78
87
 
package/README.md CHANGED
@@ -278,6 +278,31 @@ Use `--style-props` to customize styles.
278
278
  </Highlight>
279
279
  ```
280
280
 
281
+ ### Language Tag
282
+
283
+ When using a custom slot, forward `langtag` and `languageName` from `Highlight` to `LineNumbers`.
284
+
285
+ ```svelte
286
+ <Highlight
287
+ language={typescript}
288
+ {code}
289
+ langtag
290
+ let:highlighted
291
+ let:langtag
292
+ let:languageName
293
+ >
294
+ <LineNumbers {highlighted} {langtag} {languageName} />
295
+ </Highlight>
296
+ ```
297
+
298
+ With `HighlightAuto`:
299
+
300
+ ```svelte
301
+ <HighlightAuto {code} langtag let:highlighted let:langtag let:languageName>
302
+ <LineNumbers {highlighted} {langtag} {languageName} />
303
+ </HighlightAuto>
304
+ ```
305
+
281
306
  ## Language Targeting
282
307
 
283
308
  All `Highlight` components apply a `data-language` attribute on the codeblock containing the language name.
@@ -473,6 +498,8 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
473
498
  | wrapLines | `boolean` | `false` |
474
499
  | startingLineNumber | `number` | `1` |
475
500
  | highlightedLines | `number[]` | `[]` |
501
+ | langtag | `boolean` | `false` |
502
+ | languageName | `string` | `"plaintext"` |
476
503
 
477
504
  `$$restProps` are forwarded to the top-level `div` element.
478
505
 
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { default as Highlight, default as default } from "./Highlight.svelte";
1
+ export { default as Highlight, default } from "./Highlight.svelte";
2
2
  export { default as HighlightAuto } from "./HighlightAuto.svelte";
3
3
  export { default as HighlightSvelte } from "./HighlightSvelte.svelte";
4
4
  export { default as LineNumbers } from "./LineNumbers.svelte";
5
- export type { LanguageType, LanguageName } from "./languages";
5
+ export type { LanguageName, LanguageType } from "./languages";
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { default as default, default as Highlight } from "./Highlight.svelte";
1
+ export { default, default as Highlight } from "./Highlight.svelte";
2
2
  export { default as HighlightAuto } from "./HighlightAuto.svelte";
3
3
  export { default as HighlightSvelte } from "./HighlightSvelte.svelte";
4
4
  export { default as LineNumbers } from "./LineNumbers.svelte";
package/langtag.css ADDED
@@ -0,0 +1,17 @@
1
+ .langtag {
2
+ position: relative;
3
+ }
4
+
5
+ .langtag::after {
6
+ content: attr(data-language);
7
+ position: absolute;
8
+ top: var(--langtag-top, 0);
9
+ right: var(--langtag-right, 0);
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ background: var(--langtag-background, inherit);
14
+ color: var(--langtag-color, inherit);
15
+ border-radius: var(--langtag-border-radius, 0);
16
+ padding: var(--langtag-padding, 1em);
17
+ }
@@ -0,0 +1,2 @@
1
+ export { astro } from "./";
2
+ export { astro as default } from "./";
@@ -0,0 +1,57 @@
1
+ import cssRegister from "highlight.js/lib/languages/css";
2
+ import javascriptRegister from "highlight.js/lib/languages/javascript";
3
+ import typescriptRegister from "highlight.js/lib/languages/typescript";
4
+ import html from "./html.js";
5
+
6
+ /** @param {import("highlight.js").HLJSApi} hljs */
7
+ function defineAstro(hljs) {
8
+ return {
9
+ name: "Astro",
10
+ subLanguage: "html",
11
+ contains: [
12
+ {
13
+ begin: /^---\s*\n/,
14
+ end: /^---\s*$|^\.\.\.\s*$/m,
15
+ subLanguage: "typescript",
16
+ excludeBegin: true,
17
+ excludeEnd: true,
18
+ relevance: 100,
19
+ },
20
+ {
21
+ begin: /^---\s*$/m,
22
+ className: "meta",
23
+ relevance: 50,
24
+ },
25
+ hljs.COMMENT(/<!--/, /-->/, { relevance: 10 }),
26
+ {
27
+ begin: /^(\s*)(<style[^>]*>)/gm,
28
+ end: /^(\s*)(<\/style>)/gm,
29
+ subLanguage: "css",
30
+ excludeBegin: true,
31
+ excludeEnd: true,
32
+ relevance: 100,
33
+ },
34
+ {
35
+ begin: /\{/,
36
+ end: /\}/,
37
+ contains: /** @type {(import("highlight.js").Mode | "self")[]} */ ([
38
+ "self",
39
+ ]),
40
+ subLanguage: "javascript",
41
+ relevance: 10,
42
+ },
43
+ ],
44
+ };
45
+ }
46
+
47
+ /** @type {import("highlight.js").LanguageFn} */
48
+ function register(hljs) {
49
+ hljs.registerLanguage("html", html.register);
50
+ hljs.registerLanguage("typescript", typescriptRegister);
51
+ hljs.registerLanguage("css", cssRegister);
52
+ hljs.registerLanguage("javascript", javascriptRegister);
53
+ return defineAstro(hljs);
54
+ }
55
+
56
+ export const astro = { name: "astro", register };
57
+ export default astro;
@@ -0,0 +1,2 @@
1
+ export { html } from "./";
2
+ export { html as default } from "./";
@@ -0,0 +1,140 @@
1
+ import cssRegister from "highlight.js/lib/languages/css";
2
+ import javascriptRegister from "highlight.js/lib/languages/javascript";
3
+
4
+ /** @param {import("highlight.js").HLJSApi} hljs */
5
+ function defineHtml(hljs) {
6
+ const regex = hljs.regex;
7
+ const TagNameRe = regex.concat(
8
+ /[\p{L}_]/u,
9
+ regex.optional(/[\p{L}0-9_.-]*:/u),
10
+ /[\p{L}0-9_.-]*/u,
11
+ );
12
+ const HtmlIdentRe = /[\p{L}0-9._:-]+/u;
13
+ const HtmlEntities = {
14
+ className: "symbol",
15
+ begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/,
16
+ };
17
+ const TagInternals = {
18
+ endsWithParent: true,
19
+ illegal: /</,
20
+ relevance: 0,
21
+ contains: [
22
+ {
23
+ className: "attr",
24
+ begin: HtmlIdentRe,
25
+ relevance: 0,
26
+ },
27
+ {
28
+ begin: /=\s*/,
29
+ relevance: 0,
30
+ contains: [
31
+ {
32
+ className: "string",
33
+ endsParent: true,
34
+ variants: [
35
+ {
36
+ begin: /"/,
37
+ end: /"/,
38
+ contains: [HtmlEntities],
39
+ },
40
+ {
41
+ begin: /'/,
42
+ end: /'/,
43
+ contains: [HtmlEntities],
44
+ },
45
+ { begin: /[^\s"'=<>`]+/ },
46
+ ],
47
+ },
48
+ ],
49
+ },
50
+ ],
51
+ };
52
+
53
+ return {
54
+ name: "HTML",
55
+ aliases: ["htm"],
56
+ case_insensitive: true,
57
+ unicodeRegex: true,
58
+ contains: [
59
+ {
60
+ className: "meta",
61
+ begin: /<!DOCTYPE/i,
62
+ end: />/,
63
+ relevance: 10,
64
+ },
65
+ hljs.COMMENT(/<!--/, /-->/, { relevance: 10 }),
66
+ HtmlEntities,
67
+ {
68
+ className: "tag",
69
+ begin: /<style(?=\s|>)/,
70
+ end: />/,
71
+ keywords: { name: "style" },
72
+ contains: [TagInternals],
73
+ starts: {
74
+ end: /<\/style>/,
75
+ returnEnd: true,
76
+ subLanguage: ["css"],
77
+ },
78
+ },
79
+ {
80
+ className: "tag",
81
+ begin: /<script(?=\s|>)/,
82
+ end: />/,
83
+ keywords: { name: "script" },
84
+ contains: [TagInternals],
85
+ starts: {
86
+ end: /<\/script>/,
87
+ returnEnd: true,
88
+ subLanguage: ["javascript"],
89
+ },
90
+ },
91
+ {
92
+ className: "tag",
93
+ begin: regex.concat(
94
+ /</,
95
+ regex.lookahead(
96
+ regex.concat(TagNameRe, regex.either(/\/>/, />/, /\s/)),
97
+ ),
98
+ ),
99
+ end: /\/?>/,
100
+ contains: [
101
+ {
102
+ className: "name",
103
+ begin: TagNameRe,
104
+ relevance: 0,
105
+ starts: TagInternals,
106
+ },
107
+ ],
108
+ },
109
+ {
110
+ className: "tag",
111
+ begin: regex.concat(
112
+ /<\//,
113
+ regex.lookahead(regex.concat(TagNameRe, />/)),
114
+ ),
115
+ contains: [
116
+ {
117
+ className: "name",
118
+ begin: TagNameRe,
119
+ relevance: 0,
120
+ },
121
+ {
122
+ begin: />/,
123
+ relevance: 0,
124
+ endsParent: true,
125
+ },
126
+ ],
127
+ },
128
+ ],
129
+ };
130
+ }
131
+
132
+ /** @type {import("highlight.js").LanguageFn} */
133
+ function register(hljs) {
134
+ hljs.registerLanguage("css", cssRegister);
135
+ hljs.registerLanguage("javascript", javascriptRegister);
136
+ return defineHtml(hljs);
137
+ }
138
+
139
+ export const html = { name: "html", register };
140
+ export default html;