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

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