Syntax...e::Kate(3pm)
π Syntax::Highlight::Engine::Kate β bestie edition π
okay so this is Syntax::Highlight::Engine::Kate(3pm), a Perl module from the User Contributed Perl Documentation, and it's literally a port to Perl of the syntax highlight engine from the Kate text editor. it's giving "I took Kate's whole vibe and made it Perl". no cap. β¨
β¨ NAME β¨
Syntax::Highlight::Engine::Kate β a port to Perl of the syntax highlight engine of the Kate text editor. that's it, that's the name, periodt. π
πΈ SYNOPSIS πΈ
like, here's how you'd actually use her:
#if you want to create a compiled executable, you may want to do this:
use Syntax::Highlight::Engine::Kate::All;
use Syntax::Highlight::Engine::Kate;
my $hl = Syntax::Highlight::Engine::Kate->new(
language => 'Perl',
substitutions => {
"<" => "<",
">" => ">",
"&" => "&",
" " => " ",
"\t" => " ",
"\n" => "<BR>\n",
},
format_table => {
Alert => [ "<font color=\"#0000ff\">", "</font>" ],
BaseN => [ "<font color=\"#007f00\">", "</font>" ],
BString => [ "<font color=\"#c9a7ff\">", "</font>" ],
Char => [ "<font color=\"#ff00ff\">", "</font>" ],
Comment => [ "<font color=\"#7f7f7f\"><i>", "</i></font>" ],
DataType => [ "<font color=\"#0000ff\">", "</font>" ],
DecVal => [ "<font color=\"#00007f\">", "</font>" ],
Error => [ "<font color=\"#ff0000\"><b><i>", "</i></b></font>" ],
Float => [ "<font color=\"#00007f\">", "</font>" ],
Function => [ "<font color=\"#007f00\">", "</font>" ],
IString => [ "<font color=\"#ff0000\">", "" ],
Keyword => [ "<b>", "</b>" ],
Normal => [ "", "" ],
Operator => [ "<font color=\"#ffa500\">", "</font>" ],
Others => [ "<font color=\"#b03060\">", "</font>" ],
RegionMarker => [ "<font color=\"#96b9ff\"><i>", "</i></font>" ],
Reserved => [ "<font color=\"#9b30ff\"><b>", "</b></font>" ],
String => [ "<font color=\"#ff0000\">", "</font>" ],
Variable => [ "<font color=\"#0000ff\"><b>", "</b></font>" ],
Warning => [ "<font color=\"#0000ff\"><b><i>", "</b></i></font>" ],
},
);
#or
my $hl = Syntax::Highlight::Engine::Kate::Perl->new(
substitutions => {
# ...
},
format_table => {
# ...
},
);
print "<html>\n<head>\n</head>\n<body>\n";
while ( my $in = <> ) {
print $hl->highlightText($in);
}
print "</body>\n</html>\n";
so yeah, two ways to flex: one big generic object with a language key, or the per-language subclass route (::Perl in the example). both devour STDIN line by line and spit out highlighted output. iconic. π¦
π DESCRIPTION π
okay bestie, deep breath. π
This module is now deprecated.
likeβ¦ she's retired. she's living her best life on a beach somewhere. she's been superseded and replaced by Syntax::Kamelon. for new projects, bestie, use Syntax::Kamelon. that's the move. no cap. π
for the historical record tho: Syntax::Highlight::Engine::Kate is a port to Perl of the syntax highlight engine of the Kate text editor.
the language XML files of Kate have been rewritten to Perl modules using a script. these modules function as plugins to this module.
and yes, Syntax::Highlight::Engine::Kate inherits Syntax::Highlight::Engine::Kate::Template. family tree moment. π
π OPTIONS π
these are the options you can pass in when you build your object, one by one, no skipping:
languageβ specify the language you want highlighted. look in the PLUGINS section for supported languages. (yes, go look, she's not listing them all here.)pluginsβ if you created your own language plugins, you may specify a list of them with this option.
plugins => [
["MyModuleName", "MyLanguageName", "*,ext1;*.ext2", "Section"],
....
]
format_tableβ you must specify this option if you want thehighlightTextmethod to do anything useful for you. like, genuinely must. every single key mentioned in the synopsis has to be specified. all of them. the whole roster. don't be shy with it. πsubstitutionsβ with this option you can specify additional formatting options.
π«Ά METHODS π«Ά
the full menu of things you can call on her:
extensionsβ returns a reference to the extensions hash.language(?$language?)β sets and returns the current language that is highlighted. when setting the language a reset is also done. so it's a set-and-return situation, and setting it wipes the slate. two jobs, one method, main character energy.languageAutoSet($filename)β suggests language name for the given file$filename.languageListβ returns a list of languages for which plugins have been defined.languagePlug($language, ?$insensitive?)β returns the module name of the plugin for$language.
if $insensitive is set it will also try to match names ignoring case and return the correct module name of the plugin.
e.g. "$highlighter->languagePlug('HtMl', 1);" will return "HTML". lowercase bestie gets recognised, slay. π
languagePropose($filename)β suggests language name for the given file$filename.sectionsβ returns a reference to the sections hash.
π ATTRIBUTES π
okay so here's the lore. in the Kate XML syntax files you find under the section <itemDatas> entries like "<itemData name="Unknown Property" defStyleNum="dsError" italic="1"/>". Kate is an editor, so it's ok to have definitions for foreground and background colors and so on. however β and this is the important part, bestie β since this module is supposed to be a more universal highlight engine, the attributes need to be fully abstract. in which case, Kate does not have enough default attributes defined to fulfill all needs. π
Kate defines the following standard attributes:
dsNormaldsKeyworddsDataTypedsDecValdsBaseNdsFloatdsChardsStringdsCommentdsOthersdsAlertdsFunctiondsRegionMarkerdsError
this module leaves out the <ds> part and uses following additional attributes:
BStringIStringOperatorReservedVariable
and then, quote unquote: "I have modified the XML files so that each highlight mode would get its own attribute. In quite a few cases still not enough attributes were defined. So in some languages different modes have the same attribute."
so yeah. some modes are sharing an attribute because there simply weren't enough to go around. it's a group chat and there aren't enough nicknames. it happens. π
π PLUGINS π
ok bestie sit down for this one because it's a whole roster. here's the rundown of every plugin that exists. all of them have been tested in actual use and can be created β but the ones with no sample file to their name are marked as such, okay? and the ones marked OK? those highlighted the test file without any apparent mistakes. which is not the same as saying all bugs are shaken out, bestie, do not come for me π
the columns are LANGUAGE, MODULE and COMMENT:
.desktopβDesktopβ OK β¨4GLβFourGLβ No sample file4GL-PERβFourGLminusPERβ No sample fileABCβABCβ OKAHDLβAHDLβ OKANSI C89βANSI_C89β No sample fileASPβASPβ OKAVR AssemblerβAVR_Assemblerβ OKAWKβAWKβ OKAdaβAdaβ No sample fileAlertsβAlertsβ OK, hidden module πAnsysβAnsysβ No sample fileApache ConfigurationβApache_Configurationβ No sample fileAsm6502βAsm6502β No sample fileBashβBashβ OKBibTeXβBibTeXβ OKCβCβ No sample fileC#βCdashβ No sample fileC++βCplusplusβ OKCGiSβCGiSβ No sample fileCMakeβCMakeβ OKCSSβCSSβ OKCUE SheetβCUE_Sheetβ No sample fileCgβCgβ No sample fileChangeLogβChangeLogβ No sample fileCiscoβCiscoβ No sample fileClipperβClipperβ OKColdFusionβColdFusionβ No sample fileCommon LispβCommon_Lispβ OKComponent-PascalβComponentminusPascalβ No sample fileDβDβ No sample fileDebian ChangelogβDebian_Changelogβ No sample fileDebian ControlβDebian_Controlβ No sample fileDiffβDiffβ No sample fileDoxygenβDoxygenβ OKE LanguageβE_Languageβ OKEiffelβEiffelβ No sample fileEmailβEmailβ OKEuphoriaβEuphoriaβ OKFortranβFortranβ OKFreeBASICβFreeBASICβ No sample fileGDLβGDLβ No sample fileGLSLβGLSLβ OKGNU AssemblerβGNU_Assemblerβ No sample fileGNU GettextβGNU_Gettextβ No sample fileHTMLβHTMLβ OKHaskellβHaskellβ OKIDLβIDLβ No sample fileILERPGβILERPGβ No sample fileINI FilesβINI_Filesβ No sample fileInformβInformβ No sample fileIntel x86 (NASM)βIntel_X86_NASMβ seems to have issues πJSPβJSPβ OKJavaβJavaβ OKJavaScriptβJavaScriptβ OKJavadocβJavadocβ No sample fileKBasicβKBasicβ No sample fileKate File TemplateβKate_File_Templateβ No sample fileLDIFβLDIFβ No sample fileLPCβLPCβ No sample fileLaTeXβLaTexβ OKLex/FlexβLex_Flexβ OKLilyPondβLilyPondβ OKLiterate HaskellβLiterate_Haskellβ OKLuaβLuaβ No sample fileM3UβM3Uβ OKMAB-DBβMABminusDBβ No sample fileMIPS AssemblerβMIPS_Assemblerβ No sample fileMakefileβMakefileβ No sample fileMasonβMasonβ No sample fileMatlabβMatlabβ has issues πModula-2βModulaminus2β No sample fileMusic PublisherβMusic_Publisherβ No sample fileOctaveβOctaveβ OKPHP (HTML)βPHP_HTMLβ OKPHP_PHPβPHP_PHPβ OK, hidden module πPOV-RayβPOV_Rayβ OKPascalβPascalβ No sample filePerlβPerlβ OK (obviously, it's literally us π )PicAsmβPicAsmβ OKPikeβPikeβ OKPostScriptβPostScriptβ OKPrologβPrologβ No sample filePureBasicβPureBasicβ OKPythonβPythonβ OKQuake ScriptβQuake_Scriptβ No sample fileR ScriptβR_Scriptβ No sample fileREXXβREXXβ No sample fileRPM SpecβRPM_Specβ No sample fileRSI IDLβRSI_IDLβ No sample fileRenderMan RIBβRenderMan_RIBβ OKRubyβRubyβ OKSGMLβSGMLβ No sample fileSMLβSMLβ No sample fileSQLβSQLβ No sample fileSQL (MySQL)βSQL_MySQLβ No sample fileSQL (PostgreSQL)βSQL_PostgreSQLβ No sample fileSatherβSatherβ No sample fileSchemeβSchemeβ OKSieveβSieveβ No sample fileSpiceβSpiceβ OKStataβStataβ OKTI BasicβTI_Basicβ No sample fileTaskJugglerβTaskJugglerβ No sample fileTcl/TkβTCL_Tkβ OKUnrealScriptβUnrealScriptβ OKVHDLβVHDLβ No sample fileVRMLβVRMLβ OKVelocityβVelocityβ No sample fileVerilogβVerilogβ No sample fileWINE ConfigβWINE_Configβ No sample fileWikimediaβWikimediaβ No sample fileXMLβXMLβ OKXML (Debug)βXML_Debugβ No sample fileYacc/BisonβYacc_Bisonβ OKde_DEβDe_DEβ No sample fileen_ENβEn_ENβ No sample fileferiteβFeriteβ No sample filenlβNlβ No sample fileprogressβProgressβ No sample filescilabβScilabβ No sample filetxt2tagsβTxt2tagsβ No sample filex.org ConfigurationβX_org_Configurationβ OKxHarbourβXHarbourβ OKxsltβXsltβ No sample fileyacasβYacasβ No sample file
andddd one more thing π«Ά β the module Syntax::Highlight::Engine::Kate::Convert::ToolKit plus the script hl-kate-convert can be used to convert an existing Kate/KTextEditor Syntax Highlighting file from XML format to Perl. slay.
π BUGS π
ngl bestie, here's where it gets a lil spicy:
Floatis detected differently than in the Kate editor. deadass. it just is.- the regular expression engine of the Kate editor,
qregexp, appears to be more tolerant to mistakes in regular expressions than Perl. which meansβ¦ error messages. and differences in behaviour. most of the problems were sorted out while developing, because error messages appeared. but as far as differences in behaviour goes? testing is literally the only way to find out, so I hope the users out there will be able to tell me more π - this module is mimicking the behaviour of the syntax highlight engine of the Kate editor. so if you find a bug/mistake in the highlighting, please check if Kate behaves in the same way. if yes, the cause is likely to be found there. not my problem, that's Kate's problem π
β¨ TO DO β¨
the vision board, bestie:
- rebuild the scripts I am using to generate the modules from XML files, so they are more pro-actively tracking flaws in the build of the XML files β like missing lists, y'know? also, regular expressions in the XML can be tested better before they are used in plugins.
- refine the test methods in
Syntax::Highlight::Engine::Kate::Template, so that choices for case sensitivity, dynamic behaviour and lookahead can be determined at generate time of the plugin. might increase throughput π - implement code folding.
π«Ά ACKNOWLEDGEMENTS π«Ά
all the people who wrote Kate and the syntax highlight XML files. every single one. absolute icons, every last one of them πΈ
π AUTHOR AND COPYRIGHT π
this module is written and maintained by:
Hans Jeuken < haje at toneel dot demon dot nl >
Copyright (c) 2006 by Hans Jeuken, all rights reserved.
you may freely distribute and/or modify this module under the same terms as Perl itself. that's the good stuff β¨
π SEE ALSO π
Syntax::Highlight::Engine::Kate::Template- <http://www.kate-editor.org>
- KTextEditor Syntax Highlighting Repository <https://quickgit.kde.org/?p=ktexteditor.git&a=tree&f=src%2Fsyntax%2Fdata>
and that's a wrap on the whole page, bestie!! π this was perl v5.40.1, dated 2026-02-22, and honestly? she ate. go highlight something cute. mwah ππ
π¦ where this page comes from
- ubuntu resolute: libsyntax-highlight-engine-kate-perl 0.16+dfsg-1ubuntu1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsyntax-highlight-engine-kate-perl 0.16+dfsg-1ubuntu1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms