svelte-highlight 7.12.0 → 7.14.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 (600) hide show
  1. package/AnsiOutput.svelte +193 -0
  2. package/AnsiOutput.svelte.d.ts +112 -0
  3. package/CodeWindow.svelte +110 -0
  4. package/CodeWindow.svelte.d.ts +136 -0
  5. package/CopyButton.svelte +2 -5
  6. package/CopyButton.svelte.d.ts +16 -20
  7. package/FileTabs.svelte +161 -0
  8. package/FileTabs.svelte.d.ts +96 -0
  9. package/Highlight.svelte +15 -25
  10. package/Highlight.svelte.d.ts +9 -10
  11. package/HighlightAuto.svelte +20 -25
  12. package/HighlightAuto.svelte.d.ts +2 -2
  13. package/HighlightEditable.svelte +385 -0
  14. package/HighlightEditable.svelte.d.ts +113 -0
  15. package/HighlightStyle.svelte +21 -6
  16. package/HighlightStyle.svelte.d.ts +22 -1
  17. package/HighlightSvelte.svelte +15 -23
  18. package/HighlightSvelte.svelte.d.ts +1 -1
  19. package/LangTag.svelte.d.ts +3 -3
  20. package/LineNumbers.svelte.d.ts +10 -10
  21. package/README.md +621 -0
  22. package/Typewriter.svelte +238 -0
  23. package/Typewriter.svelte.d.ts +65 -0
  24. package/action.d.ts +20 -0
  25. package/action.js +22 -0
  26. package/ansi.d.ts +36 -0
  27. package/ansi.js +198 -0
  28. package/core.js +22 -0
  29. package/highlighter.svelte.js +22 -0
  30. package/index.d.ts +10 -0
  31. package/index.js +8 -0
  32. package/languages/bibtex.js +2 -2
  33. package/languages/bicep.js +6 -0
  34. package/languages/blade.js +35 -1
  35. package/languages/caddy.js +1 -1
  36. package/languages/cairo.js +15 -0
  37. package/languages/clarity.js +1 -1
  38. package/languages/cue.js +31 -1
  39. package/languages/cypher.js +9 -0
  40. package/languages/d2.js +2 -2
  41. package/languages/dax.d.ts +2 -0
  42. package/languages/dax.js +75 -0
  43. package/languages/dhall.js +7 -0
  44. package/languages/dotenv.js +5 -1
  45. package/languages/fish.js +8 -0
  46. package/languages/gleam.js +7 -0
  47. package/languages/groq.js +19 -0
  48. package/languages/hcl.js +4 -1
  49. package/languages/hlsl.d.ts +2 -0
  50. package/languages/hlsl.js +88 -0
  51. package/languages/html.js +28 -0
  52. package/languages/index.d.ts +20 -0
  53. package/languages/index.js +10 -0
  54. package/languages/jq.d.ts +2 -0
  55. package/languages/jq.js +120 -0
  56. package/languages/jsonnet.js +9 -2
  57. package/languages/just.d.ts +2 -0
  58. package/languages/just.js +120 -0
  59. package/languages/kql.d.ts +2 -0
  60. package/languages/kql.js +122 -0
  61. package/languages/liquid.js +1 -0
  62. package/languages/logql.d.ts +2 -0
  63. package/languages/logql.js +82 -0
  64. package/languages/marko.js +84 -1
  65. package/languages/mdx.js +40 -1
  66. package/languages/move.js +20 -0
  67. package/languages/nickel.js +16 -1
  68. package/languages/nushell.js +23 -0
  69. package/languages/pkl.js +2 -1
  70. package/languages/prisma.js +2 -1
  71. package/languages/promql.js +35 -2
  72. package/languages/pug.js +22 -0
  73. package/languages/razor.js +64 -5
  74. package/languages/rego.d.ts +2 -0
  75. package/languages/rego.js +94 -0
  76. package/languages/rescript.js +70 -2
  77. package/languages/rst.d.ts +2 -0
  78. package/languages/rst.js +144 -0
  79. package/languages/solidity.js +2 -1
  80. package/languages/svelte.js +12 -3
  81. package/languages/templ.d.ts +2 -0
  82. package/languages/templ.js +254 -0
  83. package/languages/toml.js +3 -1
  84. package/languages/typst.d.ts +2 -0
  85. package/languages/typst.js +185 -0
  86. package/languages/v.js +24 -2
  87. package/languages/vue.js +4 -2
  88. package/languages/vyper.js +18 -0
  89. package/languages/wgsl.js +14 -0
  90. package/languages/zig.js +7 -0
  91. package/load-language.d.ts +9 -0
  92. package/load-language.js +15 -0
  93. package/package.json +11 -2
  94. package/preprocessor.js +373 -0
  95. package/scoped.d.ts +12 -0
  96. package/scoped.js +55 -24
  97. package/static.d.ts +36 -0
  98. package/static.js +1 -0
  99. package/styles/1c-light.css +1 -1
  100. package/styles/1c-light.js +1 -1
  101. package/styles/3024.css +1 -1
  102. package/styles/3024.js +1 -1
  103. package/styles/a11y-dark.css +1 -1
  104. package/styles/a11y-dark.js +1 -1
  105. package/styles/a11y-light.css +1 -1
  106. package/styles/a11y-light.js +1 -1
  107. package/styles/agate.css +1 -1
  108. package/styles/agate.js +1 -1
  109. package/styles/an-old-hope.css +1 -1
  110. package/styles/an-old-hope.js +1 -1
  111. package/styles/androidstudio.css +1 -1
  112. package/styles/androidstudio.js +1 -1
  113. package/styles/apathy.css +1 -1
  114. package/styles/apathy.js +1 -1
  115. package/styles/apprentice.css +1 -1
  116. package/styles/apprentice.js +1 -1
  117. package/styles/arduino-light.css +1 -1
  118. package/styles/arduino-light.js +1 -1
  119. package/styles/arta.css +1 -1
  120. package/styles/arta.js +1 -1
  121. package/styles/ascetic.css +1 -1
  122. package/styles/ascetic.js +1 -1
  123. package/styles/ashes.css +1 -1
  124. package/styles/ashes.js +1 -1
  125. package/styles/atelier-cave-light.css +1 -1
  126. package/styles/atelier-cave-light.js +1 -1
  127. package/styles/atelier-cave.css +1 -1
  128. package/styles/atelier-cave.js +1 -1
  129. package/styles/atelier-dune-light.css +1 -1
  130. package/styles/atelier-dune-light.js +1 -1
  131. package/styles/atelier-dune.css +1 -1
  132. package/styles/atelier-dune.js +1 -1
  133. package/styles/atelier-estuary-light.css +1 -1
  134. package/styles/atelier-estuary-light.js +1 -1
  135. package/styles/atelier-estuary.css +1 -1
  136. package/styles/atelier-estuary.js +1 -1
  137. package/styles/atelier-forest-light.css +1 -1
  138. package/styles/atelier-forest-light.js +1 -1
  139. package/styles/atelier-forest.css +1 -1
  140. package/styles/atelier-forest.js +1 -1
  141. package/styles/atelier-heath-light.css +1 -1
  142. package/styles/atelier-heath-light.js +1 -1
  143. package/styles/atelier-heath.css +1 -1
  144. package/styles/atelier-heath.js +1 -1
  145. package/styles/atelier-lakeside-light.css +1 -1
  146. package/styles/atelier-lakeside-light.js +1 -1
  147. package/styles/atelier-lakeside.css +1 -1
  148. package/styles/atelier-lakeside.js +1 -1
  149. package/styles/atelier-plateau-light.css +1 -1
  150. package/styles/atelier-plateau-light.js +1 -1
  151. package/styles/atelier-plateau.css +1 -1
  152. package/styles/atelier-plateau.js +1 -1
  153. package/styles/atelier-savanna-light.css +1 -1
  154. package/styles/atelier-savanna-light.js +1 -1
  155. package/styles/atelier-savanna.css +1 -1
  156. package/styles/atelier-savanna.js +1 -1
  157. package/styles/atelier-seaside-light.css +1 -1
  158. package/styles/atelier-seaside-light.js +1 -1
  159. package/styles/atelier-seaside.css +1 -1
  160. package/styles/atelier-seaside.js +1 -1
  161. package/styles/atelier-sulphurpool-light.css +1 -1
  162. package/styles/atelier-sulphurpool-light.js +1 -1
  163. package/styles/atelier-sulphurpool.css +1 -1
  164. package/styles/atelier-sulphurpool.js +1 -1
  165. package/styles/atlas.css +1 -1
  166. package/styles/atlas.js +1 -1
  167. package/styles/atom-one-dark-reasonable.css +1 -1
  168. package/styles/atom-one-dark-reasonable.js +1 -1
  169. package/styles/atom-one-dark.css +1 -1
  170. package/styles/atom-one-dark.js +1 -1
  171. package/styles/atom-one-light.css +1 -1
  172. package/styles/atom-one-light.js +1 -1
  173. package/styles/base16-github.css +1 -1
  174. package/styles/base16-github.js +1 -1
  175. package/styles/base16-ir-black.css +1 -1
  176. package/styles/base16-ir-black.js +1 -1
  177. package/styles/base16-monokai.css +1 -1
  178. package/styles/base16-monokai.js +1 -1
  179. package/styles/base16-nord.css +1 -1
  180. package/styles/base16-nord.js +1 -1
  181. package/styles/bespin.css +1 -1
  182. package/styles/bespin.js +1 -1
  183. package/styles/black-metal-bathory.css +1 -1
  184. package/styles/black-metal-bathory.js +1 -1
  185. package/styles/black-metal-burzum.css +1 -1
  186. package/styles/black-metal-burzum.js +1 -1
  187. package/styles/black-metal-dark-funeral.css +1 -1
  188. package/styles/black-metal-dark-funeral.js +1 -1
  189. package/styles/black-metal-gorgoroth.css +1 -1
  190. package/styles/black-metal-gorgoroth.js +1 -1
  191. package/styles/black-metal-immortal.css +1 -1
  192. package/styles/black-metal-immortal.js +1 -1
  193. package/styles/black-metal-khold.css +1 -1
  194. package/styles/black-metal-khold.js +1 -1
  195. package/styles/black-metal-marduk.css +1 -1
  196. package/styles/black-metal-marduk.js +1 -1
  197. package/styles/black-metal-mayhem.css +1 -1
  198. package/styles/black-metal-mayhem.js +1 -1
  199. package/styles/black-metal-nile.css +1 -1
  200. package/styles/black-metal-nile.js +1 -1
  201. package/styles/black-metal-venom.css +1 -1
  202. package/styles/black-metal-venom.js +1 -1
  203. package/styles/black-metal.css +1 -1
  204. package/styles/black-metal.js +1 -1
  205. package/styles/brewer.css +1 -1
  206. package/styles/brewer.js +1 -1
  207. package/styles/bright.css +1 -1
  208. package/styles/bright.js +1 -1
  209. package/styles/brogrammer.css +1 -1
  210. package/styles/brogrammer.js +1 -1
  211. package/styles/brown-paper.css +1 -1
  212. package/styles/brown-paper.js +1 -1
  213. package/styles/brush-trees-dark.css +1 -1
  214. package/styles/brush-trees-dark.js +1 -1
  215. package/styles/brush-trees.css +1 -1
  216. package/styles/brush-trees.js +1 -1
  217. package/styles/chalk.css +1 -1
  218. package/styles/chalk.js +1 -1
  219. package/styles/circus.css +1 -1
  220. package/styles/circus.js +1 -1
  221. package/styles/classic-dark.css +1 -1
  222. package/styles/classic-dark.js +1 -1
  223. package/styles/classic-light.css +1 -1
  224. package/styles/classic-light.js +1 -1
  225. package/styles/codepen-embed.css +1 -1
  226. package/styles/codepen-embed.js +1 -1
  227. package/styles/codeschool.css +1 -1
  228. package/styles/codeschool.js +1 -1
  229. package/styles/color-brewer.css +1 -1
  230. package/styles/color-brewer.js +1 -1
  231. package/styles/colors.css +1 -1
  232. package/styles/colors.js +1 -1
  233. package/styles/cupcake.css +1 -1
  234. package/styles/cupcake.js +1 -1
  235. package/styles/cupertino.css +1 -1
  236. package/styles/cupertino.js +1 -1
  237. package/styles/danqing.css +1 -1
  238. package/styles/danqing.js +1 -1
  239. package/styles/darcula.css +1 -1
  240. package/styles/darcula.js +1 -1
  241. package/styles/dark-violet.css +1 -1
  242. package/styles/dark-violet.js +1 -1
  243. package/styles/dark.css +1 -1
  244. package/styles/dark.js +1 -1
  245. package/styles/darkmoss.css +1 -1
  246. package/styles/darkmoss.js +1 -1
  247. package/styles/darktooth.css +1 -1
  248. package/styles/darktooth.js +1 -1
  249. package/styles/decaf.css +1 -1
  250. package/styles/decaf.js +1 -1
  251. package/styles/default-dark.css +1 -1
  252. package/styles/default-dark.js +1 -1
  253. package/styles/default-light.css +1 -1
  254. package/styles/default-light.js +1 -1
  255. package/styles/default.css +1 -1
  256. package/styles/default.js +1 -1
  257. package/styles/devibeans.css +1 -1
  258. package/styles/devibeans.js +1 -1
  259. package/styles/dirtysea.css +1 -1
  260. package/styles/dirtysea.js +1 -1
  261. package/styles/docco.css +1 -1
  262. package/styles/docco.js +1 -1
  263. package/styles/dracula.css +1 -1
  264. package/styles/dracula.js +1 -1
  265. package/styles/edge-dark.css +1 -1
  266. package/styles/edge-dark.js +1 -1
  267. package/styles/edge-light.css +1 -1
  268. package/styles/edge-light.js +1 -1
  269. package/styles/eighties.css +1 -1
  270. package/styles/eighties.js +1 -1
  271. package/styles/embers.css +1 -1
  272. package/styles/embers.js +1 -1
  273. package/styles/equilibrium-dark.css +1 -1
  274. package/styles/equilibrium-dark.js +1 -1
  275. package/styles/equilibrium-gray-dark.css +1 -1
  276. package/styles/equilibrium-gray-dark.js +1 -1
  277. package/styles/equilibrium-gray-light.css +1 -1
  278. package/styles/equilibrium-gray-light.js +1 -1
  279. package/styles/equilibrium-light.css +1 -1
  280. package/styles/equilibrium-light.js +1 -1
  281. package/styles/espresso.css +1 -1
  282. package/styles/espresso.js +1 -1
  283. package/styles/eva-dim.css +1 -1
  284. package/styles/eva-dim.js +1 -1
  285. package/styles/eva.css +1 -1
  286. package/styles/eva.js +1 -1
  287. package/styles/far.css +1 -1
  288. package/styles/far.js +1 -1
  289. package/styles/felipec.css +1 -1
  290. package/styles/felipec.js +1 -1
  291. package/styles/flat.css +1 -1
  292. package/styles/flat.js +1 -1
  293. package/styles/foundation.css +1 -1
  294. package/styles/foundation.js +1 -1
  295. package/styles/framer.css +1 -1
  296. package/styles/framer.js +1 -1
  297. package/styles/fruit-soda.css +1 -1
  298. package/styles/fruit-soda.js +1 -1
  299. package/styles/gigavolt.css +1 -1
  300. package/styles/gigavolt.js +1 -1
  301. package/styles/github-dark-dimmed.css +1 -1
  302. package/styles/github-dark-dimmed.js +1 -1
  303. package/styles/github-dark.css +1 -1
  304. package/styles/github-dark.js +1 -1
  305. package/styles/github.css +1 -1
  306. package/styles/github.js +1 -1
  307. package/styles/gml.css +1 -1
  308. package/styles/gml.js +1 -1
  309. package/styles/google-dark.css +1 -1
  310. package/styles/google-dark.js +1 -1
  311. package/styles/google-light.css +1 -1
  312. package/styles/google-light.js +1 -1
  313. package/styles/googlecode.css +1 -2
  314. package/styles/googlecode.js +1 -2
  315. package/styles/gradient-dark.css +2 -3
  316. package/styles/gradient-dark.js +2 -3
  317. package/styles/gradient-light.css +2 -3
  318. package/styles/gradient-light.js +2 -3
  319. package/styles/grayscale-dark.css +1 -1
  320. package/styles/grayscale-dark.js +1 -1
  321. package/styles/grayscale-light.css +1 -1
  322. package/styles/grayscale-light.js +1 -1
  323. package/styles/grayscale.css +1 -1
  324. package/styles/grayscale.js +1 -1
  325. package/styles/green-screen.css +1 -1
  326. package/styles/green-screen.js +1 -1
  327. package/styles/gruvbox-dark-hard.css +1 -1
  328. package/styles/gruvbox-dark-hard.js +1 -1
  329. package/styles/gruvbox-dark-medium.css +1 -1
  330. package/styles/gruvbox-dark-medium.js +1 -1
  331. package/styles/gruvbox-dark-pale.css +1 -1
  332. package/styles/gruvbox-dark-pale.js +1 -1
  333. package/styles/gruvbox-dark-soft.css +1 -1
  334. package/styles/gruvbox-dark-soft.js +1 -1
  335. package/styles/gruvbox-light-hard.css +1 -1
  336. package/styles/gruvbox-light-hard.js +1 -1
  337. package/styles/gruvbox-light-medium.css +1 -1
  338. package/styles/gruvbox-light-medium.js +1 -1
  339. package/styles/gruvbox-light-soft.css +1 -1
  340. package/styles/gruvbox-light-soft.js +1 -1
  341. package/styles/hardcore.css +1 -1
  342. package/styles/hardcore.js +1 -1
  343. package/styles/harmonic16-dark.css +1 -1
  344. package/styles/harmonic16-dark.js +1 -1
  345. package/styles/harmonic16-light.css +1 -1
  346. package/styles/harmonic16-light.js +1 -1
  347. package/styles/heetch-dark.css +1 -1
  348. package/styles/heetch-dark.js +1 -1
  349. package/styles/heetch-light.css +1 -1
  350. package/styles/heetch-light.js +1 -1
  351. package/styles/helios.css +1 -1
  352. package/styles/helios.js +1 -1
  353. package/styles/hopscotch.css +1 -1
  354. package/styles/hopscotch.js +1 -1
  355. package/styles/horizon-dark.css +1 -1
  356. package/styles/horizon-dark.js +1 -1
  357. package/styles/horizon-light.css +1 -1
  358. package/styles/horizon-light.js +1 -1
  359. package/styles/humanoid-dark.css +1 -1
  360. package/styles/humanoid-dark.js +1 -1
  361. package/styles/humanoid-light.css +1 -1
  362. package/styles/humanoid-light.js +1 -1
  363. package/styles/hybrid.css +1 -1
  364. package/styles/hybrid.js +1 -1
  365. package/styles/ia-dark.css +1 -1
  366. package/styles/ia-dark.js +1 -1
  367. package/styles/ia-light.css +1 -1
  368. package/styles/ia-light.js +1 -1
  369. package/styles/icy-dark.css +1 -1
  370. package/styles/icy-dark.js +1 -1
  371. package/styles/idea.css +1 -1
  372. package/styles/idea.js +1 -1
  373. package/styles/intellij-light.css +1 -1
  374. package/styles/intellij-light.js +1 -1
  375. package/styles/ir-black.css +1 -1
  376. package/styles/ir-black.js +1 -1
  377. package/styles/isbl-editor-dark.css +1 -1
  378. package/styles/isbl-editor-dark.js +1 -1
  379. package/styles/isbl-editor-light.css +1 -1
  380. package/styles/isbl-editor-light.js +1 -1
  381. package/styles/isotope.css +1 -1
  382. package/styles/isotope.js +1 -1
  383. package/styles/kimber.css +1 -1
  384. package/styles/kimber.js +1 -1
  385. package/styles/kimbie-dark.css +1 -1
  386. package/styles/kimbie-dark.js +1 -1
  387. package/styles/kimbie-light.css +1 -1
  388. package/styles/kimbie-light.js +1 -1
  389. package/styles/lightfair.css +1 -1
  390. package/styles/lightfair.js +1 -1
  391. package/styles/lioshi.css +1 -1
  392. package/styles/lioshi.js +1 -1
  393. package/styles/london-tube.css +1 -1
  394. package/styles/london-tube.js +1 -1
  395. package/styles/macintosh.css +1 -1
  396. package/styles/macintosh.js +1 -1
  397. package/styles/magula.css +1 -2
  398. package/styles/magula.js +1 -2
  399. package/styles/marrakesh.css +1 -1
  400. package/styles/marrakesh.js +1 -1
  401. package/styles/materia.css +1 -1
  402. package/styles/materia.js +1 -1
  403. package/styles/material-darker.css +1 -1
  404. package/styles/material-darker.js +1 -1
  405. package/styles/material-lighter.css +1 -1
  406. package/styles/material-lighter.js +1 -1
  407. package/styles/material-palenight.css +1 -1
  408. package/styles/material-palenight.js +1 -1
  409. package/styles/material-vivid.css +1 -1
  410. package/styles/material-vivid.js +1 -1
  411. package/styles/material.css +1 -1
  412. package/styles/material.js +1 -1
  413. package/styles/mellow-purple.css +1 -1
  414. package/styles/mellow-purple.js +1 -1
  415. package/styles/mexico-light.css +1 -1
  416. package/styles/mexico-light.js +1 -1
  417. package/styles/mocha.css +1 -1
  418. package/styles/mocha.js +1 -1
  419. package/styles/mono-blue.css +1 -1
  420. package/styles/mono-blue.js +1 -1
  421. package/styles/monokai-sublime.css +1 -1
  422. package/styles/monokai-sublime.js +1 -1
  423. package/styles/monokai.css +1 -1
  424. package/styles/monokai.js +1 -1
  425. package/styles/nebula.css +1 -1
  426. package/styles/nebula.js +1 -1
  427. package/styles/night-owl.css +1 -1
  428. package/styles/night-owl.js +1 -1
  429. package/styles/nnfx-dark.css +1 -1
  430. package/styles/nnfx-dark.js +1 -1
  431. package/styles/nnfx-light.css +1 -1
  432. package/styles/nnfx-light.js +1 -1
  433. package/styles/nord.css +1 -1
  434. package/styles/nord.js +1 -1
  435. package/styles/nova.css +1 -1
  436. package/styles/nova.js +1 -1
  437. package/styles/obsidian.css +1 -1
  438. package/styles/obsidian.js +1 -1
  439. package/styles/ocean.css +1 -1
  440. package/styles/ocean.js +1 -1
  441. package/styles/oceanicnext.css +1 -1
  442. package/styles/oceanicnext.js +1 -1
  443. package/styles/one-light.css +1 -1
  444. package/styles/one-light.js +1 -1
  445. package/styles/onedark.css +1 -1
  446. package/styles/onedark.js +1 -1
  447. package/styles/outrun-dark.css +1 -1
  448. package/styles/outrun-dark.js +1 -1
  449. package/styles/panda-syntax-dark.css +1 -2
  450. package/styles/panda-syntax-dark.js +1 -2
  451. package/styles/papercolor-dark.css +1 -1
  452. package/styles/papercolor-dark.js +1 -1
  453. package/styles/papercolor-light.css +1 -1
  454. package/styles/papercolor-light.js +1 -1
  455. package/styles/paraiso-dark.css +1 -1
  456. package/styles/paraiso-dark.js +1 -1
  457. package/styles/paraiso-light.css +1 -1
  458. package/styles/paraiso-light.js +1 -1
  459. package/styles/paraiso.css +1 -1
  460. package/styles/paraiso.js +1 -1
  461. package/styles/pasque.css +1 -1
  462. package/styles/pasque.js +1 -1
  463. package/styles/phd.css +1 -1
  464. package/styles/phd.js +1 -1
  465. package/styles/pico.css +1 -1
  466. package/styles/pico.js +1 -1
  467. package/styles/pojoaque.css +1 -1
  468. package/styles/pojoaque.js +1 -1
  469. package/styles/pop.css +1 -1
  470. package/styles/pop.js +1 -1
  471. package/styles/porple.css +1 -1
  472. package/styles/porple.js +1 -1
  473. package/styles/purebasic.css +1 -1
  474. package/styles/purebasic.js +1 -1
  475. package/styles/qtcreator-dark.css +1 -1
  476. package/styles/qtcreator-dark.js +1 -1
  477. package/styles/qtcreator-light.css +1 -1
  478. package/styles/qtcreator-light.js +1 -1
  479. package/styles/qualia.css +1 -1
  480. package/styles/qualia.js +1 -1
  481. package/styles/railscasts.css +1 -1
  482. package/styles/railscasts.js +1 -1
  483. package/styles/rainbow.css +1 -1
  484. package/styles/rainbow.js +1 -1
  485. package/styles/rebecca.css +1 -1
  486. package/styles/rebecca.js +1 -1
  487. package/styles/ros-pine-dawn.css +1 -1
  488. package/styles/ros-pine-dawn.js +1 -1
  489. package/styles/ros-pine-moon.css +1 -1
  490. package/styles/ros-pine-moon.js +1 -1
  491. package/styles/ros-pine.css +1 -1
  492. package/styles/ros-pine.js +1 -1
  493. package/styles/rose-pine-dawn.css +1 -1
  494. package/styles/rose-pine-dawn.js +1 -1
  495. package/styles/rose-pine-moon.css +1 -1
  496. package/styles/rose-pine-moon.js +1 -1
  497. package/styles/rose-pine.css +1 -1
  498. package/styles/rose-pine.js +1 -1
  499. package/styles/routeros.css +1 -1
  500. package/styles/routeros.js +1 -1
  501. package/styles/sagelight.css +1 -1
  502. package/styles/sagelight.js +1 -1
  503. package/styles/sandcastle.css +1 -1
  504. package/styles/sandcastle.js +1 -1
  505. package/styles/school-book.css +1 -1
  506. package/styles/school-book.js +1 -1
  507. package/styles/seti-ui.css +1 -1
  508. package/styles/seti-ui.js +1 -1
  509. package/styles/shades-of-purple.css +2 -3
  510. package/styles/shades-of-purple.js +2 -3
  511. package/styles/shapeshifter.css +1 -1
  512. package/styles/shapeshifter.js +1 -1
  513. package/styles/silk-dark.css +1 -1
  514. package/styles/silk-dark.js +1 -1
  515. package/styles/silk-light.css +1 -1
  516. package/styles/silk-light.js +1 -1
  517. package/styles/snazzy.css +1 -1
  518. package/styles/snazzy.js +1 -1
  519. package/styles/solar-flare-light.css +1 -1
  520. package/styles/solar-flare-light.js +1 -1
  521. package/styles/solar-flare.css +1 -1
  522. package/styles/solar-flare.js +1 -1
  523. package/styles/solarized-dark.css +1 -1
  524. package/styles/solarized-dark.js +1 -1
  525. package/styles/solarized-light.css +1 -1
  526. package/styles/solarized-light.js +1 -1
  527. package/styles/spacemacs.css +1 -1
  528. package/styles/spacemacs.js +1 -1
  529. package/styles/srcery.css +1 -1
  530. package/styles/srcery.js +1 -1
  531. package/styles/stackoverflow-dark.css +1 -1
  532. package/styles/stackoverflow-dark.js +1 -1
  533. package/styles/stackoverflow-light.css +1 -1
  534. package/styles/stackoverflow-light.js +1 -1
  535. package/styles/summercamp.css +1 -1
  536. package/styles/summercamp.js +1 -1
  537. package/styles/summerfruit-dark.css +1 -1
  538. package/styles/summerfruit-dark.js +1 -1
  539. package/styles/summerfruit-light.css +1 -1
  540. package/styles/summerfruit-light.js +1 -1
  541. package/styles/sunburst.css +1 -1
  542. package/styles/sunburst.js +1 -1
  543. package/styles/synth-midnight-terminal-dark.css +1 -1
  544. package/styles/synth-midnight-terminal-dark.js +1 -1
  545. package/styles/synth-midnight-terminal-light.css +1 -1
  546. package/styles/synth-midnight-terminal-light.js +1 -1
  547. package/styles/tango.css +1 -1
  548. package/styles/tango.js +1 -1
  549. package/styles/tender.css +1 -1
  550. package/styles/tender.js +1 -1
  551. package/styles/tokyo-night-dark.css +1 -2
  552. package/styles/tokyo-night-dark.js +1 -2
  553. package/styles/tokyo-night-light.css +1 -2
  554. package/styles/tokyo-night-light.js +1 -2
  555. package/styles/tomorrow-night-blue.css +1 -1
  556. package/styles/tomorrow-night-blue.js +1 -1
  557. package/styles/tomorrow-night-bright.css +1 -1
  558. package/styles/tomorrow-night-bright.js +1 -1
  559. package/styles/tomorrow-night.css +1 -1
  560. package/styles/tomorrow-night.js +1 -1
  561. package/styles/tomorrow.css +1 -1
  562. package/styles/tomorrow.js +1 -1
  563. package/styles/twilight.css +1 -1
  564. package/styles/twilight.js +1 -1
  565. package/styles/unikitty-dark.css +1 -1
  566. package/styles/unikitty-dark.js +1 -1
  567. package/styles/unikitty-light.css +1 -1
  568. package/styles/unikitty-light.js +1 -1
  569. package/styles/vs.css +1 -1
  570. package/styles/vs.js +1 -1
  571. package/styles/vs2015.css +1 -1
  572. package/styles/vs2015.js +1 -1
  573. package/styles/vulcan.css +1 -1
  574. package/styles/vulcan.js +1 -1
  575. package/styles/windows-10-light.css +1 -1
  576. package/styles/windows-10-light.js +1 -1
  577. package/styles/windows-10.css +1 -1
  578. package/styles/windows-10.js +1 -1
  579. package/styles/windows-95-light.css +1 -1
  580. package/styles/windows-95-light.js +1 -1
  581. package/styles/windows-95.css +1 -1
  582. package/styles/windows-95.js +1 -1
  583. package/styles/windows-high-contrast-light.css +1 -1
  584. package/styles/windows-high-contrast-light.js +1 -1
  585. package/styles/windows-high-contrast.css +1 -1
  586. package/styles/windows-high-contrast.js +1 -1
  587. package/styles/windows-nt-light.css +1 -1
  588. package/styles/windows-nt-light.js +1 -1
  589. package/styles/windows-nt.css +1 -1
  590. package/styles/windows-nt.js +1 -1
  591. package/styles/woodland.css +1 -1
  592. package/styles/woodland.js +1 -1
  593. package/styles/xcode-dusk.css +1 -1
  594. package/styles/xcode-dusk.js +1 -1
  595. package/styles/xcode.css +1 -1
  596. package/styles/xcode.js +1 -1
  597. package/styles/xt256.css +1 -1
  598. package/styles/xt256.js +1 -1
  599. package/styles/zenburn.css +1 -1
  600. package/styles/zenburn.js +1 -1
