[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Updated Template-Toolkit Syntax Files
From:       Sean Kellogg <skellogg () u ! washington ! edu>
Date:       2006-10-05 18:22:20
Message-ID: 200610051122.20236.skellogg () u ! washington ! edu
[Download RAW message or body]

Hello -

I wrote a few days ago with my initial try at writing TT syntax files.  Turns 
out there were some glaring errors :(  I took a peak at the php files and 
learned a few tricks which helped me solve most of the serious outstanding 
bugs with the file I sent you.

Here is the new version which are split into two files (like the php files 
are).

Also, if someone could please let me know if this is the best way of sending 
updates or if there is a more effective way?  I'm not subscribed to the devel 
list, but am happy to do so if that's "the thing to do."

Thanks,
Sean

-- 
Sean Kellogg
c: 831.818.6940    e: skellogg@u.washington.edu
w: http://blog.probonogeek.org/

So, let go
 ...Jump in
  ...Oh well, what you waiting for?
   ...it's all right
    ...'Cause there's beauty in the breakdown

["html-tmpl.xml" (text/xml)]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
[
	<!ENTITY name    "[A-Za-z_:][\w.:_-]*">
	<!ENTITY entref  "&amp;(#[0-9]+|#[xX][0-9A-Fa-f]+|&name;);">
]>

<!--
	Copyright (C) 2006 Sean Kellogg <skellogg@u.washington.edu>
			
	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Library General Public
	License version 2 as published by the Free Software Foundation.
	
	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Library General Public License for more details.
	
	You should have received a copy of the GNU Library General Public License
	along with this library; see the file COPYING.LIB.  If not, write to
	the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
	Boston, MA 02110-1301, USA.
	
	*** NOTICE ***
	This file is based on the html-php template file maintained by Wilbert Berendsen \
(wilbert@kde.nl)  
	*** TODO ***
	
	* Write Javascript and CSS rules which do not rely on PHP rules...  although, the \
PHP  rules seem to be working just fine

	*** CHANGELOG ***
	
	[1.00]
	* Initial Release of 1.0.0 (10/05/06)
	* Discovered the html-php approach to breaking up html detection from TT detection
	* Fixes TT detection while inside an HTML tag
	
-->

<language name="Template-Toolkit (HTML)" version="1.00" kateversion="2.4" \
section="Markup" extensions="*.tmpl;*.TT;*.tt" mimetype="text/tmpl"  author="Sean \
Kellogg (skellogg@u.washington.edu)" license="LGPL" priority="10">

<highlighting>
<contexts>
	<context name="Start" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<IncludeRules context="FindHTML" />
	</context>

	<context name="FindHTML" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectSpaces/>
		<DetectIdentifier/>
		<StringDetect attribute="Comment" context="Comment" String="&lt;!--" \
beginRegion="comment" />  <StringDetect attribute="CDATA" context="CDATA" \
String="&lt;![CDATA[" beginRegion="cdata" />  <RegExpr attribute="Doctype" \
context="Doctype" String="&lt;!DOCTYPE\s+" beginRegion="doctype" />  <RegExpr \
attribute="Processing Instruction" context="PI" String="&lt;\?[\w:-]*" \
beginRegion="pi" />  <RegExpr attribute="Element" context="CSS" String="&lt;style\b" \
insensitive="TRUE" beginRegion="style" />  <RegExpr attribute="Element" context="JS" \
String="&lt;script\b" insensitive="TRUE" beginRegion="script" />  <RegExpr \
attribute="Element" context="El Open" String="&lt;pre\b" insensitive="TRUE" \
beginRegion="pre" />  <RegExpr attribute="Element" context="El Open" \
String="&lt;div\b" insensitive="TRUE" beginRegion="div" />  <RegExpr \
attribute="Element" context="El Open" String="&lt;table\b" insensitive="TRUE" \
beginRegion="table" />  <RegExpr attribute="Element" context="El Open" \
String="&lt;&name;" />  <RegExpr attribute="Element" context="El Close" \
String="&lt;/pre\b" insensitive="TRUE" endRegion="pre" />  <RegExpr \
attribute="Element" context="El Close" String="&lt;/div\b" insensitive="TRUE" \
endRegion="div" />  <RegExpr attribute="Element" context="El Close" \
String="&lt;/table\b" insensitive="TRUE" endRegion="table" />  <RegExpr \
attribute="Element" context="El Close" String="&lt;/&name;" />  <!-- as long as kde \
gives DTDs the text/html mimetype--><IncludeRules context="FindDTDRules" />  \
<IncludeRules context="FindEntityRefs" />  </context>

	<context name="FindEntityRefs" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="EntityRef" context="#stay" String="&entref;" />
		<AnyChar attribute="Error" context="#stay" String="&amp;&lt;" />
	</context>

	<context name="FindPEntityRefs" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="EntityRef" context="#stay" String="&entref;" />
		<RegExpr attribute="PEntityRef" context="#stay" String="%&name;;" />
		<AnyChar attribute="Error" context="#stay" String="&amp;%" />
	</context>

	<context name="FindAttributes" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="Attribute" context="#stay" String="&name;" column="0"/>
		<RegExpr attribute="Attribute" context="#stay" String="\s+&name;" />
		<DetectChar attribute="Attribute" context="Value" char="=" />
	</context>

	<context name="FindDTDRules" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="Doctype" context="Doctype Markupdecl" \
String="&lt;!(ELEMENT|ENTITY|ATTLIST|NOTATION)\b" />  </context>

	<context name="Comment" attribute="Comment" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectSpaces/>
		<IncludeRules context="##Alerts" />
		<DetectIdentifier/>
		<StringDetect attribute="Comment" context="#pop" String="--&gt;" \
endRegion="comment" />  <RegExpr attribute="Error" context="#stay" \
String="-(-(?!-&gt;))+" />  </context>
	
	<context name="CDATA" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectSpaces/>
		<DetectIdentifier/>
		<StringDetect attribute="CDATA" context="#pop" String="]]&gt;" endRegion="cdata" />
		<StringDetect attribute="EntityRef" context="#stay" String="]]&amp;gt;" />
	</context>
	
	<context name="PI" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<Detect2Chars attribute="Processing Instruction" context="#pop" char="?" \
char1="&gt;" endRegion="pi" />  </context>
	
	<context name="Doctype" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Doctype" context="#pop" char="&gt;" endRegion="doctype" />
		<DetectChar attribute="Doctype" context="Doctype Internal Subset" char="[" \
beginRegion="int_subset" />  </context>

	<context name="Doctype Internal Subset" attribute="Normal Text" \
lineEndContext="#stay">  <IncludeRules context="FindTT" />
		<DetectChar attribute="Doctype" context="#pop" char="]" endRegion="int_subset" />
		<IncludeRules context="FindDTDRules" />
		<StringDetect attribute="Comment" context="Comment" String="&lt;!--" \
beginRegion="comment" />  <RegExpr attribute="Processing Instruction" context="PI" \
String="&lt;\?[\w:-]*" beginRegion="pi" />  <IncludeRules context="FindPEntityRefs" \
/>  </context>
	
	<context name="Doctype Markupdecl" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Doctype" context="#pop" char="&gt;" />
		<DetectChar attribute="Value" context="Doctype Markupdecl DQ" char="&quot;" />
		<DetectChar attribute="Value" context="Doctype Markupdecl SQ" char="&apos;" />
	</context>
	
	<context name="Doctype Markupdecl DQ" attribute="Value" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Value" context="#pop" char="&quot;" />
		<IncludeRules context="FindPEntityRefs" />
	</context>

	<context name="Doctype Markupdecl SQ" attribute="Value" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Value" context="#pop" char="&apos;" />
		<IncludeRules context="FindPEntityRefs" />
	</context>
	
	<context name="El Open" attribute="Normal Text" lineEndContext="#stay">
<!-- 		<IncludeRules context="FindTT" /> -->
		<Detect2Chars attribute="Element" context="#pop" char="/" char1="&gt;" />
		<DetectChar attribute="Element" context="#pop" char="&gt;" />
		<IncludeRules context="FindAttributes" />
		<RegExpr attribute="Error" context="#stay" String="\S" />
	</context>

	<context name="El Close" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Element" context="#pop" char="&gt;" />
		<RegExpr attribute="Error" context="#stay" String="\S" />
	</context>

	<context name="El Close 2" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Element" context="#pop#pop#pop" char="&gt;" />
		<RegExpr attribute="Error" context="#stay" String="\S" />
	</context>

	<context name="El Close 3" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Element" context="#pop#pop#pop#pop" char="&gt;" />
		<RegExpr attribute="Error" context="#stay" String="\S" />
	</context>

	<context name="CSS" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<Detect2Chars attribute="Element" context="#pop" char="/" char1="&gt;" \
endRegion="style" />  <DetectChar attribute="Element" context="CSS content" \
char="&gt;" />  <IncludeRules context="FindAttributes" />
		<RegExpr attribute="Error" context="#stay" String="\S" />
	</context>

	<context name="CSS content" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="Element" context="El Close 2" String="&lt;/style\b" \
insensitive="TRUE" endRegion="style" />  <IncludeRules context="##CSS/PHP" \
includeAttrib="true"/>  </context>

	<context name="JS" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<Detect2Chars attribute="Element" context="#pop" char="/" char1="&gt;" \
endRegion="script" />  <DetectChar attribute="Element" context="JS content" \
char="&gt;" />  <IncludeRules context="FindAttributes" />
		<RegExpr attribute="Error" context="#stay" String="\S" />
	</context>

	<context name="JS content" attribute="Normal Text" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="Element" context="El Close 2" String="&lt;/script\b" \
insensitive="TRUE" endRegion="script" />  <RegExpr attribute="Comment" context="JS \
comment close" String="//(?=.*&lt;/script\b)" insensitive="TRUE" />  <IncludeRules \
context="##JavaScript/PHP" includeAttrib="true"/>  </context>

	<context name="JS comment close" attribute="Comment" lineEndContext="#pop">
		<IncludeRules context="FindTT" />
		<RegExpr attribute="Element" context="El Close 3" String="&lt;/script\b" \
insensitive="TRUE" endRegion="script" />  <IncludeRules context="##Alerts" />
	</context>

	<context name="Value" attribute="Normal Text" lineEndContext="#stay" \
fallthrough="true" fallthroughContext="Value NQ">  <IncludeRules context="FindTT" />
		<DetectChar attribute="Value" context="Value DQ" char="&quot;" />
		<DetectChar attribute="Value" context="Value SQ" char="&apos;" />
		<DetectSpaces />
	</context>

	<context name="Value NQ" attribute="Normal Text" lineEndContext="#pop#pop" \
fallthrough="true" fallthroughContext="#pop#pop">  <IncludeRules context="FindTT" />
		<IncludeRules context="FindEntityRefs" />
		<RegExpr attribute="Value" context="#stay" String="/(?!&gt;)" />
		<RegExpr attribute="Value" context="#stay" String="[^/&gt;&lt;&quot;&apos;\s]" />
	</context>

	<context name="Value DQ" attribute="Value" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Value" context="#pop#pop" char="&quot;" />
		<IncludeRules context="FindEntityRefs" />
	</context>

	<context name="Value SQ" attribute="Value" lineEndContext="#stay">
		<IncludeRules context="FindTT" />
		<DetectChar attribute="Value" context="#pop#pop" char="&apos;" />
		<IncludeRules context="FindEntityRefs" />
	</context>

	<context name="FindTT">
		<StringDetect context="##Template-Toolkit" String="[%" lookAhead="true" />
	</context>
</contexts>

<itemDatas>
  <itemData name="Normal Text" defStyleNum="dsNormal" />
  <itemData name="Comment" defStyleNum="dsComment" />
  <itemData name="CDATA" defStyleNum="dsBaseN" bold="1" />
  <itemData name="Processing Instruction" defStyleNum="dsKeyword" />
  <itemData name="Doctype" defStyleNum="dsDataType" bold="1" />
  <itemData name="Element" defStyleNum="dsKeyword" />
  <itemData name="Attribute" defStyleNum="dsOthers" />
  <itemData name="Value" defStyleNum="dsString" color="#a00" />
  <itemData name="EntityRef" defStyleNum="dsDecVal" />
  <itemData name="PEntityRef" defStyleNum="dsDecVal" />
  <itemData name="Error" defStyleNum="dsError" />
</itemDatas>

</highlighting>
<general>
  <comments>
    <comment name="multiLine" start="&lt;!--" end="--&gt;" />
  </comments>
</general>
</language>


<!-- ***** THIS FILE WAS GENERATED BY A SCRIPT - DO NOT EDIT ***** -->


["tmpl.xml" (text/xml)]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
	Copyright (C) 2006 Sean Kellogg <skellogg@u.washington.edu>
		
	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Library General Public
	License version 2 as published by the Free Software Foundation.
	
	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Library General Public License for more details.
	
	You should have received a copy of the GNU Library General Public License
	along with this library; see the file COPYING.LIB.  If not, write to
	the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
	Boston, MA 02110-1301, USA.
	
	*** NOTICE ***
	This file is based on the perl template file maintained by Anders Lund \
<anders@alweb.dk>  This file was then modified based on the php template file \
maintained by UNKNOWN

	*** TODO ***
	
	* Introduce variable handling into template directives
	* Include directives and filters which are included with the default TT software
	* Implement proper region marking for [% FOO %] ... [% END %] style directives
	* Implement proper vmethod syntax while inside interpolated strings
	* Recognize difference between functions and data
	
	*** CHANGELOG ***
	
	[1.02]
	* Incorporated tips learned from the php and html-php highlighting schemes \
                (10/05/06)
	* Commented out variable detection within interpolated strings as it can cause Kate \
                to lockup  (10/05/06)
	* Marked as 'hidden' to be replicate html-php style scheme  (10/05/06)
	
	[1.01]
	* Fixed comments instruction to actually work (10/01/06)
	
	[1.00]
	* Initial Release of 1.0.0 (10/01/06)
	
-->

	<language name="Template-Toolkit" version="1.1.0" kateversion="2.4" section="Markup" \
author="Sean Kellogg (skellogg@u.washington.edu)" license="LGPL" extensions="" \
priority="5" mimetype="" hidden="true">  
	<highlighting>
		<list name="TTdirectives">
			<item> BLOCK </item>
			<item> CALL </item>
			<item> CASE </item>
			<item> CATCH </item>
			<item> CLEAR </item>
			<item> DEBUG </item>
			<item> DEFAULT </item>
			<item> ELSE </item>
			<item> ELSIF </item>
			<item> END </item>
			<item> FILTER </item>
			<item> FINAL </item>
			<item> FOREACH </item>
			<item> GET </item>
			<item> IF </item>
			<item> IN </item>
			<item> INCLUDE </item>
			<item> INSERT </item>
			<item> LAST </item>
			<item> MACRO </item>
			<item> META </item>
			<item> NEXT </item>
			<item> PERL </item>
			<item> PROCESS </item>
			<item> RAWPERL </item>
			<item> RETURN </item>
			<item> SET </item>
			<item> STOP </item>
			<item> SWITCH </item>
			<item> TAGS </item>
			<item> THROW </item>
			<item> TRY </item>
			<item> UNLESS </item>
			<item> USE </item>
			<item> WHILE </item>
			<item> WRAPPER </item>
		</list>
		<list name="TTvmethods">
			<!-- scalar virtual functions -->
			<item>chunk</item>
			<item>defined</item>
			<item>hash</item>
			<item>length</item>
			<item>list</item>
			<item>match</item>
			<item>repeat</item>
			<item>replace</item>
			<item>search</item>
			<item>size</item>
			<item>split</item>
			<!-- hash virtual functions -->
			<item>each</item>
			<item>exists</item>
			<item>import</item>
			<item>item</item>
			<item>keys</item>
			<item>list</item>
			<item>nsort</item>
			<item>sort</item>
			<item>value</item>
			<!-- list virtual functions -->
			<item>first</item>
			<item>grep</item>
			<item>grep</item>
			<item>join</item>
			<item>last</item>
			<item>max</item>
			<item>merge</item>
			<item>pop</item>
			<item>push</item>
			<item>reverse</item>
			<item>shift</item>
			<item>size</item>
			<item>slice</item>
			<item>splice</item>
			<item>unique</item>
			<item>unshift</item>
		</list>
		<list name="TToperators">
			<item> = </item>
			<item> == </item>
			<item> != </item>
			<item> &lt; </item>
			<item> &gt; </item>
			<item> =&lt; </item>
			<item> =&gt; </item>
			<item> _ </item>
		</list>
		
		<contexts>
			<context name="Start" attribute="Normal Text" lineEndContext="#stay">
				<StringDetect attribute="TT Markup" context="TTsource" String="[%" \
beginRegion="TT" />  </context>
			
			<context name="TTsource" attribute="Normal Text" lineEndConts="#stay">
				
				<!-- Detect end of TT Directive -->
				<StringDetect attribute="TT Markup" context="#pop#pop" String="%]" endRegion="TT" \
/>  
				<!-- Detect TT specific keywords -->
				<RegExpr attribute="TT Files" context="#stay" String="\b[\w/]+\.tmpl" />
				<keyword attribute="TT Directives" context="#stay" String="TTdirectives" />
				<keyword attribute="TT Operators" context="#stay" String="TToperators" />
				<keyword attribute="TT Vmethods" context="#stay" String="TTvmethods" />
<!-- 			<RegExpr attribute="TT Data Type" context="#stay" String="[a-zA-Z]*" /> -->
				
				<!-- Detect strings -->
				<DetectChar attribute="TT Operators" context="ip_string" char="&quot;" \
beginRegion="String" />  <DetectChar attribute="TT Operators" context="string" \
char="'"  beginRegion="String" />  
				<!-- Detect types of numbers -->
				<HlCOct attribute="Octal" context="#stay" />
				<HlCHex attribute="Hex" context="#stay" />
				<Float attribute="Float" context="#stay" />
				<Int attribute="Decimal" context="#stay" />

			</context>

			<!-- Context for finding variables inside of strings -->
			<context name="find_variable" attribute="String (int)" lineEndContext="#pop" \
fallthrough="true" fallthroughContext="#pop" >  <keyword attribute="TT Vmethods" \
context="#pop" String="TTvmethods" />  <RegExpr attribute="TT Data Type" \
context="#pop" String="\$[\w_\.]+" />  </context>
			
			<!-- Context for strings -->
			<context name="ipstring_internal" attribute="String (int)" lineEndContext="#stay">
<!-- 				<RegExpr attribute="String (int)" context="find_variable" String="\$\S" \
lookAhead="true" /> -->  </context>
			<context name="ip_string" attribute="String (int)" lineEndContext="#stay">
				<DetectChar attribute="TT Operator" context="#pop" char="&quot;" \
endRegion="String"/>  <IncludeRules context="ipstring_internal" />
  		    </context>
			<context name="string" attribute="String" lineEndContext="#stay">
				<DetectChar attribute="TT Operator" context="#pop" char="'" endRegion="String" />
			</context>
		
		</contexts>
		
		<itemDatas>
			<itemData name="Normal Text"	defStyleNum="dsNormal" />
			
			<!-- TT specific styles -->
			<itemData name="TT Markup"		defStyleNum="dsFloat" />
			<itemData name="TT Data Type"	defStyleNum="dsDataType" />
			<itemData name="TT Vmethods"	defStyleNum="dsFunction" />
			<itemData name="TT Directives"	defStyleNum="dsKeyword" />
			<itemData name="TT Operators"	defStyleNum="dsKeyword" />
			<itemData name="TT Files"		defStyleNum="dsOthers" />

			<!-- Perl style string styles -->
			<itemData name="String"			defStyleNum="dsString" color="#FF6C6C" \
selColor="#FF6C6C" bold="0" italic="0" />  <itemData name="String \
(int)"	defStyleNum="dsString" />  
			<!-- Standard number style defaults -->
			<itemData name="Decimal"		defStyleNum="dsDecVal" />
			<itemData name="Octal"			defStyleNum="dsBaseN" />
			<itemData name="Hex"			defStyleNum="dsBaseN" />
			<itemData name="Float"			defStyleNum="dsFloat" />
  		</itemDatas>
		
	</highlighting>
	<general>
		<keywords casesensitive="1" />
		<comments>
			<comment name="multiLine" start="&lt;!--" end="--&gt;" />
		</comments>
	</general>
</language>



_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic