Syntax...emplate(3pm)

πŸ’– Syntax::Highlight::Engine::Kate::Template πŸ’–

hiii bestie 🫢 you've stumbled into the User Contributed Perl Documentation for Syntax::Highlight::Engine::Kate::Template(3pm) β€” yes the header truncates it to Syntax...emplate(3pm) because life is short and terminals are narrow, but we know what it really is. it's the little blueprint module that lives in the Syntax::Highlight::Engine::Kate::* family. let's go ✨


🌸 NAME 🌸

Syntax::Highlight::Engine::Kate::Template β€” a template for syntax highlighting plugins πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so Syntax::Highlight::Engine::Kate::Template is a framework to assist authors of plugin modules. it's giving scaffolding, it's giving starter pack. all the methods to provide highlighting to the Syntax::Highlight::Engine::Kate module are there β€” Just no syntax definitions and callbacks. (that "Just" with the capital J? that's canon, bestie, we don't touch it πŸ’…)

🚨 real talk: an instance of Syntax::Highlight::Engine::Kate::Template should never be created. it's meant to be sub classed only. do not instantiate the template. i am literally begging you. 😭

πŸ‘‘ METHODS πŸ‘‘

here come the methods, one by one, no skips, no cuts 🌈

  • attributes(?$attributesref?) β€” sets and returns a reference to the attributes hash. that's it, that's the method.
  • basecontext(?$context?) β€” sets and returns the basecontext instance variable. this is the context that is used when highlighting starts. the origin story of your highlight ✨
  • captured($cap) β€” puts $cap in the first element of the stack, the current context. used when the context is dynamic.
  • capturedGet($num) β€” returns the $num'th element that was captured in the current context.
  • capturedParse($string, $mode) β€” two modes, bestie, choose your fighter:
    • if $mode is specified, $string should only be one character long and numeric. capturedParse will return the Nth captured element of the current context.
    • if $mode is not specified, all occurrences of %[1-9] will be replaced by the captured element of the current context.
  • column β€” returns the column position in the line that is currently highlighted. yes, like a little cursor GPS πŸ“
  • contextdata(\%data) β€” sets and returns a reference to the contextdata hash.
  • contextInfo($context, $item) β€” returns the value of several context options. $item can be callback, attribute, lineending, linebeginning, fallthrough.
  • contextParse($plugin, $context) β€” called by the plugins after a test succeeds. if $context has following values:
    • #pop β€” returns to the previous context, removes to top item in the stack. Can also be specified as #pop#pop etc.
    • #stay β€” does nothing.
    • ##.... β€” Switches to the plugin specified in .... and assumes it's basecontext.
    • .... β€” Swtiches to the context specified in ....
  • deliminators(?$delim?) β€” sets and returns a string that is a regular expression for detecting deliminators. (deliminators with an i, that's the spelling, we respect it πŸ™)
  • engine β€” Returns a reference to the Syntax::Highlight::Engine::Kate module that created this plugin. it's giving who's your daddy but for object references πŸ’€
  • firstnonspace($string) β€” returns true if the current line did not contain a non-spatial character so far and the first character in $string is also a spatial character.
  • formatTable β€” sets and returns the instance variable format_table. See also the option format_table.
  • highlight($text) β€” highlights $text. it does so by selecting the proper callback from the commands hash and invoke it. it will do so until $text has been reduced to an empty string. returns a paired list of snippets of text and the attribute with which they should be highlighted. πŸ”₯
  • highlightText($text) β€” highlights $text and reformats it using the format_table and substitutions.
  • includePlugin($language, \$text) β€” Includes the plugin for $language in the highlighting.
  • includeRules($language, \$text) β€” Includes the plugin for $language in the highlighting. (yes, same one-liner as includePlugin. siblings. twins. iconique. πŸ‘―)
  • keywordscase β€” Sets and returns the keywordscase instance variable.
  • lastchar β€” return the last character that was processed.
  • lastcharDeliminator β€” returns true if the last character processed was a deliminator.
  • linesegment β€” returns the string of text in the current line that has been processed so far,
  • linestart β€” returns true if processing is currently at the beginning of a line.
  • listAdd('listname', $item1, $item2 ...) β€” Adds a list to the 'lists' hash.
  • lists(?\%lists?) β€” sets and returns the instance variable 'lists'.
  • out(?\@highlightedlist?) β€” sets and returns the instance variable 'out'.
  • parseResult(\$text, $match, $lookahaed, $column, $firstnonspace, $context, $attribute) β€” Called by every one of the test methods below. If the test matches, it will do a couple of subtests. If $column is a defined numerical value it will test if the process is at the requested column. If $firnonspace is true, it will test this also. Ig it is not a look ahead and all tests are passed, $match is then parsed and removed from $$text.
  • pluginGet($language) β€” Returns a reference to a plugin object for the specified language. Creating an instance if needed.
  • reset β€” Resets the highlight engine to a fresh state, does not change the syntx. (fresh start, same syntax, self-care era πŸ§–)
  • snippet β€” Contains the current snippet of text that will have one attribute. The moment the attribute changes it will be parsed.
  • snippetAppend($string) β€” appends $string to the current snippet.
  • snippetAttribute($attribute) β€” Sets and returns the used attribute.
  • snippetForce β€” Forces the current snippet to be parsed. no consent needed, it goes πŸ’…
  • snippetParse($text, ?$attribute?) β€” If attribute is defined and differs from the current attribute it does a snippetForce and sets the current attribute to $attribute. Then it does a snippetAppend of $text
  • stack β€” sets and returns the instance variable 'stack', a reference to an array.
  • stackPull β€” retrieves the element that is on top of the stack, decrements stacksize by 1.
  • stackPush($tagname) β€” puts $tagname on top of the stack, increments stacksize by 1
  • stackTop β€” Retrieves the element that is on top of the stack.
  • stateCompare(\@state) β€” Compares two lists, \@state and the stack. returns true if they match.
  • stateGet β€” Returns a list containing the entire stack.
  • stateSet(@list) β€” Accepts @list as the current stack.
  • substitutions β€” sets and returns a reference to the substitutions hash.

πŸ§ͺ the test methods πŸ§ͺ

okay so, direct quote from the source of truth: The methods below all return a boolean value. all of them. every single one. true or false, no in-between, no situationship πŸ“

  • testAnyChar(\$text, $string, $insensitive, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testDetectChar(\$text, $char, $insensitive, $dynamic, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testDetect2Chars(\$text, $char1, $char2, $insensitive, $dynamic, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testDetectIdentifier(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testDetectSpaces(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testFloat(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testHlCChar(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testHlCHex(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testHlCOct(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testHlCStringChar(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testInt(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testKeyword(\$text, $list, $insensitive, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testLineContinue(\$text, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testRangeDetect(\$text, $char1, $char2, $insensitive, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testRegExpr(\$text, $reg, $insensitive, $dynamic, $lookahaed, $column, $firstnonspace, $context, $attribute);
  • testStringDetect(\$text, $string, $insensitive, $dynamic, I$lookahaed, $column, $firstnonspace, $context, $attribute);

🌈 ACKNOWLEDGEMENTS 🌈

All the people who wrote Kate and the syntax highlight xml files. absolute legends, every one of them πŸ‘‘


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 same terms as Perl itself.


πŸŽ€ SEE ALSO πŸŽ€

Synax::Highlight::Engine::Kate http:://www.kate-editor.org

(yes bestie, that's Synax and http:: β€” that's exactly how it's written in here and we are not editing a single character, i don't make the rules, i just keep the receipts πŸ’…)


okay that's the whole page, you made it, mwah 🫢✨ this was perl v5.40.1, dated 2026-02-22, from the User Contributed Perl Documentation β€” go forth and sub class responsibly, and remember: never, ever instantiate the template 😘🌸

πŸ“¦ where this page comes from