package/README.md CHANGED
@@ -156,6 +156,39 @@ The component prefixes each selector with a scope class on the wrapper, so the t
156
156
 
157
157
  For a page-wide theme, use `{@html theme}` as shown above.
158
158
 
159
+ ### Dark mode
160
+
161
+ `HighlightStyle` can emit a light and a dark theme together and switch between them. Pass `light` and `dark` instead of `theme`:
162
+
163
+ ```svelte
164
+ <script>
165
+ import { Highlight, HighlightStyle } from "svelte-highlight";
166
+ import typescript from "svelte-highlight/languages/typescript";
167
+ import github from "svelte-highlight/styles/github";
168
+ import githubDark from "svelte-highlight/styles/github-dark";
169
+
170
+ const code = "const add = (a: number, b: number) => a + b;";
171
+ </script>
172
+
173
+ <HighlightStyle light={github} dark={githubDark}>
174
+ <Highlight language={typescript} {code} />
175
+ </HighlightStyle>
176
+ ```
177
+
178
+ The `mode` prop controls how the two themes are switched (default `"auto"`):
179
+
180
+ - `"auto"` — wrap each theme in a `@media (prefers-color-scheme: …)` query so the OS/browser preference decides.
181
+ - `"light"` / `"dark"` — emit only that single theme.
182
+ - any other string — treated as a CSS selector that gates the dark block while light stays the default. Use this to drive theming from a class or attribute on an ancestor, e.g. a manual theme toggle:
183
+
184
+ ```svelte
185
+ <HighlightStyle light={github} dark={githubDark} mode={'[data-theme="dark"]'}>
186
+ <Highlight language={typescript} {code} />
187
+ </HighlightStyle>
188
+ ```
189
+
190
+ Both themes are scoped to the wrapper, so different blocks can use different theme pairs on the same page. When `light` and `dark` are both set they take precedence over `theme`; passing only `theme` keeps the existing single-theme behavior unchanged.
191
+
159
192
  ## Styling with CSS variables
160
193
 
161
194
  Every `Highlight` variant forwards `$$restProps` to its top-level element, so you can style the component using CSS variables without resorting to `:global` overrides or `!important`.
@@ -224,6 +257,29 @@ These apply when `langtag` is set to `true`.
224
257
  | --langtag-border-radius | Border radius of the langtag | `0` |
225
258
  | --langtag-padding | Padding of the langtag | `1em` |
226
259
 
260
+ ### `CodeWindow` variables
261
+
262
+ | Variable | Description | Default value |
263
+ | :-------------------- | :--------------------------------------- | :---------------------------------- |
264
+ | --window-background | Background color of the window body | `#1e1e1e` |
265
+ | --window-border | Border of the window | `1px solid rgba(255, 255, 255, 0.1)`|
266
+ | --window-radius | Corner radius of the window | `0` |
267
+ | --titlebar-gap | Gap between items in the title bar | `0.5em` |
268
+ | --titlebar-padding | Padding of the title bar | `0.65em 1em` |
269
+ | --titlebar-background | Background color of the title bar | `#2d2d2d` |
270
+ | --titlebar-border | Bottom border of the title bar | `1px solid rgba(255, 255, 255, 0.1)`|
271
+ | --titlebar-color | Text color of the title bar | `rgba(255, 255, 255, 0.6)` |
272
+ | --titlebar-font-family| Font family of the title bar | `system-ui, -apple-system, sans-serif`|
273
+ | --titlebar-font-size | Font size of the title bar | `0.8125em` |
274
+ | --dot-gap | Gap between the macOS traffic-light dots | `0.5em` |
275
+ | --dot-size | Diameter of the macOS traffic-light dots | `0.75em` |
276
+ | --dot-close | Color of the "close" traffic-light dot | `#ff5f56` |
277
+ | --dot-minimize | Color of the "minimize" traffic-light dot| `#ffbd2e` |
278
+ | --dot-maximize | Color of the "maximize" traffic-light dot| `#27c93f` |
279
+ | --prompt-font-family | Font family of the terminal prompt | `ui-monospace, monospace` |
280
+ | --prompt-font-weight | Font weight of the terminal prompt | `700` |
281
+ | --prompt-color | Color of the terminal prompt | `inherit` |
282
+
227
283
  ## Svelte Syntax Highlighting
