highlighting
Code syntax highlighting library for over 190 languages.
If you are looking for the Flutter widget, see flutter_highlighting.
This package is a port of HighlightJS project into Dart. It is periodically updated from the original JavaScript version with an automated script.
Usage
import 'package:highlighting/highlighting.dart';
import 'package:highlighting/languages/dart.dart';
void main() {
final source = '''main() {
print('Highlighting by Akvelon.');
}
''';
highlight.registerLanguage(dart);
final highlighted = highlight.parse(source, languageId: dart.id);
final html = highlighted.toHtml();
print(html); // HTML string
}
Versions and Migration
The package uses its own version numbering in addition to that of HighlightJS.
For example, the version 0.9.0+11.8.0
means that it is:
- Version
0.9.0
of the Dart package itself, and it contains breaking changes over the version0.8.x
. - Ported from HighlightJS version
11.8.0
.
This allows the pub
tool to automatically guard you against breaking changes.
Migration guides:
Maintainer's Guide
- Maintainer's Guide on how the automatic porting works.
- How we Ported HighlightJS to Dart on Medium.
References
Libraries
- highlighting
- 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/c
- 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/csharp
- 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/go
- languages/golo
- languages/gradle
- languages/graphql
- languages/groovy
- languages/haml
- languages/handlebars
- languages/haskell
- languages/haxe
- languages/hsp
- 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/latex
- 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/nestedtext
- languages/nginx
- languages/nim
- languages/nix
- languages/node-repl
- languages/nsis
- languages/objectivec
- languages/ocaml
- languages/openscad
- languages/oxygene
- languages/parser3
- languages/perl
- languages/pf
- languages/pgsql
- languages/php
- languages/php-template
- languages/plaintext
- languages/pony
- languages/powershell
- languages/processing
- languages/profile
- languages/prolog
- languages/properties
- languages/protobuf
- languages/puppet
- languages/purebasic
- languages/python
- languages/python-repl
- 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/sqf
- languages/sql
- languages/stan
- languages/stata
- languages/step21
- languages/stylus
- languages/subunit
- languages/swift
- languages/taggerscript
- languages/tap
- languages/tcl
- languages/thrift
- languages/tp
- languages/twig
- languages/typescript
- languages/vala
- languages/vbnet
- languages/vbscript
- languages/vbscript-html
- languages/verilog
- languages/vhdl
- languages/vim
- languages/wasm
- languages/wren
- languages/x86asm
- languages/xl
- languages/xml
- languages/xquery
- languages/yaml
- languages/zephir