Syntax highlighting for more than 100 programming languages

codehighlighter:highlight(STRING code
, STRING language: "")

# it is best to explicitly give the language name to highlight
codehighlighter:highlight('<b>hi there</b>')
#=> "<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">b</span>&gt;</span>hi there<span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">b</span>&gt;</span>"

# it tries to guess the language (small number of languages are tried)
codehighlighter:highlight("select 3 as total")
#=> "<span class=\"hljs-keyword\">select</span> <span class=\"hljs-number\">3</span> <span class=\"hljs-keyword\">as</span> total"

# if given language is not valid it does not highlight
codehighlighter:highlight("x = 3", "same lang")
#=> "x = 3"

codehighlighter:highlight("{", "php")
#=> "{"

Copyright ©2013-2022 SunSed®. All rights reserved.