228
284
 
229
285
  Use the `HighlightSvelte` component for Svelte syntax highlighting.
@@ -534,6 +590,80 @@ When using a language tag alongside `CopyButton`, offset `--langtag-top` and `--
534
590
  </div>
535
591
  ```
536
592
 
593
+ ## Editable
594
+
595
+ `HighlightEditable` is a `contenteditable` code block. It re-highlights on every edit and keeps the caret where you left it.
596
+
597
+ Use `bind:code` to keep your state in sync.
598
+
599
+ ```svelte
600
+ <script>
601
+ import { HighlightEditable } from "svelte-highlight";
602
+ import typescript from "svelte-highlight/languages/typescript";
603
+ import atomOneDark from "svelte-highlight/styles/atom-one-dark";
604
+
605
+ let code = "const add = (a: number, b: number) => a + b";
606
+ </script>
607
+
608
+ <svelte:head>
609
+ {@html atomOneDark}
610
+ </svelte:head>
611
+
612
+ <HighlightEditable language={typescript} bind:code />
613
+ ```
614
+
615
+ ### Keyboard Behavior
616
+
617
+ - **Enter** inserts a newline.
618
+ - **Tab** / **Shift+Tab** indent or dedent the selected lines (or insert one indent at the caret). Set the indent size with the `tabSize` prop (default `2`).
619
+ - **Cmd/Ctrl+Z** undo and **Shift+Cmd/Ctrl+Z** (or **Ctrl+Y**) redo. Typing bursts collapse into a single undo step; cap the retained history with the `historyLimit` prop (default `200`).
620
+
621
+ ### Dispatched Events
622
+
623
+ `HighlightEditable` dispatches `change` (on every edit), `blur`, and `history` (whenever the undo/redo stack changes).
624
+
625
+ ```svelte
626
+ <HighlightEditable
627
+ language={typescript}
628
+ bind:code
629
+ on:change={(e) => console.log(e.detail.code)}
630
+ on:blur={(e) => console.log(e.detail.code)}
631
+ on:history={(e) => console.log(e.detail.canUndo, e.detail.canRedo)}
632
+ />
633
+ ```
634
+
635
+ ### Imperative API
636
+
637
+ Use `bind:this` to call methods on the instance.
638
+
639
+ ```svelte
640
+ <script>
641
+ let editor;
642
+ </script>
643
+
644
+ <HighlightEditable bind:this={editor} language={typescript} bind:code />
645
+
646
+ <button on:click={() => editor.undo()}>Undo</button>
647
+ <button on:click={() => editor.redo()}>Redo</button>
648
+ <button on:click={() => editor.indent()}>Indent</button>
649
+ <button on:click={() => editor.clear()}>Clear</button>
650
+ ```
651
+
652
+ Available methods: `undo`, `redo`, `focus`, `selectAll`, `insert`, `indent`, `outdent`, `setCode`, `clear`, `getCode`, `canUndo`, and `canRedo`.
653
+
654
+ ### Custom Styles
655
+
656
+ Customize the focus outline with the `--outline-color`, `--outline-width`, and `--outline-offset` style props.
657
+
658
+ ```svelte
659
+ <HighlightEditable
660
+ language={typescript}
661
+ bind:code
662
+ --outline-color="#42be65"
663
+ --outline-width="2px"
664
+ />
665
+ ```
666
+
537
667
  ## Language Targeting
