YetaWF.SyntaxHighlighter Package
Overview
This package implements syntax highlighting in modules.
Formats <pre> .. </pre> sections automatically using either highlight.js or Alex Gorbatchev's Syntax Highlighter.
Syntax Highlighter Settings Module
This is the main configuration module for syntax highlighting. It is accessible using Admin > Configuration > Syntax Highlighter Settings (). It is used to define the appearance of sections using syntax highlighting.
Syntax Highlighter Highlight.js (Skin) Module
This module can be referenced by sites, pages or modules, in which case <pre> .. </pre> sections are formatted using highlight.js. This module, implemented by class YetaWF.Modules.SyntaxHighlighter.Modules.SkinHighlightJSModule, has a published ModuleGuid("25068AC6-BA74-4644-8B46-9D7FEC291E45").
The appearance of the <pre> .. </pre> sections using syntax highlighting can be defined using Syntax Highlighter Settings accessible using Admin > Configuration > Syntax Highlighter Settings (), Highlight.js tab.
Syntax highlighting can be configured on each <pre> or <code> Html tag. Additional information about configuring syntax highlighting can found at https://highlightjs.org/.
The following languages are currently available (language names are available at http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases):
Language | Language Names (Css Class) |
---|
Apache | apache, apacheconf |
Bash | bash, sh, zsh |
C# | cs, csharp |
C++ | cpp, c, cc, h, c++, h++, hpp |
CSS | css |
CoffeeScript | coffeescript, coffee, cson, iced |
Diff | diff, patch |
HTML, XML | xml, html, xhtml, rss, atom, xjb, xsd, xsl, plist |
HTTP | http, https |
Ini | ini |
JSON | json |
Java | java, jsp |
JavaScript | javascript, js, jsx |
Makefile | makefile, mk, mak |
Markdown | markdown, md, mkdown, mkd |
Nginx | nginx, nginxconf |
Objective-C | objectivec, mm, objc, obj-c |
PHP | php, php3, php4, php5, php6 |
Perl | perl, pl, pm |
Python | python, py, gyp |
Ruby | ruby, rb, gemspec, podspec, thor, irb |
SQL | sql |
Shell Session | shell, console |
Highlight.js uses the defined Css class to determine the language (using one of the language names, optionally prefixed by language- or lang-). The language name can be omitted, in which case highlight.js will detect the language automatically. The Css class "lang-nohighlight" can be used to turn off highlighting so highlight.js doesn't automatically determine the language.
Example
<pre class="language-js">
function somejavascript() {
var x = 20;
x += 10;
return x;
}
</pre>
function somejavascript() {
var x = 20;
x += 10;
return x;
}
Adding/Removing Languages
It is possible to add and remove languages by downloading a custom version of highlight.js at https://highlightjs.org/download/. Select/deselect all desired languages and download. Extract highlight.pack.js from the downloaded Zip file and place it into the folder shown below (which may need to be created).
Replace domain.com with the name of the domain. Each site within one YetaWF instance can have its own set of languages and is not shared.
ASP.NET Core
.\Website\wwwroot\AddonsCustom\domain.com\YetaWF\SyntaxHighlighter\_Addons\SkinHighlightJS
ASP.NET 4
.\Website\AddonsCustom\domain.com\YetaWF\SyntaxHighlighter\_Addons\SkinHighlightJS
Syntax Highlighter Alex Gorbatchev (Skin) Module
This module can be referenced by sites, pages or modules, in which case <pre> .. </pre> sections are formatted using Alex Gorbatchev's Syntax Highlighter. This module, implemented by class YetaWF.Modules.SyntaxHighlighter.Modules.SyntaxHighlighterModule, has a published ModuleGuid("7e3c4322-5bdb-44bf-acff-f62d498705ee").
The appearance of the <pre> .. </pre> sections using syntax highlighting can be defined using Syntax Highlighter Settings accessible using Admin > Configuration >Syntax Highlighter Settings (), Alex Gorbatchev tab.
Syntax highlighting can be configured on each <pre> Html tag. Additional information about configuring syntax highlighting can found at http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/).
The following brushes are currently available:
Language | Brush (Css Class) |
---|
C++ | cpp |
C# | csharp |
Css | css |
Javascript | jscript, js |
Sql | sql |
Visual Basic | vb |
Xml | xml |
Example
<pre class="brush:js">
function somejavascript() {
var x = 20;
x += 10;
return x;
}
</pre>
function somejavascript() {
var x = 20;
x += 10;
return x;
}
License
The YetaWF.Syntax Highlighter package is part of YetaWF, an open source product licensed under the GNU General Public License, version 3 (GPL-3.0) - Copyright - Softel vdm, Inc.