Please click here for an English version of this article.
Seit diesem Wochenende ist meine erste TYPO3 Extension im TER verfügbar: beautyOfCode Syntax Highlighter
Diese Extension nutzt das jQuery Plugin beautyOfCode von Lars Corneliussen um das mittlerweile recht bekannte Syntax Highlighter 2.0 von Alex Gorbatchev zu implementieren. Bekannt deshalb weil es von einigen Größen eingesetzt wird: wordpress.com, Aptana, Mozilla Developer Center, SitePoint und das Yahoo Developer Network gehören dazu.
Der Quellcode wird XHTML 1.0 Strict kompatibel auf der Webseite eingebettet und per Java-Script gehighlighted. Die RegEx Anweisungen und die Stylesheets die für die verschiedenen Sprachen werden per lazy-loading nachgeladen.
Es gibt einige nette Features wie Zeilenumbruch, Zeilen einfärben, Code einklappen, Tabulator Länge bestimmen und eine Toolbar, aber seht am besten selbst:
function main($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
// parse XML data into php array
$this->pi_initPIflexForm();
return $content;
}
Beispiel PHP Code
Dabei sind verschiedene Programmiersprachen (zur Zeit werden Actionscript 3, Bash, Shell, ColdFusion", C, C++, C#, CSS, Delphi, Pas, Pascal, Diff, Patch, Erlang, Groovy, Java, Java FX, Java-Script, Perl, PHP, Power-Shell, Python, Ruby on Rails, Scala, SQL, Typoscript, MySQL, Virtual Basic, .Net, XML, XSLT, XHTML und HTML mitgeliefert.) und visuelle Hervorhebungen (sogenannte Themes) verfügbar. Einige weitere Feauteres (Tabulator-Größe, Zeilenumbruch, Toolbar, etc.) können konfiguriert werden.
Typoscript war bisher nicht verfügbar, dieser sogenannte Brush wurde von mir erstellt -- Feedback ist willkommen. Er basiert auf den Keywords einer UserLanguage Typoscript für Notepad++.
<INCLUDE_TYPOSCRIPT: source="FILE: fileadmin/templates/typoscript/file.ts">
# Kommentar einzeilig
config {
xmlprologue = xml_11
xhtmlDoctype = xhtml_strict
xhtml_cleaning = all
// Reihenfolge von Doctype und XML-Prolog beim Internet Explorer tauschen
[browser = msie]
config.doctypeSwitch = 1
[else]
config.doctypeSwitch = 0
[end]
page = PAGE
plugin.tx_templavoila_pi1.disableExplosivePreview = 1
page.25 < plugin.tx_templavoila_pi1
page.25.userFunc = tx_templavoila_pi1->main_page
Beispiel Typoscript Code
Für Verbesserungsvorschläge bin ich jederzeit offen. Die Extension ist im Ter noch nicht in der aktuellsten Version verfügbar, kann aber weiter unten heruntergeladen werden. Dort findet sich auch der Typoscript Brush für SyntaxHighlighter 2.0.
beautyOfCode Syntax Highlighter (which is my first extension release into the TER) provides state-of-the-art syntax highlighting by using Java-Script. The jQuery plugin beautyOfCodbye Lars Corneliussen is used to implement Syntax Highlighter 2.0 by Alex Gorbatchev.
RegEx files (so called brushes) and the CSS sytles (so called themes) are lazy-loaded (after the page has finished loading) Java-Script file.
The following features are included: show gutter, customizable tab size, configurable label, collapse code, wrap lines, a toolbar ( with print in FE view, copy to directly to clipboard (via swf) and copy manually out of an pop-up).
The following programming languages are available Actionscript 3, Bash, Shell, ColdFusion", C, C++, C#, CSS, Delphi, Pas, Pascal, Diff, Patch, Erlang, Groovy, Java, Java FX, Java-Script, Perl, PHP, Power-Shell, Python, Ruby on Rails, Scala, SQL, Typoscript, MySQL, Virtual Basic, .Net, XML, XSLT, XHTML and HTML.
As the Typoscript brush did not exist for Syntax Highlighter 2.0, i created one myself (based upon UserLanguage Typoscript for Notepad++). As the current version isnt avaiable in the Ter yet, you can download both (the extension and the brush) below.
beautyofcode im TYPO3 Extension Ter
This is a TYPO3 Typoscript brush for Syntax Highlighter 2.0 by Alex Gorbatchev, a Java-Script sourcecode highlighter.
Version 0.1.3 of my TYPO3 extension beautyOfCode Syntax Highlighter
Manual for my TYPO3 extension beautyOfCode Syntax Highlighter.
RSS: Blog | Kommentare | Was ist RSS?
Kommentar schreiben