538
668
 
539
669
  All `Highlight` components apply a `data-language` attribute on the codeblock containing the language name.
@@ -686,6 +816,398 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
686
816
  />
687
817
  ```
688
818
 
819
+ ### Loading a language by name
820
+
821
+ The example above imports a specific language as a static string, which lets the bundler split out only the grammars you reference. When the language is known only at **runtime** — a Markdown fence (` ```ts `), an API field, or a user-selected value — use the `loadLanguage` helper to import a grammar by name:
822
+
823
+ ```svelte
824
+ <script>
825
+ import { Highlight, loadLanguage } from "svelte-highlight";
826
+ import github from "svelte-highlight/styles/github";
827
+
828
+ // The language name is not known until runtime.
829
+ export let language = "typescript";
830
+ export let code = "const add = (a, b) => a + b;";
831
+ </script>
832
+
833
+ <svelte:head>
834
+ {@html github}
835
+ </svelte:head>
836
+
837
+ {#await loadLanguage(language) then grammar}
838
+ <Highlight {code} language={grammar} />
839
+ {:catch}
840
+ <pre>{code}</pre>
841
+ {/await}
842
+ ```
843
+
844
+ `loadLanguage` accepts a [supported language name](SUPPORTED_LANGUAGES.md), dynamically imports its grammar, and resolves with the language object. It rejects with an `Unknown language` error for an unrecognized name, so handle the `{:catch}` block (or `.catch`) when the name comes from untrusted input.
845
+
846
+ > **Note:** Because the imported name is dynamic, the bundler cannot prune unused grammars and will emit a chunk for every language. Prefer a static `import` when the language is known ahead of time, and reach for `loadLanguage` only when it is not.
847
+
848
+ A practical case is rendering Markdown, where each fenced block declares its own language:
849
+
850
+ ```js
851
+ import { loadLanguage } from "svelte-highlight";
852
+
853
+ // e.g. from a Markdown fence: ```ts → "typescript"
854
+ async function highlightFence(fenceLang, code) {
855
+ const grammar = await loadLanguage(fenceLang);
856
+ return { code, language: grammar };
857
+ }
858
+ ```
859
+
860
+ ## Static mode
861
+
862
+ `svelte-highlight/static` is a Svelte preprocessor. At build time it replaces `<Highlight>` usages that have known `code` and `language` with pre-rendered `highlight.js` HTML, so the client never downloads `highlight.js` or that grammar module.
863
+
864
+ The biggest win is on server-rendered or statically-generated pages, since a client-only SPA still ships the pre-rendered markup as a string inside the JS bundle, just without `highlight.js` and the grammar module.
865
+
866
+ ```js
867
+ // vite.config.js
868
+ import { svelte } from "@sveltejs/vite-plugin-svelte";
869
+ import { highlightStatic } from "svelte-highlight/static";
870
+
871
+ export default {
872
+ plugins: [svelte({ preprocess: [highlightStatic()] })],
873
+ };
874
+ ```
875
+
876
+ ```svelte
877
+ <script>
878
+ import Highlight from "svelte-highlight";
879
+ import javascript from "svelte-highlight/languages/javascript";
880
+ </script>
881
+
882
+ <Highlight language={javascript} code="const x = 1;" />
883
+ ```
884
+
885
+ At build time this becomes plain HTML:
886
+
887
+ ```html
888
+ <pre class="hljs" data-language="javascript"><code class="hljs"
889
+ ><span class="hljs-keyword">const</span> x = <span class="hljs-number">1</span>;</code
890
+ ></pre>
891
+ ```
892
+
893
+ The static transform runs only when all of these are true:
894
+
895
+ - `language` is a plain identifier from a static `import` of `svelte-highlight/languages/*`.
896
+ - `code` is a string literal or a template literal with no `${...}` interpolation.
897
+ - The element has no slot content, spread props, or directives (`bind:`, `on:`, etc.).
898
+ - `langtag` is not set. Static output can't pull in `langtag.css`; that only happens when a runtime `LangTag` is in the bundle.
899
+
900
+ Dynamic `code` or `language`, `loadLanguage`, `HighlightAuto`, `HighlightSvelte`, and `HighlightEditable` keep the runtime component. No warning. That's intentional.
901
+
902
+ If a usage looks static but still fails (language module missing, `highlight.js` throws), it falls back to the runtime component and calls `onWarn`. Usually that's a typo or a resolution quirk, not a dynamic usage you meant to keep:
903
+
904
+ ```js
905
+ highlightStatic({
906
+ onWarn(message, { filename, line, cause }) {
907
+ // defaults to `console.warn(`[svelte-highlight/static] ${filename}:${line} - ${message}`)`
908
+ },
909
+ });
910
+ ```
911
+
912
+ Scope is small on purpose. Extra props on `<Highlight>` don't carry over to the emitted `<pre>`. Unused `Highlight` and language imports are left in place; bundlers drop them (`sideEffects` in `package.json` is narrow enough). No Astro/MDX fence hook yet.
913
+
914
+ ## Action
915
+
916
+ Use the `highlight` action to highlight existing `<pre><code>` markup in place. This is useful for progressively enhancing server-rendered content (e.g. markdown) without swapping in a component.
917
+
918
+ The action accepts the same `language` prop as the components. When `code` is omitted, the element's existing `textContent` is highlighted. Updating `code` re-highlights the element.
919
+
920
+ ```svelte
921
+ <script>
922
+ import { highlight } from "svelte-highlight";
923
+ import typescript from "svelte-highlight/languages/typescript";
924
+ import github from "svelte-highlight/styles/github";
925
+
926
+ const code = "const add = (a: number, b: number) => a + b;";
927
+ </script>
928
+
929
+ <svelte:head>
930
+ {@html github}
931
+ </svelte:head>
932
+
933
+ <pre><code use:highlight={{ language: typescript, code }}></code></pre>
934
+ ```
935
+
936
+ Omit `code` to highlight the element's existing contents:
937
+
938
+ ```svelte
939
+ <pre><code use:highlight={{ language: typescript }}
940
+ >const add = (a, b) => a + b;</code
941
+ ></pre>
942
+ ```
943
+
944
+ ## Code Window
945
+
946
+ Wrap a code block in `CodeWindow` to frame it with window chrome. It's purely cosmetic; the default slot renders your content unchanged.
947
+
948
+ Use the `variant` prop to choose the chrome style: `"macos"` (default) renders traffic-light dots, `"terminal"` renders a prompt, and `"plain"` renders just the title bar. The optional `title` is shown in the title bar.
949
+
950
+ ```svelte
951
+ <script>
952
+ import Highlight, { CodeWindow } from "svelte-highlight";
953
+ import typescript from "svelte-highlight/languages/typescript";
954
+ import github from "svelte-highlight/styles/github";
955
+
956
+ const code = "const add = (a: number, b: number) => a + b;";
957
+ </script>
958
+
959
+ <svelte:head>
960
+ {@html github}
961
+ </svelte:head>
962
+
963
+ <CodeWindow variant="macos" title="example.ts">
964
+ <Highlight language={typescript} {code} />
965
+ </CodeWindow>
966
+ ```
967
+
968
+ ### Terminal output
969
+
970
+ Pair `variant="terminal"` with a shell language to frame command-line output:
971
+
972
+ ```svelte
973
+ <script>
974
+ import Highlight, { CodeWindow } from "svelte-highlight";
975
+ import bash from "svelte-highlight/languages/bash";
976
+ import nord from "svelte-highlight/styles/nord";
977
+
978
+ const code = `$ npm install svelte-highlight
979
+
980
+ added 1 package in 1.2s`;
981
+ </script>
982
+
983
+ <svelte:head>
984
+ {@html nord}
985
+ </svelte:head>
986
+
987
+ <CodeWindow variant="terminal" title="bash">
988
+ <Highlight language={bash} {code} />
989
+ </CodeWindow>
990
+ ```
991
+
992
+ ### Theming the chrome
993
+
994
+ Every part of the chrome is driven by CSS variables (see [`CodeWindow` variables](#codewindow-variables)). Pass them as style props to restyle the window without `:global` overrides. For example, give the default square window rounded corners with `--window-radius`:
995
+
996
+ ```svelte
997
+ <CodeWindow
998
+ variant="macos"
999
+ title="example.ts"
1000
+ --window-radius="12px"
1001
+ --window-background="#0d1117"
1002
+ --window-border="1px solid #30363d"
1003
+ --titlebar-background="#161b22"
1004
+ --titlebar-color="#8b949e"
1005
+ >
1006
+ <Highlight language={typescript} {code} />
1007
+ </CodeWindow>
1008
+ ```
1009
+
1010
+ The macOS traffic-light dots are themable too. Recolor them, or mute them to a single neutral color:
1011
+
1012
+ ```svelte
1013
+ <CodeWindow
1014
+ variant="macos"
1015
+ title="example.ts"
1016
+ --dot-close="#888"
1017
+ --dot-minimize="#888"
1018
+ --dot-maximize="#888"
1019
+ >
1020
+ <Highlight language={typescript} {code} />
1021
+ </CodeWindow>
1022
+ ```
1023
+
1024
+ The `plain` variant drops the dots and prompt for a minimal titled bar:
1025
+
1026
+ ```svelte
1027
+ <CodeWindow variant="plain" title="example.ts">
1028
+ <Highlight language={typescript} {code} />
1029
+ </CodeWindow>
1030
+ ```
1031
+
1032
+ ### Composing with other components
1033
+
1034
+ `CodeWindow` only frames its slot, so it composes with the rest of the library. Add `LineNumbers` inside it:
1035
+
1036
+ ```svelte
1037
+ <script>
1038
+ import Highlight, { CodeWindow, LineNumbers } from "svelte-highlight";
1039
+ import typescript from "svelte-highlight/languages/typescript";
1040
+ import github from "svelte-highlight/styles/github";
1041
+
1042
+ const code = `const add = (a, b) => a + b;
1043
+ const sub = (a, b) => a - b;`;
1044
+ </script>
1045
+
1046
+ <svelte:head>
1047
+ {@html github}
1048
+ </svelte:head>
1049
+
1050
+ <CodeWindow variant="macos" title="math.ts">
1051
+ <Highlight language={typescript} {code} let:highlighted>
1052
+ <LineNumbers {highlighted} hideBorder />
1053
+ </Highlight>
1054
+ </CodeWindow>
1055
+ ```
1056
+
1057
+ Or layer a `CopyButton` over it by wrapping both in a relatively-positioned container:
1058
+
1059
+ ```svelte
1060
+ <div style="position: relative">
1061
+ <CodeWindow variant="macos" title="example.ts">
1062
+ <Highlight language={typescript} {code} />
1063
+ </CodeWindow>
1064
+ <!-- Offset the button so it clears the title bar. -->
1065
+ <CopyButton {code} --copy-top="3em" />
1066
+ </div>
1067
+ ```
1068
+
1069
+ ## Animation
1070
+
1071
+ Use `Typewriter` inside `Highlight`'s default slot with the `highlighted` prop. It prints the code one character at a time, syntax highlighting included. A blinking caret marks the end of the typed text and hides when typing stops.
1072
+
1073
+ Unrevealed text stays in the layout but invisible, so the block is full height from the start. Content below won't jump as characters appear. You don't need a `min-height` hack.
1074
+
1075
+ ```svelte
1076
+ <script>
1077
+ import Highlight, { Typewriter } from "svelte-highlight";
1078
+ import typescript from "svelte-highlight/languages/typescript";
1079
+ import github from "svelte-highlight/styles/github";
1080
+
1081
+ const code = "const add = (a: number, b: number) => a + b;";
1082
+ </script>
1083
+
1084
+ <svelte:head>
1085
+ {@html github}
1086
+ </svelte:head>
1087
+
1088
+ <Highlight language={typescript} {code} let:highlighted>
1089
+ <Typewriter {highlighted} />
1090
+ </Highlight>
1091
+ ```
1092
+
1093
+ Set `speed` (milliseconds per character) and pause with `play`. Turn `play` back on to pick up where you left off. A new `highlighted` value starts over from the first character. Fire `on:done` when the last character is visible.
1094
+
1095
+ ```svelte
1096
+ <Highlight language={typescript} {code} let:highlighted>
1097
+ <Typewriter
1098
+ {highlighted}
1099
+ speed={50}
1100
+ {play}
1101
+ on:done={() => console.log("revealed")}
1102
+ />
1103
+ </Highlight>
1104
+ ```
1105
+
1106
+ With `prefers-reduced-motion`, the full block shows immediately and `on:done` runs right away. Customize the caret with `--caret-width`, `--caret-height`, `--caret-gap`, `--caret-color`, and `--caret-blink`.
1107
+
1108
+ ## Terminal Output
1109
+
1110
+ Use `AnsiOutput` to render terminal output that still contains ANSI [SGR](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters) escape codes. Colors, bold, dim, italic, and underline become styled HTML. The parser is separate from highlight.js, so reach for it with build logs, CLI output, and test runners.
1111
+
1112
+ ```svelte
1113
+ <script>
1114
+ import { AnsiOutput } from "svelte-highlight";
1115
+
1116
+ // Raw program output, escape codes included.
1117
+ const text = "\x1b[32m✓\x1b[0m build succeeded \x1b[2m(1.2s)\x1b[0m";
1118
+ </script>
1119
+
1120
+ <AnsiOutput {text} />
1121
+ ```
1122
+
1123
+ Malformed or unsupported escape sequences are dropped. Nothing throws.
1124
+
1125
+ ### Theming the palette
1126
+
1127
+ Pass `--ansi-*` style props to recolor the output. The 16 base colors, default foreground and background, and bold/dim weight and opacity all come from CSS variables with hex fallbacks:
1128
+
1129
+ ```svelte
1130
+ <AnsiOutput
1131
+ {text}
1132
+ --ansi-background="#0d1117"
1133
+ --ansi-red="#ff7b72"
1134
+ --ansi-green="#3fb950"
1135
+ />
1136
+ ```
1137
+
1138
+ 256-color and 24-bit truecolor codes resolve to RGB.
1139
+
1140
+ ### Readable colors
1141
+
1142
+ With `autoContrast` on (the default), spans that set a background get a readable foreground. If the chosen text color would disappear on that background (white on white, for example), it flips to black or white, whichever reads better. Only spans with a background are adjusted. Set `autoContrast={false}` to keep the ANSI colors as-is.
1143
+
1144
+ ```svelte
1145
+ <AnsiOutput {text} autoContrast={false} />
1146
+ ```
1147
+
1148
+ ### Pairing with `CodeWindow`
1149
+
1150
+ Put `AnsiOutput` inside `CodeWindow variant="terminal"` for the prompt and title bar:
1151
+
1152
+ ```svelte
1153
+ <script>
1154
+ import { AnsiOutput, CodeWindow } from "svelte-highlight";
1155
+
1156
+ const text = "\x1b[1;32m$\x1b[0m npm run build";
1157
+ </script>
1158
+
1159
+ <CodeWindow variant="terminal" title="bash">
1160
+ <AnsiOutput {text} />
1161
+ </CodeWindow>
1162
+ ```
1163
+
1164
+ Call `parseAnsi` directly if you need the segments yourself:
1165
+
1166
+ ```js
1167
+ import { parseAnsi } from "svelte-highlight";
1168
+
1169
+ parseAnsi("\x1b[31merror\x1b[0m");
1170
+ // => [{ text: "error", fg: { name: "red" } }]
1171
+ ```
1172
+
1173
+ ## File Tabs
1174
+
1175
+ `FileTabs` groups code snippets behind a tab strip, like files in an editor. Pass file names as `files`, then use `let:active` in the default slot to render the matching snippet.
1176
+
1177
+ Arrow keys move between tabs; `Home` and `End` jump to the first and last. The markup follows the WAI-ARIA tabs pattern (`role="tablist"`, `role="tab"`, `role="tabpanel"`).
1178
+
1179
+ ```svelte
1180
+ <script>
1181
+ import Highlight, { FileTabs } from "svelte-highlight";
1182
+ import javascript from "svelte-highlight/languages/javascript";
1183
+ import typescript from "svelte-highlight/languages/typescript";
1184
+ import github from "svelte-highlight/styles/github";
1185
+
1186
+ const sources = {
1187
+ "App.svelte": { language: typescript, code: "const answer = 42;" },
1188
+ "index.js": { language: javascript, code: "export default answer;" },
1189
+ };
1190
+
1191
+ const files = Object.keys(sources);
1192
+ </script>
1193
+
1194
+ <svelte:head>
1195
+ {@html github}
1196
+ </svelte:head>
1197
+
1198
+ <FileTabs {files} let:active>
1199
+ <Highlight language={sources[active].language} code={sources[active].code} />
1200
+ </FileTabs>
1201
+ ```
1202
+
1203
+ `bind:active` sets the open tab from your code. `on:change` fires when the user picks a different one.
1204
+
1205
+ ```svelte
1206
+ <FileTabs {files} bind:active on:change={(e) => console.log(e.detail.active)}>
1207
+ <Highlight language={sources[active].language} code={sources[active].code} />
1208
+ </FileTabs>
1209
+ ```
1210
+
689
1211
  ## Component API
690
1212
 
691
1213
  ### `Highlight`
@@ -761,6 +1283,28 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
761
1283
  />
762
1284
  ```
763
1285
 
1286
+ ### `CodeWindow`
1287
+
1288
+ #### Props
1289
+
1290
+ | Name | Type | Default value |
1291
+ | :------ | :--------------------------------- | :------------ |
1292
+ | variant | `"macos" \| "terminal" \| "plain"` | `"macos"` |
1293
+ | title | `string` | `""` |
1294
+
1295
+ `$$restProps` are forwarded to the top-level `div` element.
1296
+
1297
+ ### `AnsiOutput`
1298
+
1299
+ #### Props
1300
+
1301
+ | Name | Type | Default value |
1302
+ | :----------- | :-------- | :------------- |
1303
+ | text | `string` | N/A (required) |
1304
+ | autoContrast | `boolean` | `true` |
1305
+
1306
+ `$$restProps` are forwarded to the top-level `pre` element.
1307
+
764
1308
  ### `HighlightSvelte`
765
1309
 
766
1310
  #### Props
@@ -830,6 +1374,83 @@ import type { LanguageName } from "svelte-highlight";
830
1374
  />
831
1375
  ```
832
1376
 
1377
+ ### `HighlightEditable`
1378
+
1379
+ #### Props
1380
+
1381
+ | Name | Type | Default value |
1382
+ | :----------- | :--------------------------------------------- | :------------- |
1383
+ | code | `string` | `""` |
1384
+ | language | { name: `string`; register: hljs => `object` } | N/A (required) |
1385
+ | tabSize | `number` | `2` |
1386
+ | historyLimit | `number` | `200` |
1387
+
1388
+ `$$restProps` are forwarded to the top-level `pre` element.
1389
+
1390
+ `code` supports two-way binding (`bind:code`).
1391
+
1392
+ #### Methods
1393
+
1394
+ Use `bind:this`, then call `undo()`, `redo()`, `focus()`, `selectAll()`, `insert(text)`, `indent()`, `outdent()`, `setCode(value)`, `clear()`, `getCode()`, `canUndo()`, or `canRedo()`.
1395
+
1396
+ #### Dispatched Events
1397
+
1398
+ - **on:change**: fired on every edit, with `{ code }`
1399
+ - **on:blur**: fired when the editor loses focus, with `{ code }`
1400
+ - **on:history**: fired when the undo/redo stack changes, with `{ entries, index, canUndo, canRedo }`
1401
+
1402
+ ```svelte
1403
+ <HighlightEditable
1404
+ language={typescript}
1405
+ bind:code
1406
+ on:change={(e) => console.log(e.detail.code)}
1407
+ on:history={(e) => console.log(e.detail.canUndo, e.detail.canRedo)}
1408
+ />
1409
+ ```
1410
+
1411
+ ### `FileTabs`
1412
+
1413
+ #### Props
1414
+
1415
+ | Name | Type | Default value |
1416
+ | :----- | :--------- | :------------- |
1417
+ | files | `string[]` | N/A (required) |
1418
+ | active | `string` | `files[0]` |
1419
+
1420
+ `$$restProps` are forwarded to the top-level `div` element. `active` supports `bind:active`.
1421
+
1422
+ #### Dispatched Events
1423
+
1424
+ - **on:change**: fired when the user picks a tab, with `{ active }`
1425
+
1426
+ ```svelte
1427
+ <FileTabs {files} on:change={(e) => console.log(e.detail.active)} let:active>
1428
+ <Highlight language={sources[active].language} code={sources[active].code} />
1429
+ </FileTabs>
1430
+ ```
1431
+
1432
+ ### `Typewriter`
1433
+
1434
+ #### Props
1435
+
1436
+ | Name | Type | Default value |
1437
+ | :---------- | :-------- | :------------ |
1438
+ | highlighted | `string` | `""` |
1439
+ | speed | `number` | `30` |
1440
+ | play | `boolean` | `true` |
1441
+
1442
+ `$$restProps` are forwarded to the top-level `pre` element.
1443
+
1444
+ #### Dispatched Events
1445
+
1446
+ - **on:done**: fires when typing finishes, or immediately when reduced motion is on
1447
+
1448
+ ```svelte
1449
+ <Highlight language={typescript} {code} let:highlighted>
1450
+ <Typewriter {highlighted} on:done={() => console.log("revealed")} />
1451
+ </Highlight>
1452
+ ```
1453
+
833
1454
  ## [Supported Languages](SUPPORTED_LANGUAGES.md)
834
1455
 
835
1456
  ## [Supported Styles](SUPPORTED_STYLES.md)