highlight

pub

Dart Syntax highlighting library.

If you are looking for Flutter widget, see flutter_highlight.

Usage

import 'package:highlight/highlight.dart' show highlight;

main() {
  var source = '''main() {
  print("Hello, World!");
}
''';

  var result = highlight.parse(source, language: 'dart');
  var html = result.toHtml();
  print(html); // HTML string
}

Notice that all available languages are registered in the way above. For those desiring more control over what exactly they need, import highlight_core.dart instead and register languages manually:

import 'package:highlight/highlight_core.dart' show highlight;
import 'package:highlight/languages/dart.dart';

main() {
  var source = '''main() {
  print("Hello, World!");
}
''';

  highlight.registerLanguage('dart', dart);

  var result = highlight.parse(source, language: 'dart');
  var html = result.toHtml();
  print(html); // HTML string
}

References

License

MIT

Libraries

1c
abnf
accesslog
actionscript
ada
all
angelscript
apache
applescript
arcade
arduino
armasm
asciidoc
aspectj
autohotkey
autoit
avrasm
awk
axapta
bash
basic
bnf
brainfuck
cal
capnproto
ceylon
clean
clojure
clojure-repl
cmake
coffeescript
coq
cos
cpp
crmsh
crystal
cs
csp
css
d
dart
delphi
diff
django
dns
dockerfile
dos
dsconfig
dts
dust
ebnf
elixir
elm
erb
erlang
erlang-repl
excel
fix
flix
fortran
fsharp
gams
gauss
gcode
gherkin
glsl
gml
gn
go
golo
gradle
graphql
groovy
haml
handlebars
haskell
haxe
highlight
highlight_core
hsp
htmlbars
http
hy
inform7
ini
irpf90
isbl
java
javascript
jboss-cli
json
julia
julia-repl
kotlin
lasso
ldif
leaf
less
lisp
livecodeserver
livescript
llvm
lsl
lua
makefile
markdown
mathematica
matlab
maxima
mel
mercury
mipsasm
mizar
mojolicious
monkey
moonscript
n1ql
nginx
nimrod
nix
nsis
objectivec
ocaml
openscad
oxygene
parser3
perl
pf
pgsql
php
plaintext
pony
powershell
processing
profile
prolog
properties
protobuf
puppet
purebasic
python
q
qml
r
reasonml
rib
roboconf
routeros
rsl
ruby
ruleslanguage
rust
sas
scala
scheme
scilab
scss
shell
smali
smalltalk
sml
solidity
sqf
sql
stan
stata
step21
stylus
subunit
swift
taggerscript
tap
tcl
tex
thrift
tp
twig
typescript
vala
vbnet
vbscript
vbscript-html
verilog
vhdl
vim
vue
x86asm
xl
xml
xquery
yaml
zephir