mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-15 02:54:07 +08:00

* Merge with heidi related changes (basically only SingleLineMode) * Readd missing file changelog.htm to keep that file list consistent with the downloaded one * Merge our own compiler detection again * Disable including a further compiler includefile jedi.inc
1058 lines
41 KiB
ObjectPascal
1058 lines
41 KiB
ObjectPascal
{-------------------------------------------------------------------------------
|
||
The contents of this file are subject to the Mozilla Public License
|
||
Version 1.1 (the "License"); you may not use this file except in compliance
|
||
with the License. You may obtain a copy of the License at
|
||
http://www.mozilla.org/MPL/
|
||
|
||
Software distributed under the License is distributed on an "AS IS" basis,
|
||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||
the specific language governing rights and limitations under the License.
|
||
|
||
The Original Code is: SynHighlighterHTML.pas, released 2000-04-10.
|
||
The Original Code is based on the hkHTMLSyn.pas file from the
|
||
mwEdit component suite by Martin Waldenburg and other developers, the Initial
|
||
Author of this file is Hideo Koiso.
|
||
Unicode translation by Maël Hörz.
|
||
All Rights Reserved.
|
||
|
||
Contributors to the SynEdit and mwEdit projects are listed in the
|
||
Contributors.txt file.
|
||
|
||
Alternatively, the contents of this file may be used under the terms of the
|
||
GNU General Public License Version 2 or later (the "GPL"), in which case
|
||
the provisions of the GPL are applicable instead of those above.
|
||
If you wish to allow use of your version of this file only under the terms
|
||
of the GPL and not to allow others to use your version of this file
|
||
under the MPL, indicate your decision by deleting the provisions above and
|
||
replace them with the notice and other provisions required by the GPL.
|
||
If you do not delete the provisions above, a recipient may use your version
|
||
of this file under either the MPL or the GPL.
|
||
|
||
$Id: SynHighlighterHtml.pas,v 1.24.2.11 2008/09/14 16:25:00 maelh Exp $
|
||
|
||
You may retrieve the latest version of this file at the SynEdit home page,
|
||
located at http://SynEdit.SourceForge.net
|
||
|
||
Known Issues:
|
||
-------------------------------------------------------------------------------}
|
||
{
|
||
@abstract(Provides an HTML highlighter for SynEdit)
|
||
@author(Hideo Koiso, converted to SynEdit by Michael Hieke)
|
||
@created(1999-11-02, converted to SynEdit 2000-04-10)
|
||
@lastmod(2000-06-23)
|
||
The SynHighlighterHTML unit provides SynEdit with an HTML highlighter.
|
||
}
|
||
|
||
{$IFNDEF QSYNHIGHLIGHTERHTML}
|
||
unit SynHighlighterHtml;
|
||
{$ENDIF}
|
||
|
||
interface
|
||
|
||
{$I SynEdit.inc}
|
||
|
||
uses
|
||
{$IFDEF UNICODE}
|
||
WideStrUtils,
|
||
{$ENDIF}
|
||
{$IFDEF SYN_CLX}
|
||
QGraphics,
|
||
QSynEditTypes,
|
||
QSynEditHighlighter,
|
||
QSynUnicode,
|
||
{$ELSE}
|
||
Graphics,
|
||
SynEditTypes,
|
||
SynEditHighlighter,
|
||
SynUnicode,
|
||
{$ENDIF}
|
||
SysUtils,
|
||
Classes;
|
||
|
||
const
|
||
MAX_ESCAPEAMPS = 249;
|
||
|
||
EscapeAmps: array[0..MAX_ESCAPEAMPS - 1] of PWideChar = (
|
||
('Α'), { ? } { greek capital alpha }
|
||
('Β'), { ? } { greek capital beta }
|
||
('Γ'), { G } { greek capital gamma }
|
||
('Δ'), { ? } { greek capital delta }
|
||
('Ε'), { ? } { greek capital epsilon }
|
||
('Ζ'), { ? } { greek capital zeta }
|
||
('Η'), { ? } { greek capital eta }
|
||
('Θ'), { T } { greek capital theta }
|
||
('Ι'), { ? } { greek capital iota }
|
||
('Κ'), { ? } { greek capital kappa }
|
||
('Λ'), { ? } { greek capital lambda }
|
||
('Μ'), { ? } { greek capital mu }
|
||
('Ν'), { ? } { greek capital nu }
|
||
('Ξ'), { ? } { greek capital xi }
|
||
('Ο'), { ? } { greek capital omicron }
|
||
('Π'), { ? } { greek capital pi }
|
||
('Ρ'), { ? } { greek capital rho }
|
||
('Σ'), { S } { greek capital sigma }
|
||
('Τ'), { ? } { greek capital tau }
|
||
('Υ'), { ? } { greek capital upsilon }
|
||
('Φ'), { F } { greek capital phi }
|
||
('Χ'), { ? } { greek capital chi }
|
||
('Ψ'), { ? } { greek capital psi }
|
||
('Ω'), { O } { greek capital omega }
|
||
('α'), { a } { greek small alpha }
|
||
('β'), { ß } { greek small beta }
|
||
('γ'), { ? } { greek small gamma }
|
||
('δ'), { d } { greek small delta }
|
||
('ε'), { e } { greek small epsilon }
|
||
('ζ'), { ? } { greek small zeta }
|
||
('η'), { ? } { greek small eta }
|
||
('θ'), { ? } { greek small theta }
|
||
('ι'), { ? } { greek small iota }
|
||
('κ'), { ? } { greek small kappa }
|
||
('λ'), { ? } { greek small lambda }
|
||
('μ'), { µ } { greek small mu }
|
||
('ν'), { ? } { greek small nu }
|
||
('ξ'), { ? } { greek small xi }
|
||
('ο'), { ? } { greek small omicron }
|
||
('π'), { p } { greek small pi }
|
||
('ρ'), { ? } { greek small rho }
|
||
('ς'), { ? } { greek small final sigma }
|
||
('σ'), { s } { greek small sigma }
|
||
('τ'), { t } { greek small tau }
|
||
('υ'), { ? } { greek small upsilon }
|
||
('φ'), { f } { greek small phi }
|
||
('χ'), { ? } { greek small chi }
|
||
('ψ'), { ? } { greek small psi }
|
||
('ω'), { ? } { greek small omega }
|
||
('ϑ'), { ? } { greek small theta symbol }
|
||
('ϒ'), { ? } { greek upsilon with hook symbol }
|
||
('ϖ'), { ? } { greek pi symbol }
|
||
('•'), { • } { bullet }
|
||
('…'), { … } { horizontal ellipsis }
|
||
('′'), { ' } { prime }
|
||
('″'), { " } { double prime }
|
||
('‾'), { ? } { overline, = spacing overscore }
|
||
('⁄'), { / } { fraction slash }
|
||
('℘'), { P } { script capital P }
|
||
('ℑ'), { I } { imaginary part }
|
||
('ℜ'), { R } { real part }
|
||
('™'), { ™ } { trademark sign }
|
||
('ℵ'), { ? } { first transfinite cardinal }
|
||
('←'), { ? } { leftwards arrow }
|
||
('↑'), { ? } { upwards arrow }
|
||
('→'), { ? } { rightwards arrow }
|
||
('↓'), { ? } { downwards arrow }
|
||
('↔'), { ? } { left right arrow }
|
||
('↵'), { ? } { carriage return arrow }
|
||
('⇐'), { ? } { leftwards double arrow }
|
||
('⇑'), { ? } { upwards double arrow }
|
||
('⇒'), { ? } { rightwards double arrow }
|
||
('⇓'), { ? } { downwards double arrow }
|
||
('⇔'), { ? } { left right double arrow }
|
||
('∀'), { ? } { for all }
|
||
('∂'), { ? } { partial differential }
|
||
('∃'), { ? } { there exists }
|
||
('∅'), { Ø } { empty set }
|
||
('∇'), { ? } { backward difference }
|
||
('∈'), { ? } { element of }
|
||
('∉'), { ? } { not an element of }
|
||
('∋'), { ? } { contains as member }
|
||
('∏'), { ? } { n-ary product }
|
||
('∑'), { ? } { n-ary sumation }
|
||
('−'), { - } { minus sign }
|
||
('∗'), { * } { asterisk operator }
|
||
('√'), { v } { square root }
|
||
('∝'), { ? } { proportional to }
|
||
('∞'), { 8 } { infinity }
|
||
('∠'), { ? } { angle }
|
||
('∧'), { ? } { logical and }
|
||
('∨'), { ? } { logical or }
|
||
('∩'), { n } { intersection }
|
||
('∪'), { ? } { union }
|
||
('∫'), { ? } { integral }
|
||
('∴'), { ? } { therefore }
|
||
('∼'), { ~ } { similar to = tilde operator }
|
||
('≅'), { ? } { approximately equal to }
|
||
('≈'), { ˜ } { almost euqal to }
|
||
('≠'), { ? } { not equal to }
|
||
('≡'), { = } { identical to }
|
||
('≤'), { = } { less-than or equal to }
|
||
('≥'), { = } { greater-than or equal to }
|
||
('⊂'), { ? } { subset of }
|
||
('⊃'), { ? } { superset of }
|
||
('⊄'), { ? } { not a subset of }
|
||
('⊆'), { ? } { subset of or equal to }
|
||
('⊇'), { ? } { superset of or equal to }
|
||
('⊕'), { ? } { circled plus }
|
||
('⊗'), { ? } { circled times }
|
||
('⊥'), { ? } { orthogonal to = perpendicular }
|
||
('⋅'), { · } { dot operator }
|
||
('⌈'), { ? } { left ceiling }
|
||
('⌉'), { ? } { right ceiling }
|
||
('⌊'), { ? } { left floor }
|
||
('⌋'), { ? } { right floor }
|
||
('⟨'), { < } { left-pointing angle bracket }
|
||
('⟩'), { > } { right-pointing angle bracket }
|
||
('◊'), { ? } { lozenge }
|
||
('♠'), { ? } { black spade suit }
|
||
('♣'), { ? } { black club suit }
|
||
('♥'), { ? } { black heart suit }
|
||
('♦'), { ? } { black diamond suit }
|
||
('‘'), { ‘ } { left single quote }
|
||
('’'), { ’ } { right single quote }
|
||
('‚'), { ‚ } { single low-9 quote }
|
||
('“'), { “ } { left double quote }
|
||
('”'), { ” } { right double quote }
|
||
('„'), { „ } { double low-9 quote }
|
||
('†'), { † } { dagger }
|
||
('‡'), { ‡ } { double dagger }
|
||
('‰'), { ‰ } { per mill sign }
|
||
('‹'), { ‹ } { single left-pointing angle quote }
|
||
('›'), { › } { single right-pointing angle quote }
|
||
('"'), { " " } { double quotation mark }
|
||
('&'), { & & } { ampersand }
|
||
('<'), { < < } { less-than sign }
|
||
('>'), { > } { greater-than sign }
|
||
('–'), { – – } { en dash }
|
||
('—'), { — — } { em dash }
|
||
(' '), {   } { nonbreaking space }
|
||
(' '), { } { thin space }
|
||
(' '), { } { en space }
|
||
(' '), { } { em space }
|
||
('¡'), { ¡ ! } { inverted exclamation }
|
||
('¢'), { ¢ c } { cent sign }
|
||
('£'), { £ L } { pound sterling }
|
||
('¤'), { ¤ ¤ } { general currency sign }
|
||
('¥'), { ¥ Y } { yen sign }
|
||
('¦'), { ¦ ¦ } { broken vertical bar }
|
||
('&brkbar;'), { ¦ ¦ } { broken vertical bar }
|
||
('§'), { § § } { section sign }
|
||
('¨'), { ¨ ¨ } { umlaut }
|
||
('¨'), { ¨ ¨ } { umlaut }
|
||
('©'), { © © } { copyright }
|
||
('ª'), { ª a } { feminine ordinal }
|
||
('«'), { « « } { left angle quote }
|
||
('¬'), { ¬ ¬ } { not sign }
|
||
('­'), { ­ } { soft hyphen }
|
||
('®'), { ® ® } { registered trademark }
|
||
('¯'), { ¯ — } { macron accent }
|
||
('&hibar;'), { ¯ — } { macron accent }
|
||
('°'), { ° ° } { degree sign }
|
||
('±'), { ± ± } { plus or minus }
|
||
('²'), { ² 2 } { superscript two }
|
||
('³'), { ³ 3 } { superscript three }
|
||
('´'), { ´ ´ } { acute accent }
|
||
('µ'), { µ µ } { micro sign }
|
||
('¶'), { ¶ ¶ } { paragraph sign }
|
||
('·'), { · · } { middle dot }
|
||
('¸'), { ¸ ¸ } { cedilla }
|
||
('¹'), { ¹ 1 } { superscript one }
|
||
('º'), { º o } { masculine ordinal }
|
||
('»'), { » » } { right angle quote }
|
||
('¼'), { ¼ 1 } { one-fourth }
|
||
('½'), { ½ 1 } { one-half }
|
||
('¾'), { ¾ 3 } { three-fourths }
|
||
('¿'), { ¿ ? } { inverted question mark }
|
||
('À'), { À A } { uppercase A, grave accent }
|
||
('Á'), { Á Á } { uppercase A, acute accent }
|
||
('Â'), { Â Â } { uppercase A, circumflex accent }
|
||
('Ã'), { Ã A } { uppercase A, tilde }
|
||
('Ä'), { Ä Ä } { uppercase A, umlaut }
|
||
('Å'), { Å A } { uppercase A, ring }
|
||
('Æ'), { Æ A } { uppercase AE }
|
||
('Ç'), { Ç Ç } { uppercase C, cedilla }
|
||
('È'), { È E } { uppercase E, grave accent }
|
||
('É'), { É É } { uppercase E, acute accent }
|
||
('Ê'), { Ê E } { uppercase E, circumflex accent }
|
||
('Ë'), { Ë Ë } { uppercase E, umlaut }
|
||
('Ì'), { Ì I } { uppercase I, grave accent }
|
||
('Í'), { Í Í } { uppercase I, acute accent }
|
||
('Î'), { Î Î } { uppercase I, circumflex accent }
|
||
('Ï'), { Ï I } { uppercase I, umlaut }
|
||
('Ð'), { Ð ? } { uppercase Eth, Icelandic }
|
||
('Ñ'), { Ñ N } { uppercase N, tilde }
|
||
('Ò'), { Ò O } { uppercase O, grave accent }
|
||
('Ó'), { Ó Ó } { uppercase O, acute accent }
|
||
('Ô'), { Ô Ô } { uppercase O, circumflex accent }
|
||
('Õ'), { Õ O } { uppercase O, tilde }
|
||
('Ö'), { Ö Ö } { uppercase O, umlaut }
|
||
('×'), { × × } { multiplication sign }
|
||
('Ø'), { Ø O } { uppercase O, slash }
|
||
('Ù'), { Ù U } { uppercase U, grave accent }
|
||
('Ú'), { Ú Ú } { uppercase U, acute accent }
|
||
('Û'), { Û U } { uppercase U, circumflex accent }
|
||
('Ü'), { Ü Ü } { uppercase U, umlaut }
|
||
('Ý'), { Ý Ý } { uppercase Y, acute accent }
|
||
('Þ'), { Þ ? } { uppercase THORN, Icelandic }
|
||
('ß'), { ß ß } { lowercase sharps, German }
|
||
('à'), { à à } { lowercase a, grave accent }
|
||
('á'), { á á } { lowercase a, acute accent }
|
||
('â'), { â â } { lowercase a, circumflex accent }
|
||
('ã'), { ã ã } { lowercase a, tilde }
|
||
('ä'), { ä ä } { lowercase a, umlaut }
|
||
('å'), { å å } { lowercase a, ring }
|
||
('æ'), { æ a } { lowercase ae }
|
||
('ç'), { ç ç } { lowercase c, cedilla }
|
||
('è'), { è e } { lowercase e, grave accent }
|
||
('é'), { é é } { lowercase e, acute accent }
|
||
('ê'), { ê ê } { lowercase e, circumflex accent }
|
||
('ë'), { ë ë } { lowercase e, umlaut }
|
||
('ì'), { ì i } { lowercase i, grave accent }
|
||
('í'), { í í } { lowercase i, acute accent }
|
||
('î'), { î î } { lowercase i, circumflex accent }
|
||
('ï'), { ï i } { lowercase i, umlaut }
|
||
('ð'), { ð ? } { lowercase eth, Icelandic }
|
||
('ñ'), { ñ ñ } { lowercase n, tilde }
|
||
('ò'), { ò o } { lowercase o, grave accent }
|
||
('ó'), { ó ó } { lowercase o, acute accent }
|
||
('ô'), { ô ô } { lowercase o, circumflex accent }
|
||
('õ'), { õ o } { lowercase o, tilde }
|
||
('ö'), { ö ö } { lowercase o, umlaut }
|
||
('÷'), { ÷ ÷ } { division sign }
|
||
('ø'), { ø o } { lowercase o, slash }
|
||
('ù'), { ù u } { lowercase u, grave accent }
|
||
('ú'), { ú ú } { lowercase u, acute accent }
|
||
('û'), { û u } { lowercase u, circumflex accent }
|
||
('ü'), { ü ü } { lowercase u, umlaut }
|
||
('ý'), { ý ý } { lowercase y, acute accent }
|
||
('þ'), { þ ? } { lowercase thorn, Icelandic }
|
||
('ÿ'), { ÿ y } { lowercase y, umlaut }
|
||
('€'), { € } { euro sign }
|
||
('Œ'), { Œ } { capital ligature OE }
|
||
('œ'), { œ } { small ligature oe }
|
||
('š'), { š } { small S with caron }
|
||
('Š'), { Š } { capital S with caron }
|
||
('ƒ'), { ƒ } { function }
|
||
('ˆ') { ˆ } { circumflex accent }
|
||
);
|
||
|
||
|
||
type
|
||
TtkTokenKind = (tkAmpersand, tkComment, tkIdentifier, tkKey, tkNull,
|
||
tkSpace, tkSymbol, tkText, tkUndefKey, tkValue);
|
||
|
||
TRangeState = (rsAmpersand, rsComment, rsKey, rsParam, rsText,
|
||
rsUnKnown, rsValue, rsQuoteValue, rsDoubleQuoteValue);
|
||
|
||
PIdentFuncTableFunc = ^TIdentFuncTableFunc;
|
||
TIdentFuncTableFunc = function (Index: Integer): TtkTokenKind of object;
|
||
|
||
TSynHTMLSyn = class(TSynCustomHighlighter)
|
||
private
|
||
fAndCode: Integer;
|
||
fRange: TRangeState;
|
||
fIdentFuncTable: array[0..1542] of TIdentFuncTableFunc;
|
||
fTokenID: TtkTokenKind;
|
||
fAndAttri: TSynHighlighterAttributes;
|
||
fCommentAttri: TSynHighlighterAttributes;
|
||
fIdentifierAttri: TSynHighlighterAttributes;
|
||
fKeyAttri: TSynHighlighterAttributes;
|
||
fSpaceAttri: TSynHighlighterAttributes;
|
||
fSymbolAttri: TSynHighlighterAttributes;
|
||
fTextAttri: TSynHighlighterAttributes;
|
||
fUndefKeyAttri: TSynHighlighterAttributes;
|
||
fValueAttri: TSynHighlighterAttributes;
|
||
function AltFunc(Index: Integer): TtkTokenKind;
|
||
function KeyWordFunc(Index: Integer): TtkTokenKind;
|
||
function HashKey(Str: PWideChar): Cardinal;
|
||
function IdentKind(MayBe: PWideChar): TtkTokenKind;
|
||
procedure InitIdent;
|
||
procedure TextProc;
|
||
procedure CommentProc;
|
||
procedure BraceCloseProc;
|
||
procedure BraceOpenProc;
|
||
procedure CRProc;
|
||
procedure EqualProc;
|
||
procedure IdentProc;
|
||
procedure LFProc;
|
||
procedure NullProc;
|
||
procedure SpaceProc;
|
||
procedure StringProc;
|
||
procedure AmpersandProc;
|
||
protected
|
||
function GetSampleSource: UnicodeString; override;
|
||
function IsFilterStored: Boolean; override;
|
||
procedure NextProcedure;
|
||
public
|
||
class function GetLanguageName: string; override;
|
||
class function GetFriendlyLanguageName: UnicodeString; override;
|
||
public
|
||
constructor Create(AOwner: TComponent); override;
|
||
function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||
override;
|
||
function GetEol: Boolean; override;
|
||
function GetRange: Pointer; override;
|
||
function GetTokenID: TtkTokenKind;
|
||
function GetTokenAttribute: TSynHighlighterAttributes; override;
|
||
function GetTokenKind: Integer; override;
|
||
procedure Next; override;
|
||
procedure SetRange(Value: Pointer); override;
|
||
procedure ResetRange; override;
|
||
published
|
||
property AndAttri: TSynHighlighterAttributes read fAndAttri write fAndAttri;
|
||
property CommentAttri: TSynHighlighterAttributes read fCommentAttri
|
||
write fCommentAttri;
|
||
property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri
|
||
write fIdentifierAttri;
|
||
property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
|
||
property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
|
||
write fSpaceAttri;
|
||
property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri
|
||
write fSymbolAttri;
|
||
property TextAttri: TSynHighlighterAttributes read fTextAttri
|
||
write fTextAttri;
|
||
property UndefKeyAttri: TSynHighlighterAttributes read fUndefKeyAttri
|
||
write fUndefKeyAttri;
|
||
property ValueAttri: TSynHighlighterAttributes read fValueAttri
|
||
write fValueAttri;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
{$IFDEF SYN_CLX}
|
||
QSynEditStrConst;
|
||
{$ELSE}
|
||
SynEditStrConst;
|
||
{$ENDIF}
|
||
|
||
const
|
||
KeyWords: array[0..201] of UnicodeString = (
|
||
'!doctype', '/a', '/abbr', '/acronym', '/address', '/applet', '/b', '/bdo',
|
||
'/big', '/blink', '/blockquote', '/body', '/button', '/caption', '/center',
|
||
'/cite', '/code', '/colgroup', '/comment', '/dd', '/del', '/dfn', '/dir',
|
||
'/div', '/dl', '/dt', '/em', '/embed', '/fieldset', '/font', '/form',
|
||
'/frameset', '/h1', '/h2', '/h3', '/h4', '/h5', '/h6', '/head', '/html',
|
||
'/i', '/iframe', '/ilayer', '/ins', '/kbd', '/label', '/layer', '/legend',
|
||
'/li', '/listing', '/map', '/marquee', '/menu', '/multicol', '/nobr',
|
||
'/noembed', '/noframes', '/nolayer', '/noscript', '/object', '/ol',
|
||
'/optgroup', '/option', '/p', '/pre', '/q', '/s', '/samp', '/script',
|
||
'/select', '/server', '/small', '/span', '/strike', '/strong', '/style',
|
||
'/sub', '/sup', '/table', '/tbody', '/td', '/textarea', '/tfoot', '/th',
|
||
'/thead', '/title', '/tr', '/tt', '/u', '/ul', '/var', '/xmp', 'a', 'abbr',
|
||
'acronym', 'address', 'applet', 'area', 'b', 'base', 'basefont', 'bdo',
|
||
'bgsound', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'caption',
|
||
'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'dd', 'del', 'dfn',
|
||
'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'font', 'form',
|
||
'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr',
|
||
'html', 'i', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'kbd',
|
||
'keygen', 'label', 'layer', 'legend', 'li', 'link', 'listing', 'map',
|
||
'marquee', 'menu', 'meta', 'multicol', 'nextid', 'nobr', 'noembed',
|
||
'noframes', 'nolayer', 'noscript', 'object', 'ol', 'optgroup', 'option',
|
||
'p', 'param', 'plaintext', 'pre', 'q', 's', 'samp', 'script', 'select',
|
||
'server', 'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub',
|
||
'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title',
|
||
'tr', 'tt', 'u', 'ul', 'var', 'wbr', 'xmp'
|
||
);
|
||
|
||
KeyIndices: array[0..1542] of Integer = (
|
||
-1, -1, 182, -1, -1, -1, 97, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, 33, -1, -1, -1, -1, 40, -1, -1, -1, -1, -1, 137, 189, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, 191, -1, -1, -1, -1, -1, -1, -1, 52, 170, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, 5, 55, -1, 83, -1, -1, 34, -1, 198, -1, -1, -1,
|
||
-1, -1, -1, -1, 82, -1, -1, -1, -1, -1, 74, 111, -1, 62, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, 35, 72, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 130,
|
||
190, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, 157, -1, -1, -1,
|
||
-1, -1, 13, 114, -1, -1, -1, -1, 131, -1, -1, -1, -1, -1, -1, 21, -1, -1,
|
||
-1, 161, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 139, -1,
|
||
-1, -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 192, -1, -1,
|
||
132, 103, -1, -1, -1, 199, -1, -1, -1, -1, -1, -1, -1, 129, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, 133, -1, -1, -1, -1, -1, -1, -1, -1, 54,
|
||
-1, -1, -1, -1, -1, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, -1, -1, -1,
|
||
148, -1, -1, -1, -1, -1, -1, -1, 96, -1, -1, -1, -1, -1, -1, -1, -1, 134,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, -1, -1, 168, -1, 45,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 179, -1, -1, 63, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, 135, -1, -1, -1, -1, -1, -1, 60, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 125, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, 4, -1, -1, 39, -1, -1, -1, -1, 128, 20, -1, -1, 51, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 176, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, 112, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
180, -1, -1, -1, -1, -1, 172, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 107,
|
||
-1, -1, -1, -1, 66, -1, -1, -1, 59, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, 162, -1, 8, -1, -1, -1, -1, -1, -1, 166, -1,
|
||
-1, -1, 169, 141, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 95, -1, -1,
|
||
-1, -1, -1, -1, -1, 56, -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, 19, -1, -1, 41, -1, 173, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, 88, -1, -1, -1, -1, -1, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, 200, -1,
|
||
-1, -1, 87, 181, -1, -1, -1, -1, 119, -1, -1, -1, 57, -1, -1, -1, 104, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, -1, 26, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, 174, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, 201, -1, -1, -1, 195, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
58, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 49, -1, -1, -1, 101,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, 113, 187, -1, -1,
|
||
-1, 94, -1, -1, -1, -1, -1, 165, -1, -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
|
||
-1, -1, 167, -1, -1, 163, -1, -1, 197, -1, -1, -1, -1, 78, -1, 68, -1, -1,
|
||
-1, -1, -1, -1, 145, -1, -1, 196, -1, -1, -1, -1, 12, -1, -1, -1, 160, -1,
|
||
61, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 123,
|
||
-1, -1, -1, -1, -1, -1, 76, 120, -1, 140, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, 10, -1, -1, -1, -1, -1, 153, -1, -1, -1, -1, -1, -1, -1, 30, -1, -1,
|
||
-1, -1, -1, -1, 142, -1, -1, -1, -1, -1, 99, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 152, -1, 171,
|
||
-1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, 150, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
22, -1, -1, -1, -1, -1, 138, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
24, -1, 70, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 53, -1, -1, 177, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, 100, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 144, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, -1, -1,
|
||
-1, 121, 159, 102, -1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 155, 149, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, 81, 2, -1, 110, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, 146, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
178, -1, -1, -1, -1, -1, 17, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, 164, -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, 9,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, 6, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, 188, -1, -1, -1, -1, -1, -1, -1, 25, -1, -1, 73, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64,
|
||
79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 127, -1, -1, -1, 18, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, 43, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, 184, -1, -1, -1, 175, -1, -1, 193, -1, 92, 151, 154, -1, -1, -1, -1,
|
||
106, -1, -1, -1, -1, -1, -1, -1, -1, -1, 194, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, 75, -1, -1, -1, -1, -1, -1, 84, -1, -1, -1, -1, -1, 28, -1, -1, -1, -1,
|
||
-1, -1, 98, -1, 80, -1, -1, -1, 85, -1, -1, -1, -1, 67, -1, 118, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, 126, -1, -1, -1, -1, -1, 77, -1, -1, 122, 44, -1, -1,
|
||
-1, -1, -1, 89, -1, -1, -1, 115, 136, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
-1, -1, -1, -1, -1, -1, -1, 105, -1, -1, -1, -1, -1, -1, -1, -1, 147, -1,
|
||
16, 185, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||
158, -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, 91,
|
||
-1, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||
);
|
||
|
||
{$Q-}
|
||
function TSynHTMLSyn.HashKey(Str: PWideChar): Cardinal;
|
||
begin
|
||
Result := 0;
|
||
while IsIdentChar(Str^) or CharInSet(Str^, ['!', '/']) do
|
||
begin
|
||
Result := Result * 932 + Ord(Str^) * 46;
|
||
inc(Str);
|
||
end;
|
||
Result := Result mod 1543;
|
||
fStringLen := Str - fToIdent;
|
||
end;
|
||
{$Q+}
|
||
|
||
function TSynHTMLSyn.IdentKind(MayBe: PWideChar): TtkTokenKind;
|
||
var
|
||
Key: Cardinal;
|
||
begin
|
||
fToIdent := MayBe;
|
||
Key := HashKey(MayBe);
|
||
if Key <= High(fIdentFuncTable) then
|
||
Result := fIdentFuncTable[Key](KeyIndices[Key])
|
||
else
|
||
Result := tkIdentifier;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.InitIdent;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
for i := Low(fIdentFuncTable) to High(fIdentFuncTable) do
|
||
if KeyIndices[i] = -1 then
|
||
fIdentFuncTable[i] := AltFunc;
|
||
|
||
for i := Low(fIdentFuncTable) to High(fIdentFuncTable) do
|
||
if @fIdentFuncTable[i] = nil then
|
||
fIdentFuncTable[i] := KeyWordFunc;
|
||
end;
|
||
|
||
function TSynHTMLSyn.AltFunc(Index: Integer): TtkTokenKind;
|
||
begin
|
||
Result := tkUndefKey;
|
||
end;
|
||
|
||
function TSynHTMLSyn.KeyWordFunc(Index: Integer): TtkTokenKind;
|
||
begin
|
||
if IsCurrentToken(KeyWords[Index]) then
|
||
Result := tkKey
|
||
else
|
||
Result := tkUndefKey;
|
||
end;
|
||
|
||
constructor TSynHTMLSyn.Create(AOwner: TComponent);
|
||
begin
|
||
inherited Create(AOwner);
|
||
|
||
fCaseSensitive := False;
|
||
|
||
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment, SYNS_FriendlyAttrComment);
|
||
AddAttribute(fCommentAttri);
|
||
|
||
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier, SYNS_FriendlyAttrIdentifier);
|
||
fIdentifierAttri.Style := [fsBold];
|
||
AddAttribute(fIdentifierAttri);
|
||
|
||
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord, SYNS_FriendlyAttrReservedWord);
|
||
fKeyAttri.Style := [fsBold];
|
||
fKeyAttri.Foreground := $00ff0080;
|
||
AddAttribute(fKeyAttri);
|
||
|
||
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace, SYNS_FriendlyAttrSpace);
|
||
AddAttribute(fSpaceAttri);
|
||
|
||
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol, SYNS_FriendlyAttrSymbol);
|
||
fSymbolAttri.Style := [fsBold];
|
||
AddAttribute(fSymbolAttri);
|
||
|
||
fTextAttri := TSynHighlighterAttributes.Create(SYNS_AttrText, SYNS_FriendlyAttrText);
|
||
AddAttribute(fTextAttri);
|
||
|
||
fUndefKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrUnknownWord, SYNS_FriendlyAttrUnknownWord);
|
||
fUndefKeyAttri.Style := [fsBold];
|
||
fUndefKeyAttri.Foreground := clRed;
|
||
AddAttribute(fUndefKeyAttri);
|
||
|
||
fValueAttri := TSynHighlighterAttributes.Create(SYNS_AttrValue, SYNS_FriendlyAttrValue);
|
||
fValueAttri.Foreground := $00ff8000;
|
||
AddAttribute(fValueAttri);
|
||
|
||
fAndAttri := TSynHighlighterAttributes.Create(SYNS_AttrEscapeAmpersand, SYNS_FriendlyAttrEscapeAmpersand);
|
||
fAndAttri.Style := [fsBold];
|
||
fAndAttri.Foreground := $0000ff00;
|
||
AddAttribute(fAndAttri);
|
||
SetAttributesOnChange(DefHighlightChange);
|
||
|
||
InitIdent;
|
||
fRange := rsText;
|
||
fDefaultFilter := SYNS_FilterHTML;
|
||
fAndCode := -1;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.BraceCloseProc;
|
||
begin
|
||
fRange := rsText;
|
||
fTokenId := tkSymbol;
|
||
Inc(Run);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.CommentProc;
|
||
begin
|
||
fTokenID := tkComment;
|
||
|
||
if IsLineEnd(Run) then
|
||
begin
|
||
NextProcedure;
|
||
Exit;
|
||
end;
|
||
|
||
while not IsLineEnd(Run) do
|
||
begin
|
||
if (fLine[Run] = '>') and (fLine[Run - 1] = '-') and (fLine[Run - 2] = '-') then
|
||
begin
|
||
fRange := rsText;
|
||
Inc(Run);
|
||
break;
|
||
end;
|
||
Inc(Run);
|
||
end;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.BraceOpenProc;
|
||
begin
|
||
Inc(Run);
|
||
if (fLine[Run] = '!') and (fLine[Run + 1] = '-') and (fLine[Run + 2] = '-') then
|
||
begin
|
||
fRange := rsComment;
|
||
fTokenID := tkComment;
|
||
Inc(Run, 3);
|
||
end
|
||
else
|
||
begin
|
||
fRange := rsKey;
|
||
fTokenID := tkSymbol;
|
||
end;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.CRProc;
|
||
begin
|
||
fTokenID := tkSpace;
|
||
Inc(Run);
|
||
if fLine[Run] = #10 then Inc(Run);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.EqualProc;
|
||
begin
|
||
fRange := rsValue;
|
||
fTokenID := tkSymbol;
|
||
Inc(Run);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.IdentProc;
|
||
begin
|
||
case fRange of
|
||
rsKey:
|
||
begin
|
||
fRange := rsParam;
|
||
fTokenID := IdentKind((fLine + Run));
|
||
Inc(Run, fStringLen);
|
||
end;
|
||
rsValue:
|
||
begin
|
||
fRange := rsParam;
|
||
fTokenID := tkValue;
|
||
repeat
|
||
Inc(Run);
|
||
until (fLine[Run] <= #32) or (fLine[Run] = '>');
|
||
end;
|
||
else
|
||
fTokenID := tkIdentifier;
|
||
repeat
|
||
Inc(Run);
|
||
until (fLine[Run] <= #32) or (fLine[Run] = '=') or (fLine[Run] = '"') or
|
||
(fLine[Run] = '>');
|
||
end;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.LFProc;
|
||
begin
|
||
fTokenID := tkSpace;
|
||
Inc(Run);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.NullProc;
|
||
begin
|
||
fTokenID := tkNull;
|
||
inc(Run);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.TextProc;
|
||
|
||
function IsStopChar: Boolean;
|
||
begin
|
||
case fLine[Run] of
|
||
#0..#31, '<', '&':
|
||
Result := True;
|
||
else
|
||
Result := False;
|
||
end;
|
||
end;
|
||
|
||
function IsNumberChar: Boolean;
|
||
begin
|
||
case fLine[Run] of
|
||
'0'..'9', 'A'..'F', 'a'..'f':
|
||
Result := True;
|
||
else
|
||
Result := False;
|
||
end;
|
||
end;
|
||
|
||
var
|
||
i: Integer;
|
||
begin
|
||
if CharInSet(fLine[Run], [#0..#31, '<']) then
|
||
begin
|
||
NextProcedure;
|
||
exit;
|
||
end;
|
||
|
||
fTokenID := tkText;
|
||
|
||
while True do
|
||
begin
|
||
while not IsStopChar do Inc(Run);
|
||
|
||
if (fLine[Run] = '&') then
|
||
begin
|
||
if (fLine[Run + 1] = '#') then
|
||
begin
|
||
fAndCode := -1;
|
||
i := Run;
|
||
inc(Run, 2);
|
||
if CharInSet(fLine[Run], ['X', 'x']) then
|
||
begin
|
||
inc(Run);
|
||
while IsNumberChar do
|
||
inc(Run);
|
||
end
|
||
else
|
||
while CharInSet(fLine[Run], ['0'..'9']) do
|
||
inc(Run);
|
||
if (fLine[Run] = ';') then
|
||
begin
|
||
inc(Run);
|
||
Run := i;
|
||
fRange := rsAmpersand;
|
||
end;
|
||
break;
|
||
end
|
||
else
|
||
for i := Low(EscapeAmps) To High(EscapeAmps) do
|
||
if (WStrLComp((fLine + Run), EscapeAmps[i], WStrLen(EscapeAmps[i])) = 0) then
|
||
begin
|
||
fAndCode := i;
|
||
fRange := rsAmpersand;
|
||
Exit;
|
||
end;
|
||
|
||
Inc(Run);
|
||
end
|
||
else
|
||
Break;
|
||
end;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.AmpersandProc;
|
||
|
||
function IsNumberChar: Boolean;
|
||
begin
|
||
case fLine[Run] of
|
||
'0'..'9', 'A'..'F', 'a'..'f':
|
||
Result := True;
|
||
else
|
||
Result := False;
|
||
end;
|
||
end;
|
||
|
||
begin
|
||
if fRange <> rsAmpersand then
|
||
begin
|
||
if fRange = rsKey then
|
||
begin
|
||
Inc(Run);
|
||
fRange := rsText;
|
||
fTokenID := tkText;
|
||
end
|
||
else
|
||
IdentProc;
|
||
Exit;
|
||
end;
|
||
|
||
case fAndCode of
|
||
Low(EscapeAmps)..High(EscapeAmps):
|
||
begin
|
||
fTokenID := tkAmpersand;
|
||
Inc(Run, WStrLen(EscapeAmps[fAndCode]));
|
||
end;
|
||
else begin
|
||
if (fLine[Run + 1] = '#') then
|
||
begin
|
||
fAndCode := -1;
|
||
inc(Run, 2);
|
||
if CharInSet(fLine[Run], ['X', 'x']) then
|
||
begin
|
||
inc(Run);
|
||
while IsNumberChar do
|
||
inc(Run);
|
||
end
|
||
else
|
||
while CharInSet(fLine[Run], ['0'..'9']) do
|
||
inc(Run);
|
||
if (fLine[Run] = ';') then begin
|
||
inc(Run);
|
||
fTokenID := tkAmpersand;
|
||
end else
|
||
fTokenID := tkText;
|
||
end;
|
||
end;
|
||
end;
|
||
fAndCode := -1;
|
||
fRange := rsText;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.SpaceProc;
|
||
begin
|
||
inc(Run);
|
||
fTokenID := tkSpace;
|
||
while fLine[Run] <= #32 do
|
||
begin
|
||
if CharInSet(fLine[Run], [#0, #9, #10, #13]) then break;
|
||
Inc(Run);
|
||
end;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.StringProc;
|
||
var
|
||
iOpenChar: WideChar;
|
||
begin
|
||
case fRange of
|
||
rsQuoteValue:
|
||
begin
|
||
iOpenChar := #39;
|
||
fTokenID := tkValue;
|
||
end;
|
||
rsDoubleQuoteValue:
|
||
begin
|
||
iOpenChar := '"';
|
||
fTokenID := tkValue;
|
||
end;
|
||
else
|
||
begin
|
||
iOpenChar := fLine[Run];
|
||
if fRange = rsValue then
|
||
begin
|
||
if iOpenChar = '"' then
|
||
fRange := rsDoubleQuoteValue
|
||
else
|
||
fRange := rsQuoteValue;
|
||
fTokenID := tkValue;
|
||
end else
|
||
begin
|
||
IdentProc;
|
||
Exit;
|
||
end;
|
||
Inc(Run); { jumps over the opening char }
|
||
end;
|
||
end;
|
||
|
||
while not IsLineEnd(Run) do
|
||
begin
|
||
if fLine[Run] = iOpenChar then
|
||
begin
|
||
Inc(Run); { jumps over the closing char }
|
||
if fRange in [rsDoubleQuoteValue, rsQuoteValue] then
|
||
fRange := rsParam
|
||
else
|
||
fRange := rsText;
|
||
break;
|
||
end;
|
||
Inc(Run);
|
||
end;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.Next;
|
||
begin
|
||
fTokenPos := Run;
|
||
case fRange of
|
||
rsText:
|
||
TextProc;
|
||
rsComment:
|
||
CommentProc;
|
||
rsQuoteValue, rsDoubleQuoteValue:
|
||
if IsLineEnd(Run) then
|
||
NextProcedure
|
||
else
|
||
StringProc;
|
||
else
|
||
NextProcedure;
|
||
end;
|
||
|
||
// ensure that one call of Next is enough to reach next token
|
||
if (fOldRun = Run) and not GetEol then Next;
|
||
|
||
inherited;
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.NextProcedure;
|
||
begin
|
||
case fLine[Run] of
|
||
#0: NullProc;
|
||
#10: LFProc;
|
||
#13: CRProc;
|
||
#1..#9, #11, #12, #14..#32: SpaceProc;
|
||
'&': AmpersandProc;
|
||
'"', #39: StringProc;
|
||
'<': BraceOpenProc;
|
||
'>': BraceCloseProc;
|
||
'=': EqualProc;
|
||
else IdentProc;
|
||
end;
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||
begin
|
||
case Index of
|
||
SYN_ATTR_COMMENT: Result := fCommentAttri;
|
||
SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
|
||
SYN_ATTR_KEYWORD: Result := fKeyAttri;
|
||
SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
|
||
SYN_ATTR_SYMBOL: Result := fSymbolAttri;
|
||
else
|
||
Result := nil;
|
||
end;
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetEol: Boolean;
|
||
begin
|
||
Result := Run = fLineLen + 1;
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetTokenID: TtkTokenKind;
|
||
begin
|
||
Result := fTokenId;
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetTokenAttribute: TSynHighlighterAttributes;
|
||
begin
|
||
case fTokenID of
|
||
tkAmpersand: Result := fAndAttri;
|
||
tkComment: Result := fCommentAttri;
|
||
tkIdentifier: Result := fIdentifierAttri;
|
||
tkKey: Result := fKeyAttri;
|
||
tkSpace: Result := fSpaceAttri;
|
||
tkSymbol: Result := fSymbolAttri;
|
||
tkText: Result := fTextAttri;
|
||
tkUndefKey: Result := fUndefKeyAttri;
|
||
tkValue: Result := fValueAttri;
|
||
else Result := nil;
|
||
end;
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetTokenKind: integer;
|
||
begin
|
||
Result := Ord(fTokenId);
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetRange: Pointer;
|
||
begin
|
||
Result := Pointer(fRange);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.SetRange(Value: Pointer);
|
||
begin
|
||
fRange := TRangeState(Value);
|
||
end;
|
||
|
||
procedure TSynHTMLSyn.ResetRange;
|
||
begin
|
||
fRange:= rsText;
|
||
end;
|
||
|
||
function TSynHTMLSyn.IsFilterStored: Boolean;
|
||
begin
|
||
Result := fDefaultFilter <> SYNS_FilterHTML;
|
||
end;
|
||
|
||
class function TSynHTMLSyn.GetLanguageName: string;
|
||
begin
|
||
Result := SYNS_LangHTML;
|
||
end;
|
||
|
||
function TSynHTMLSyn.GetSampleSource: UnicodeString;
|
||
begin
|
||
Result := '<!-- Syntax highlighting -->'#13#10 +
|
||
#13#10 +
|
||
'<html>'#13#10 +
|
||
'<body bgcolor="red">'#13#10 +
|
||
' <form name="frmLogin" action="doSomething.asp">'#13#10 +
|
||
' <input name="user" value=''any'#13#10 +
|
||
' value''>'#13#10 +
|
||
' </form>'#13#10 +
|
||
' <invalid>Sample HTML code © 2001</invalid>'#13#10 +
|
||
'</body>'#13#10 +
|
||
'</html>';
|
||
end;
|
||
|
||
class function TSynHTMLSyn.GetFriendlyLanguageName: UnicodeString;
|
||
begin
|
||
Result := SYNS_FriendlyLangHTML;
|
||
end;
|
||
|
||
initialization
|
||
{$IFNDEF SYN_CPPB_1}
|
||
RegisterPlaceableHighlighter(TSynHTMLSyn);
|
||
{$ENDIF}
|
||
end.
|