svelte-highlight 6.2.0 → 7.0.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.
- package/CHANGELOG.md +35 -1
- package/Highlight.svelte +9 -11
- package/Highlight.svelte.d.ts +228 -332
- package/HighlightAuto.svelte +10 -11
- package/HighlightAuto.svelte.d.ts +233 -327
- package/HighlightSvelte.svelte +7 -6
- package/HighlightSvelte.svelte.d.ts +218 -325
- package/LineNumbers.svelte +64 -0
- package/LineNumbers.svelte.d.ts +260 -0
- package/README.md +257 -52
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/languages/1c.d.ts +2 -0
- package/languages/abnf.d.ts +2 -0
- package/languages/accesslog.d.ts +2 -0
- package/languages/actionscript.d.ts +2 -0
- package/languages/ada.d.ts +2 -0
- package/languages/angelscript.d.ts +2 -0
- package/languages/apache.d.ts +2 -0
- package/languages/applescript.d.ts +2 -0
- package/languages/arcade.d.ts +2 -0
- package/languages/arduino.d.ts +2 -0
- package/languages/armasm.d.ts +2 -0
- package/languages/asciidoc.d.ts +2 -0
- package/languages/aspectj.d.ts +2 -0
- package/languages/autohotkey.d.ts +2 -0
- package/languages/autoit.d.ts +2 -0
- package/languages/avrasm.d.ts +2 -0
- package/languages/awk.d.ts +2 -0
- package/languages/axapta.d.ts +2 -0
- package/languages/bash.d.ts +2 -0
- package/languages/basic.d.ts +2 -0
- package/languages/bnf.d.ts +2 -0
- package/languages/brainfuck.d.ts +2 -0
- package/languages/c.d.ts +2 -0
- package/languages/cal.d.ts +2 -0
- package/languages/capnproto.d.ts +2 -0
- package/languages/ceylon.d.ts +2 -0
- package/languages/clean.d.ts +2 -0
- package/languages/clojure-repl.d.ts +2 -0
- package/languages/clojure.d.ts +2 -0
- package/languages/cmake.d.ts +2 -0
- package/languages/coffeescript.d.ts +2 -0
- package/languages/coq.d.ts +2 -0
- package/languages/cos.d.ts +2 -0
- package/languages/cpp.d.ts +2 -0
- package/languages/crmsh.d.ts +2 -0
- package/languages/crystal.d.ts +2 -0
- package/languages/csharp.d.ts +2 -0
- package/languages/csp.d.ts +2 -0
- package/languages/css.d.ts +2 -0
- package/languages/d.d.ts +2 -0
- package/languages/dart.d.ts +2 -0
- package/languages/delphi.d.ts +2 -0
- package/languages/diff.d.ts +2 -0
- package/languages/django.d.ts +2 -0
- package/languages/dns.d.ts +2 -0
- package/languages/dockerfile.d.ts +2 -0
- package/languages/dos.d.ts +2 -0
- package/languages/dsconfig.d.ts +2 -0
- package/languages/dts.d.ts +2 -0
- package/languages/dust.d.ts +2 -0
- package/languages/ebnf.d.ts +2 -0
- package/languages/elixir.d.ts +2 -0
- package/languages/elm.d.ts +2 -0
- package/languages/erb.d.ts +2 -0
- package/languages/erlang-repl.d.ts +2 -0
- package/languages/erlang.d.ts +2 -0
- package/languages/excel.d.ts +2 -0
- package/languages/fix.d.ts +2 -0
- package/languages/flix.d.ts +2 -0
- package/languages/fortran.d.ts +2 -0
- package/languages/fsharp.d.ts +2 -0
- package/languages/gams.d.ts +2 -0
- package/languages/gauss.d.ts +2 -0
- package/languages/gcode.d.ts +2 -0
- package/languages/gherkin.d.ts +2 -0
- package/languages/glsl.d.ts +2 -0
- package/languages/gml.d.ts +2 -0
- package/languages/go.d.ts +2 -0
- package/languages/golo.d.ts +2 -0
- package/languages/gradle.d.ts +2 -0
- package/languages/graphql.d.ts +2 -0
- package/languages/groovy.d.ts +2 -0
- package/languages/haml.d.ts +2 -0
- package/languages/handlebars.d.ts +2 -0
- package/languages/haskell.d.ts +2 -0
- package/languages/haxe.d.ts +2 -0
- package/languages/hsp.d.ts +2 -0
- package/languages/http.d.ts +2 -0
- package/languages/hy.d.ts +2 -0
- package/languages/index.d.ts +199 -0
- package/languages/inform7.d.ts +2 -0
- package/languages/ini.d.ts +2 -0
- package/languages/irpf90.d.ts +2 -0
- package/languages/isbl.d.ts +2 -0
- package/languages/java.d.ts +2 -0
- package/languages/javascript.d.ts +2 -0
- package/languages/jboss-cli.d.ts +2 -0
- package/languages/json.d.ts +2 -0
- package/languages/julia-repl.d.ts +2 -0
- package/languages/julia.d.ts +2 -0
- package/languages/kotlin.d.ts +2 -0
- package/languages/lasso.d.ts +2 -0
- package/languages/latex.d.ts +2 -0
- package/languages/ldif.d.ts +2 -0
- package/languages/leaf.d.ts +2 -0
- package/languages/less.d.ts +2 -0
- package/languages/lisp.d.ts +2 -0
- package/languages/livecodeserver.d.ts +2 -0
- package/languages/livescript.d.ts +2 -0
- package/languages/llvm.d.ts +2 -0
- package/languages/lsl.d.ts +2 -0
- package/languages/lua.d.ts +2 -0
- package/languages/makefile.d.ts +2 -0
- package/languages/markdown.d.ts +2 -0
- package/languages/mathematica.d.ts +2 -0
- package/languages/matlab.d.ts +2 -0
- package/languages/maxima.d.ts +2 -0
- package/languages/mel.d.ts +2 -0
- package/languages/mercury.d.ts +2 -0
- package/languages/mipsasm.d.ts +2 -0
- package/languages/mizar.d.ts +2 -0
- package/languages/mojolicious.d.ts +2 -0
- package/languages/monkey.d.ts +2 -0
- package/languages/moonscript.d.ts +2 -0
- package/languages/n1ql.d.ts +2 -0
- package/languages/nestedtext.d.ts +2 -0
- package/languages/nginx.d.ts +2 -0
- package/languages/nim.d.ts +2 -0
- package/languages/nix.d.ts +2 -0
- package/languages/node-repl.d.ts +2 -0
- package/languages/nsis.d.ts +2 -0
- package/languages/objectivec.d.ts +2 -0
- package/languages/ocaml.d.ts +2 -0
- package/languages/openscad.d.ts +2 -0
- package/languages/oxygene.d.ts +2 -0
- package/languages/parser3.d.ts +2 -0
- package/languages/perl.d.ts +2 -0
- package/languages/pf.d.ts +2 -0
- package/languages/pgsql.d.ts +2 -0
- package/languages/php-template.d.ts +2 -0
- package/languages/php.d.ts +2 -0
- package/languages/plaintext.d.ts +2 -0
- package/languages/pony.d.ts +2 -0
- package/languages/powershell.d.ts +2 -0
- package/languages/processing.d.ts +2 -0
- package/languages/profile.d.ts +2 -0
- package/languages/prolog.d.ts +2 -0
- package/languages/properties.d.ts +2 -0
- package/languages/protobuf.d.ts +2 -0
- package/languages/puppet.d.ts +2 -0
- package/languages/purebasic.d.ts +2 -0
- package/languages/python-repl.d.ts +2 -0
- package/languages/python.d.ts +2 -0
- package/languages/q.d.ts +2 -0
- package/languages/qml.d.ts +2 -0
- package/languages/r.d.ts +2 -0
- package/languages/reasonml.d.ts +2 -0
- package/languages/rib.d.ts +2 -0
- package/languages/roboconf.d.ts +2 -0
- package/languages/routeros.d.ts +2 -0
- package/languages/rsl.d.ts +2 -0
- package/languages/ruby.d.ts +2 -0
- package/languages/ruleslanguage.d.ts +2 -0
- package/languages/rust.d.ts +2 -0
- package/languages/sas.d.ts +2 -0
- package/languages/scala.d.ts +2 -0
- package/languages/scheme.d.ts +2 -0
- package/languages/scilab.d.ts +2 -0
- package/languages/scss.d.ts +2 -0
- package/languages/shell.d.ts +2 -0
- package/languages/smali.d.ts +2 -0
- package/languages/smalltalk.d.ts +2 -0
- package/languages/sml.d.ts +2 -0
- package/languages/sqf.d.ts +2 -0
- package/languages/sql.d.ts +2 -0
- package/languages/stan.d.ts +2 -0
- package/languages/stata.d.ts +2 -0
- package/languages/step21.d.ts +2 -0
- package/languages/stylus.d.ts +2 -0
- package/languages/subunit.d.ts +2 -0
- package/languages/swift.d.ts +2 -0
- package/languages/taggerscript.d.ts +2 -0
- package/languages/tap.d.ts +2 -0
- package/languages/tcl.d.ts +2 -0
- package/languages/thrift.d.ts +2 -0
- package/languages/tp.d.ts +2 -0
- package/languages/twig.d.ts +2 -0
- package/languages/typescript.d.ts +2 -0
- package/languages/vala.d.ts +2 -0
- package/languages/vbnet.d.ts +2 -0
- package/languages/vbscript-html.d.ts +2 -0
- package/languages/vbscript.d.ts +2 -0
- package/languages/verilog.d.ts +2 -0
- package/languages/vhdl.d.ts +2 -0
- package/languages/vim.d.ts +2 -0
- package/languages/wasm.d.ts +2 -0
- package/languages/wren.d.ts +2 -0
- package/languages/x86asm.d.ts +2 -0
- package/languages/xl.d.ts +2 -0
- package/languages/xml.d.ts +2 -0
- package/languages/xquery.d.ts +2 -0
- package/languages/yaml.d.ts +2 -0
- package/languages/zephir.d.ts +2 -0
- package/package.json +21 -18
- package/styles/3024.d.ts +1 -0
- package/styles/a11y-dark.d.ts +1 -0
- package/styles/a11y-light.d.ts +1 -0
- package/styles/agate.d.ts +1 -0
- package/styles/an-old-hope.d.ts +1 -0
- package/styles/androidstudio.d.ts +1 -0
- package/styles/apathy.d.ts +1 -0
- package/styles/apprentice.d.ts +1 -0
- package/styles/arduino-light.d.ts +1 -0
- package/styles/arta.d.ts +1 -0
- package/styles/ascetic.d.ts +1 -0
- package/styles/ashes.d.ts +1 -0
- package/styles/atelier-cave-light.d.ts +1 -0
- package/styles/atelier-cave.d.ts +1 -0
- package/styles/atelier-dune-light.d.ts +1 -0
- package/styles/atelier-dune.d.ts +1 -0
- package/styles/atelier-estuary-light.d.ts +1 -0
- package/styles/atelier-estuary.d.ts +1 -0
- package/styles/atelier-forest-light.d.ts +1 -0
- package/styles/atelier-forest.d.ts +1 -0
- package/styles/atelier-heath-light.d.ts +1 -0
- package/styles/atelier-heath.d.ts +1 -0
- package/styles/atelier-lakeside-light.d.ts +1 -0
- package/styles/atelier-lakeside.d.ts +1 -0
- package/styles/atelier-plateau-light.d.ts +1 -0
- package/styles/atelier-plateau.d.ts +1 -0
- package/styles/atelier-savanna-light.d.ts +1 -0
- package/styles/atelier-savanna.d.ts +1 -0
- package/styles/atelier-seaside-light.d.ts +1 -0
- package/styles/atelier-seaside.d.ts +1 -0
- package/styles/atelier-sulphurpool-light.d.ts +1 -0
- package/styles/atelier-sulphurpool.d.ts +1 -0
- package/styles/atlas.d.ts +1 -0
- package/styles/atom-one-dark-reasonable.d.ts +1 -0
- package/styles/atom-one-dark.d.ts +1 -0
- package/styles/atom-one-light.d.ts +1 -0
- package/styles/base16-github.d.ts +1 -0
- package/styles/base16-ir-black.d.ts +1 -0
- package/styles/base16-monokai.d.ts +1 -0
- package/styles/base16-nord.d.ts +1 -0
- package/styles/bespin.d.ts +1 -0
- package/styles/black-metal-bathory.d.ts +1 -0
- package/styles/black-metal-burzum.d.ts +1 -0
- package/styles/black-metal-dark-funeral.d.ts +1 -0
- package/styles/black-metal-gorgoroth.d.ts +1 -0
- package/styles/black-metal-immortal.d.ts +1 -0
- package/styles/black-metal-khold.d.ts +1 -0
- package/styles/black-metal-marduk.d.ts +1 -0
- package/styles/black-metal-mayhem.d.ts +1 -0
- package/styles/black-metal-nile.d.ts +1 -0
- package/styles/black-metal-venom.d.ts +1 -0
- package/styles/black-metal.d.ts +1 -0
- package/styles/brewer.d.ts +1 -0
- package/styles/bright.d.ts +1 -0
- package/styles/brogrammer.d.ts +1 -0
- package/styles/brown-paper.d.ts +1 -0
- package/styles/brush-trees-dark.d.ts +1 -0
- package/styles/brush-trees.d.ts +1 -0
- package/styles/chalk.d.ts +1 -0
- package/styles/circus.d.ts +1 -0
- package/styles/classic-dark.d.ts +1 -0
- package/styles/classic-light.d.ts +1 -0
- package/styles/codepen-embed.d.ts +1 -0
- package/styles/codeschool.d.ts +1 -0
- package/styles/color-brewer.d.ts +1 -0
- package/styles/colors.d.ts +1 -0
- package/styles/cupcake.d.ts +1 -0
- package/styles/cupertino.d.ts +1 -0
- package/styles/danqing.d.ts +1 -0
- package/styles/darcula.d.ts +1 -0
- package/styles/dark-violet.d.ts +1 -0
- package/styles/dark.d.ts +1 -0
- package/styles/darkmoss.d.ts +1 -0
- package/styles/darktooth.d.ts +1 -0
- package/styles/decaf.d.ts +1 -0
- package/styles/default-dark.d.ts +1 -0
- package/styles/default-light.d.ts +1 -0
- package/styles/default.d.ts +1 -0
- package/styles/devibeans.d.ts +1 -0
- package/styles/dirtysea.d.ts +1 -0
- package/styles/docco.d.ts +1 -0
- package/styles/dracula.d.ts +1 -0
- package/styles/edge-dark.d.ts +1 -0
- package/styles/edge-light.d.ts +1 -0
- package/styles/eighties.d.ts +1 -0
- package/styles/embers.d.ts +1 -0
- package/styles/equilibrium-dark.d.ts +1 -0
- package/styles/equilibrium-gray-dark.d.ts +1 -0
- package/styles/equilibrium-gray-light.d.ts +1 -0
- package/styles/equilibrium-light.d.ts +1 -0
- package/styles/espresso.d.ts +1 -0
- package/styles/eva-dim.d.ts +1 -0
- package/styles/eva.d.ts +1 -0
- package/styles/far.d.ts +1 -0
- package/styles/felipec.d.ts +1 -0
- package/styles/flat.d.ts +1 -0
- package/styles/foundation.d.ts +1 -0
- package/styles/framer.d.ts +1 -0
- package/styles/fruit-soda.d.ts +1 -0
- package/styles/gigavolt.d.ts +1 -0
- package/styles/github-dark-dimmed.d.ts +1 -0
- package/styles/github-dark.d.ts +1 -0
- package/styles/github.d.ts +1 -0
- package/styles/gml.d.ts +1 -0
- package/styles/google-dark.d.ts +1 -0
- package/styles/google-light.d.ts +1 -0
- package/styles/googlecode.d.ts +1 -0
- package/styles/gradient-dark.d.ts +1 -0
- package/styles/gradient-light.d.ts +1 -0
- package/styles/grayscale-dark.d.ts +1 -0
- package/styles/grayscale-light.d.ts +1 -0
- package/styles/grayscale.d.ts +1 -0
- package/styles/green-screen.d.ts +1 -0
- package/styles/gruvbox-dark-hard.d.ts +1 -0
- package/styles/gruvbox-dark-medium.d.ts +1 -0
- package/styles/gruvbox-dark-pale.d.ts +1 -0
- package/styles/gruvbox-dark-soft.d.ts +1 -0
- package/styles/gruvbox-light-hard.d.ts +1 -0
- package/styles/gruvbox-light-medium.d.ts +1 -0
- package/styles/gruvbox-light-soft.d.ts +1 -0
- package/styles/hardcore.d.ts +1 -0
- package/styles/harmonic16-dark.d.ts +1 -0
- package/styles/harmonic16-light.d.ts +1 -0
- package/styles/heetch-dark.d.ts +1 -0
- package/styles/heetch-light.d.ts +1 -0
- package/styles/helios.d.ts +1 -0
- package/styles/hopscotch.d.ts +1 -0
- package/styles/horizon-dark.d.ts +1 -0
- package/styles/horizon-light.d.ts +1 -0
- package/styles/humanoid-dark.d.ts +1 -0
- package/styles/humanoid-light.d.ts +1 -0
- package/styles/hybrid.d.ts +1 -0
- package/styles/ia-dark.d.ts +1 -0
- package/styles/ia-light.d.ts +1 -0
- package/styles/icy-dark.d.ts +1 -0
- package/styles/idea.d.ts +1 -0
- package/styles/index.d.ts +248 -0
- package/styles/intellij-light.d.ts +1 -0
- package/styles/ir-black.d.ts +1 -0
- package/styles/isbl-editor-dark.d.ts +1 -0
- package/styles/isbl-editor-light.d.ts +1 -0
- package/styles/isotope.d.ts +1 -0
- package/styles/kimber.d.ts +1 -0
- package/styles/kimbie-dark.d.ts +1 -0
- package/styles/kimbie-light.d.ts +1 -0
- package/styles/lightfair.d.ts +1 -0
- package/styles/lioshi.d.ts +1 -0
- package/styles/london-tube.d.ts +1 -0
- package/styles/macintosh.d.ts +1 -0
- package/styles/magula.d.ts +1 -0
- package/styles/marrakesh.d.ts +1 -0
- package/styles/materia.d.ts +1 -0
- package/styles/material-darker.d.ts +1 -0
- package/styles/material-lighter.d.ts +1 -0
- package/styles/material-palenight.d.ts +1 -0
- package/styles/material-vivid.d.ts +1 -0
- package/styles/material.d.ts +1 -0
- package/styles/mellow-purple.d.ts +1 -0
- package/styles/mexico-light.d.ts +1 -0
- package/styles/mocha.d.ts +1 -0
- package/styles/mono-blue.d.ts +1 -0
- package/styles/monokai-sublime.d.ts +1 -0
- package/styles/monokai.d.ts +1 -0
- package/styles/nebula.d.ts +1 -0
- package/styles/night-owl.d.ts +1 -0
- package/styles/nnfx-dark.d.ts +1 -0
- package/styles/nnfx-light.d.ts +1 -0
- package/styles/nord.d.ts +1 -0
- package/styles/nova.d.ts +1 -0
- package/styles/obsidian.d.ts +1 -0
- package/styles/ocean.d.ts +1 -0
- package/styles/oceanicnext.d.ts +1 -0
- package/styles/one-light.d.ts +1 -0
- package/styles/onedark.d.ts +1 -0
- package/styles/outrun-dark.d.ts +1 -0
- package/styles/panda-syntax-dark.d.ts +1 -0
- package/styles/panda-syntax-light.d.ts +1 -0
- package/styles/papercolor-dark.d.ts +1 -0
- package/styles/papercolor-light.d.ts +1 -0
- package/styles/paraiso-dark.d.ts +1 -0
- package/styles/paraiso-light.d.ts +1 -0
- package/styles/paraiso.d.ts +1 -0
- package/styles/pasque.d.ts +1 -0
- package/styles/phd.d.ts +1 -0
- package/styles/pico.d.ts +1 -0
- package/styles/pojoaque.d.ts +1 -0
- package/styles/pop.d.ts +1 -0
- package/styles/porple.d.ts +1 -0
- package/styles/purebasic.d.ts +1 -0
- package/styles/qtcreator-dark.d.ts +1 -0
- package/styles/qtcreator-light.d.ts +1 -0
- package/styles/qualia.d.ts +1 -0
- package/styles/railscasts.d.ts +1 -0
- package/styles/rainbow.d.ts +1 -0
- package/styles/rebecca.d.ts +1 -0
- package/styles/ros-pine-dawn.d.ts +1 -0
- package/styles/ros-pine-moon.d.ts +1 -0
- package/styles/ros-pine.d.ts +1 -0
- package/styles/routeros.d.ts +1 -0
- package/styles/sagelight.d.ts +1 -0
- package/styles/sandcastle.d.ts +1 -0
- package/styles/school-book.d.ts +1 -0
- package/styles/seti-ui.d.ts +1 -0
- package/styles/shades-of-purple.d.ts +1 -0
- package/styles/shapeshifter.d.ts +1 -0
- package/styles/silk-dark.d.ts +1 -0
- package/styles/silk-light.d.ts +1 -0
- package/styles/snazzy.d.ts +1 -0
- package/styles/solar-flare-light.d.ts +1 -0
- package/styles/solar-flare.d.ts +1 -0
- package/styles/solarized-dark.d.ts +1 -0
- package/styles/solarized-light.d.ts +1 -0
- package/styles/spacemacs.d.ts +1 -0
- package/styles/srcery.d.ts +1 -0
- package/styles/stackoverflow-dark.d.ts +1 -0
- package/styles/stackoverflow-light.d.ts +1 -0
- package/styles/summercamp.d.ts +1 -0
- package/styles/summerfruit-dark.d.ts +1 -0
- package/styles/summerfruit-light.d.ts +1 -0
- package/styles/sunburst.d.ts +1 -0
- package/styles/synth-midnight-terminal-dark.d.ts +1 -0
- package/styles/synth-midnight-terminal-light.d.ts +1 -0
- package/styles/tango.d.ts +1 -0
- package/styles/tender.d.ts +1 -0
- package/styles/tokyo-night-dark.d.ts +1 -0
- package/styles/tokyo-night-light.d.ts +1 -0
- package/styles/tomorrow-night-blue.d.ts +1 -0
- package/styles/tomorrow-night-bright.d.ts +1 -0
- package/styles/tomorrow-night.d.ts +1 -0
- package/styles/tomorrow.d.ts +1 -0
- package/styles/twilight.d.ts +1 -0
- package/styles/unikitty-dark.d.ts +1 -0
- package/styles/unikitty-light.d.ts +1 -0
- package/styles/vs.d.ts +1 -0
- package/styles/vs2015.d.ts +1 -0
- package/styles/vulcan.d.ts +1 -0
- package/styles/windows-10-light.d.ts +1 -0
- package/styles/windows-10.d.ts +1 -0
- package/styles/windows-95-light.d.ts +1 -0
- package/styles/windows-95.d.ts +1 -0
- package/styles/windows-high-contrast-light.d.ts +1 -0
- package/styles/windows-high-contrast.d.ts +1 -0
- package/styles/windows-nt-light.d.ts +1 -0
- package/styles/windows-nt.d.ts +1 -0
- package/styles/woodland.d.ts +1 -0
- package/styles/xcode-dusk.d.ts +1 -0
- package/styles/xcode.d.ts +1 -0
- package/styles/xt256.d.ts +1 -0
- package/styles/zenburn.d.ts +1 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
> Syntax highlighting for Svelte using [highlight.js](https://github.com/highlightjs/highlight.js).
|
|
7
7
|
|
|
8
|
-
Try it in
|
|
8
|
+
Try it in [StackBlitz](https://stackblitz.com/edit/svelte-highlight?file=src%2Froutes%2Findex.svelte).
|
|
9
9
|
|
|
10
10
|
## [Documentation](https://svhe.onrender.com)
|
|
11
11
|
|
|
@@ -22,28 +22,33 @@ npm i -D svelte-highlight
|
|
|
22
22
|
pnpm i -D svelte-highlight highlight.js
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Note that [pnpm](https://github.com/pnpm/pnpm) users must also install `highlight.js
|
|
25
|
+
Note that [pnpm](https://github.com/pnpm/pnpm) users must also install `highlight.js`.
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## Basic Usage
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The `Highlight` component requires two props:
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
- `code`: text to highlight
|
|
32
|
+
- `language`: language grammar used to highlight the text
|
|
33
|
+
|
|
34
|
+
Import languages from `svelte-highlight/languages`.
|
|
35
|
+
|
|
36
|
+
See [SUPPORTED_LANGUAGES.md](SUPPORTED_LANGUAGES.md) for a list of supported languages.
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script>
|
|
40
|
+
import Highlight from "svelte-highlight";
|
|
41
|
+
import typescript from "svelte-highlight/languages/typescript";
|
|
42
|
+
|
|
43
|
+
const code = "const add = (a: number, b: number) => a + b;";
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<Highlight language={typescript} {code} />
|
|
42
47
|
```
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
## Styling
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
Import styles from `svelte-highlight/styles`. See [SUPPORTED_STYLES.md](SUPPORTED_STYLES.md) for a list of supported styles.
|
|
47
52
|
|
|
48
53
|
There are two ways to apply `highlight.js` styles.
|
|
49
54
|
|
|
@@ -72,7 +77,7 @@ This component exports `highlight.js` themes in JavaScript. Import the theme fro
|
|
|
72
77
|
|
|
73
78
|
### CSS StyleSheet
|
|
74
79
|
|
|
75
|
-
Depending on your set-up, importing a CSS StyleSheet in Svelte may require a CSS file loader.
|
|
80
|
+
Depending on your set-up, importing a CSS StyleSheet in Svelte may require a CSS file loader. SvelteKit/Vite automatically supports this. For Webpack, refer to [examples/webpack](examples/webpack).
|
|
76
81
|
|
|
77
82
|
```svelte
|
|
78
83
|
<script>
|
|
@@ -86,6 +91,38 @@ Depending on your set-up, importing a CSS StyleSheet in Svelte may require a CSS
|
|
|
86
91
|
<Highlight language={typescript} {code} />
|
|
87
92
|
```
|
|
88
93
|
|
|
94
|
+
#### Linking from a CDN
|
|
95
|
+
|
|
96
|
+
CSS StyleSheets can also be externally linked from a Content Delivery Network (CDN) like [unpkg.com](https://unpkg.com/).
|
|
97
|
+
|
|
98
|
+
> **Warning**
|
|
99
|
+
> Using a CDN is best suited for prototyping and not recommended for production use.
|
|
100
|
+
|
|
101
|
+
**HTML**
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<!DOCTYPE html>
|
|
105
|
+
<html lang="en">
|
|
106
|
+
<head>
|
|
107
|
+
<link
|
|
108
|
+
rel="stylesheet"
|
|
109
|
+
href="https://unpkg.com/svelte-highlight/styles/github.css"
|
|
110
|
+
/>
|
|
111
|
+
</head>
|
|
112
|
+
</html>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**svelte:head**
|
|
116
|
+
|
|
117
|
+
```svelte
|
|
118
|
+
<svelte:head>
|
|
119
|
+
<link
|
|
120
|
+
rel="stylesheet"
|
|
121
|
+
href="https://unpkg.com/svelte-highlight/styles/github.css"
|
|
122
|
+
/>
|
|
123
|
+
</svelte:head>
|
|
124
|
+
```
|
|
125
|
+
|
|
89
126
|
## Svelte Syntax Highlighting
|
|
90
127
|
|
|
91
128
|
Use the `HighlightSvelte` component for Svelte syntax highlighting.
|
|
@@ -95,7 +132,7 @@ Use the `HighlightSvelte` component for Svelte syntax highlighting.
|
|
|
95
132
|
import { HighlightSvelte } from "svelte-highlight";
|
|
96
133
|
import github from "svelte-highlight/styles/github";
|
|
97
134
|
|
|
98
|
-
|
|
135
|
+
const code = `<button on:click={() => { console.log(0); }}>Increment {count}</button>`;
|
|
99
136
|
</script>
|
|
100
137
|
|
|
101
138
|
<svelte:head>
|
|
@@ -109,16 +146,15 @@ Use the `HighlightSvelte` component for Svelte syntax highlighting.
|
|
|
109
146
|
|
|
110
147
|
The `HighlightAuto` component uses [highlightAuto](https://highlightjs.readthedocs.io/en/latest/api.html#highlightauto) API.
|
|
111
148
|
|
|
112
|
-
**
|
|
113
|
-
|
|
114
|
-
Prefer to specify a language if possible.
|
|
149
|
+
> **Warning**
|
|
150
|
+
> Auto-highlighting will result in a larger bundle size. Specify a language if possible.
|
|
115
151
|
|
|
116
152
|
```svelte
|
|
117
153
|
<script>
|
|
118
154
|
import { HighlightAuto } from "svelte-highlight";
|
|
119
155
|
import github from "svelte-highlight/styles/github";
|
|
120
156
|
|
|
121
|
-
|
|
157
|
+
const code = `body {\n padding: 0;\n color: red;\n}`;
|
|
122
158
|
</script>
|
|
123
159
|
|
|
124
160
|
<svelte:head>
|
|
@@ -128,11 +164,78 @@ Prefer to specify a language if possible.
|
|
|
128
164
|
<HighlightAuto {code} />
|
|
129
165
|
```
|
|
130
166
|
|
|
167
|
+
## Line Numbers
|
|
168
|
+
|
|
169
|
+
Use the `LineNumbers` component to render the highlighted code with line numbers.
|
|
170
|
+
|
|
171
|
+
```svelte
|
|
172
|
+
<script>
|
|
173
|
+
import Hightlight, { LineNumbers } from "svelte-highlight";
|
|
174
|
+
import typescript from "svelte-highlight/languages/typescript";
|
|
175
|
+
import atomOneDark from "svelte-highlight/styles/atom-one-dark";
|
|
176
|
+
|
|
177
|
+
const code = "const add = (a: number, b: number) => a + b";
|
|
178
|
+
</script>
|
|
179
|
+
|
|
180
|
+
<svelte:head>
|
|
181
|
+
{@html atomOneDark}
|
|
182
|
+
</svelte:head>
|
|
183
|
+
|
|
184
|
+
<Highlight language={typescript} {code} let:highlighted>
|
|
185
|
+
<LineNumbers {highlighted} />
|
|
186
|
+
</Highlight>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Hidden Border
|
|
190
|
+
|
|
191
|
+
Set `hideBorder` to `true` to hide the border of the line numbers column.
|
|
192
|
+
|
|
193
|
+
```svelte
|
|
194
|
+
<Highlight language={typescript} {code} let:highlighted>
|
|
195
|
+
<LineNumbers {highlighted} hideBorder />
|
|
196
|
+
</Highlight>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Wrapped Lines
|
|
200
|
+
|
|
201
|
+
By default, overflowing horizontal content is contained by a scrollbar.
|
|
202
|
+
|
|
203
|
+
Set `wrapLines` to `true` to hide the border of the line numbers column.
|
|
204
|
+
|
|
205
|
+
```svelte
|
|
206
|
+
<Highlight language={typescript} {code} let:highlighted>
|
|
207
|
+
<LineNumbers {highlighted} wrapLines />
|
|
208
|
+
</Highlight>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Custom Styles
|
|
212
|
+
|
|
213
|
+
Use `--style-props` to customize styles.
|
|
214
|
+
|
|
215
|
+
| Style prop | Description | Default value |
|
|
216
|
+
| :------------------ | :----------------------------------------- | :------------- |
|
|
217
|
+
| --line-number-color | Text color of the line numbers | `currentColor` |
|
|
218
|
+
| --border-color | Border color of the column of line numbers | `currentColor` |
|
|
219
|
+
| --padding-left | Left padding for `td` elements | `1em` |
|
|
220
|
+
| --padding-right | Rightt padding for `td` elements | `1em` |
|
|
221
|
+
|
|
222
|
+
```svelte
|
|
223
|
+
<Highlight language={typescript} {code} let:highlighted>
|
|
224
|
+
<LineNumbers
|
|
225
|
+
{highlighted}
|
|
226
|
+
--line-number-color="pink"
|
|
227
|
+
--border-color="rgba(255, 255, 255, 0.2)"
|
|
228
|
+
--padding-left="0"
|
|
229
|
+
--padding-right="3em"
|
|
230
|
+
/>
|
|
231
|
+
</Highlight>
|
|
232
|
+
```
|
|
233
|
+
|
|
131
234
|
## Language Targeting
|
|
132
235
|
|
|
133
236
|
All `Highlight` components apply a `data-language` attribute on the codeblock containing the language name.
|
|
134
237
|
|
|
135
|
-
See
|
|
238
|
+
See [SUPPORTED_LANGUAGES.md](SUPPORTED_LANGUAGES.md) for a list of supported languages.
|
|
136
239
|
|
|
137
240
|
```css
|
|
138
241
|
[data-language="css"] {
|
|
@@ -142,19 +245,17 @@ See the [Languages page](SUPPORTED_LANGUAGES.md) for a list of supported languag
|
|
|
142
245
|
|
|
143
246
|
## Language Tags
|
|
144
247
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
The language tag can be given a custom `background` , `color` , and `border-radius` through CSS custom properties.
|
|
248
|
+
Set `langtag` to `true` to display the language name in the top right corner of the code block.
|
|
148
249
|
|
|
149
|
-
|
|
250
|
+
Customize the language tag `background`, `color`, and `border-radius` using style props.
|
|
150
251
|
|
|
151
252
|
See the [Languages page](SUPPORTED_LANGUAGES.md) for a list of supported languages.
|
|
152
253
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
254
|
+
| Style prop | Description | Default value |
|
|
255
|
+
| :---------------------- | :------------------------------ | :------------ |
|
|
256
|
+
| --langtag-background | Background color of the langtag | `inherit` |
|
|
257
|
+
| --langtag-color | Text color of the langtag | `inherit` |
|
|
258
|
+
| --langtag-border-radius | Border radius of the langtag | `0` |
|
|
158
259
|
|
|
159
260
|
```svelte
|
|
160
261
|
<script>
|
|
@@ -168,9 +269,9 @@ Defaults:
|
|
|
168
269
|
|
|
169
270
|
```css
|
|
170
271
|
[data-language="css"] {
|
|
171
|
-
--
|
|
172
|
-
--
|
|
173
|
-
--
|
|
272
|
+
--langtag-background: linear-gradient(135deg, #2996cf, 80%, white);
|
|
273
|
+
--langtag-color: #fff;
|
|
274
|
+
--langtag-border-radius: 8px;
|
|
174
275
|
}
|
|
175
276
|
```
|
|
176
277
|
|
|
@@ -199,37 +300,143 @@ Refer to the highlight.js [language definition guide](https://highlightjs.readth
|
|
|
199
300
|
<Highlight {language} code="..." />
|
|
200
301
|
```
|
|
201
302
|
|
|
202
|
-
##
|
|
303
|
+
## Code-splitting
|
|
203
304
|
|
|
204
|
-
|
|
305
|
+
You can use the `await import` syntax for code-splitting.
|
|
205
306
|
|
|
206
|
-
|
|
207
|
-
| :---------------------------------------------- | :--------------------------------------------- | :--------------------------------------- |
|
|
208
|
-
| code | `any` | `undefined` |
|
|
209
|
-
| language (only required for `Highlight.svelte`) | { name: `string`; register: hljs => `object` } | { name: undefined, register: undefined } |
|
|
210
|
-
| langtag | `boolean` | `false` |
|
|
307
|
+
In the example below, the `HighlightAuto` component and injected styles are dynamically loaded.
|
|
211
308
|
|
|
212
|
-
|
|
309
|
+
```svelte
|
|
310
|
+
<script>
|
|
311
|
+
import { onMount } from "svelte";
|
|
312
|
+
|
|
313
|
+
let component;
|
|
314
|
+
let styles;
|
|
213
315
|
|
|
214
|
-
|
|
316
|
+
onMount(async () => {
|
|
317
|
+
component = (await import("svelte-highlight")).HighlightAuto;
|
|
318
|
+
styles = (await import("svelte-highlight/styles/github")).default;
|
|
319
|
+
});
|
|
320
|
+
</script>
|
|
215
321
|
|
|
216
|
-
|
|
322
|
+
<svelte:head>
|
|
323
|
+
{#if styles}
|
|
324
|
+
{@html styles}
|
|
325
|
+
{/if}
|
|
326
|
+
</svelte:head>
|
|
327
|
+
|
|
328
|
+
<svelte:component
|
|
329
|
+
this={component}
|
|
330
|
+
langtag
|
|
331
|
+
code={`body {\n padding: 0;\n color: red;\n}`}
|
|
332
|
+
/>
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Component API
|
|
336
|
+
|
|
337
|
+
### `Highlight`
|
|
338
|
+
|
|
339
|
+
#### Props
|
|
340
|
+
|
|
341
|
+
| Name | Type | Default value |
|
|
342
|
+
| :------- | :--------------------------------------------- | :------------- |
|
|
343
|
+
| code | `any` | N/A (required) |
|
|
344
|
+
| language | { name: `string`; register: hljs => `object` } | N/A (required) |
|
|
345
|
+
| langtag | `boolean` | `false` |
|
|
346
|
+
|
|
347
|
+
`$$restProps` are forwarded to the top-level `pre` element.
|
|
348
|
+
|
|
349
|
+
#### Dispatched Events
|
|
350
|
+
|
|
351
|
+
- **on:highlight**: fired after `code` is highlighted
|
|
217
352
|
|
|
218
353
|
```svelte
|
|
219
354
|
<Highlight
|
|
220
355
|
language={typescript}
|
|
221
356
|
{code}
|
|
222
357
|
on:highlight={(e) => {
|
|
223
|
-
|
|
358
|
+
/**
|
|
359
|
+
* The highlighted HTML as a string.
|
|
360
|
+
* @example "<span>...</span>"
|
|
361
|
+
*/
|
|
362
|
+
console.log(e.detail.highlighted);
|
|
363
|
+
}}
|
|
364
|
+
/>
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### `LineNumbers`
|
|
368
|
+
|
|
369
|
+
#### Props
|
|
370
|
+
|
|
371
|
+
| Name | Type | Default value |
|
|
372
|
+
| :---------- | :-------- | :------------- |
|
|
373
|
+
| highlighted | `string` | N/A (required) |
|
|
374
|
+
| hideBorder | `boolean` | `false` |
|
|
375
|
+
| wrapLines | `boolean` | `false` |
|
|
376
|
+
|
|
377
|
+
`$$restProps` are forwarded to the top-level `div` element.
|
|
378
|
+
|
|
379
|
+
### `HighlightSvelte`
|
|
380
|
+
|
|
381
|
+
#### Props
|
|
382
|
+
|
|
383
|
+
| Name | Type | Default value |
|
|
384
|
+
| :------ | :-------- | :------------- |
|
|
385
|
+
| code | `any` | N/A (required) |
|
|
386
|
+
| langtag | `boolean` | `false` |
|
|
387
|
+
|
|
388
|
+
`$$restProps` are forwarded to the top-level `pre` element.
|
|
389
|
+
|
|
390
|
+
#### Dispatched Events
|
|
391
|
+
|
|
392
|
+
- **on:highlight**: fired after `code` is highlighted
|
|
393
|
+
|
|
394
|
+
```svelte
|
|
395
|
+
<HighlightSvelte
|
|
396
|
+
{code}
|
|
397
|
+
on:highlight={(e) => {
|
|
398
|
+
/**
|
|
399
|
+
* The highlighted HTML as a string.
|
|
400
|
+
* @example "<span>...</span>"
|
|
401
|
+
*/
|
|
402
|
+
console.log(e.detail.highlighted);
|
|
224
403
|
}}
|
|
225
404
|
/>
|
|
226
405
|
```
|
|
227
406
|
|
|
228
|
-
|
|
407
|
+
### `HighlightAuto`
|
|
408
|
+
|
|
409
|
+
#### Props
|
|
410
|
+
|
|
411
|
+
| Name | Type | Default value |
|
|
412
|
+
| :------ | :-------- | :------------- |
|
|
413
|
+
| code | `any` | N/A (required) |
|
|
414
|
+
| langtag | `boolean` | `false` |
|
|
415
|
+
|
|
416
|
+
`$$restProps` are forwarded to the top-level `pre` element.
|
|
417
|
+
|
|
418
|
+
#### Dispatched Events
|
|
229
419
|
|
|
230
|
-
|
|
420
|
+
- **on:highlight**: fired after `code` is highlighted
|
|
231
421
|
|
|
232
|
-
|
|
422
|
+
```svelte
|
|
423
|
+
<HighlightAuto
|
|
424
|
+
{code}
|
|
425
|
+
on:highlight={(e) => {
|
|
426
|
+
/**
|
|
427
|
+
* The highlighted HTML as a string.
|
|
428
|
+
* @example "<span>...</span>"
|
|
429
|
+
*/
|
|
430
|
+
console.log(e.detail.highlighted);
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The inferred language name
|
|
434
|
+
* @example "css"
|
|
435
|
+
*/
|
|
436
|
+
console.log(e.detail.language);
|
|
437
|
+
}}
|
|
438
|
+
/>
|
|
439
|
+
```
|
|
233
440
|
|
|
234
441
|
## [Supported Languages](SUPPORTED_LANGUAGES.md)
|
|
235
442
|
|
|
@@ -238,8 +445,6 @@ TypeScript definitions are auto-generated by SvelteKit.
|
|
|
238
445
|
## Examples
|
|
239
446
|
|
|
240
447
|
- [examples/rollup](examples/rollup)
|
|
241
|
-
- [examples/rollup-typescript](examples/rollup-typescript)
|
|
242
|
-
- [examples/snowpack](examples/snowpack)
|
|
243
448
|
- [examples/sveltekit](examples/sveltekit)
|
|
244
449
|
- [examples/vite](examples/vite)
|
|
245
450
|
- [examples/webpack](examples/webpack)
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as default } from "./Highlight.svelte";
|
|
2
|
-
export { default as Highlight } from "./Highlight.svelte";
|
|
1
|
+
export { default as default, default as Highlight } from "./Highlight.svelte";
|
|
3
2
|
export { default as HighlightAuto } from "./HighlightAuto.svelte";
|
|
4
3
|
export { default as HighlightSvelte } from "./HighlightSvelte.svelte";
|
|
4
|
+
export { default as LineNumbers } from "./LineNumbers.svelte";
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as default } from "./Highlight.svelte";
|
|
2
|
-
export { default as Highlight } from "./Highlight.svelte";
|
|
1
|
+
export { default as default, default as Highlight } from "./Highlight.svelte";
|
|
3
2
|
export { default as HighlightAuto } from "./HighlightAuto.svelte";
|
|
4
3
|
export { default as HighlightSvelte } from "./HighlightSvelte.svelte";
|
|
4
|
+
export { default as LineNumbers } from "./LineNumbers.svelte";
|
package/languages/c.d.ts
ADDED
package/languages/d.d.ts
ADDED