HTML syntax file weirdness

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
WayneCa
Posts: 50
Joined: Sat Aug 16, 2014 2:13 am

HTML syntax file weirdness

Post by WayneCa »

I am creating a website where I will document the history of HTML tags and attributes. I am also creating a syntax file that will hilite the tags and attributes in TextPad according to validity in HTML5. I have not finished cataloging all of the tags and attributes yet, but I am already seeing oddity in the coloring of the tags and attributes. In specific, the dir attribute, which is valid, is being hilited as a invalid tag, not a valid attribute. DIR occurs in the invalid tags keyword section and dir occurs in the valid attributes keyword section of the syntax file.

While HTML is case-insensitive, and modern usage suggests that everyone uses all lowercase, I prefer to keep my tags and attributes separated by using uppercase on tags and lowercase on attributes, with event attributes being a combination. The syntax file remains set as case-insensitive to follow the convention of the HTML standard. FWIW, HTML shows up as a tag and html shows up as an attribute using the syntax file as it is now. It is only dir that is showing up incorrectly. I would appreciate help in determining why this is happening.

The keyword sections are as follows:
  • keywords 1 - valid primary tags (HTML, TITLE, etc.)
    keywords 2 - valid secondary tags (tables, lists, BR, HR, SPAN)
    keywords 3 - invalid tags (TT, STRIKE, etc.)
    keywords 4 - valid attributes (dir, class etc.)
    keywords 5 - invalid attributes (face, width, height, etc.)
    keywords 6 - valid event attributes (onHover, onClick, etc.)
Below is the content of the syntax file as it stands right now:

Code: Select all

; TextPad syntax definitions for HTML
; Copyright (C) 1998-2002, Helios Software Solutions

HTML=1

[Syntax]
Namespace1 = 3
IgnoreCase = Yes
KeyWordLength =
BracketChars =
OperatorChars = -=-
PreprocStart =
HexPrefix = #
SyntaxStart = <
SyntaxEnd = >
CommentStart = !--
CommentEnd = -->
CommentStartAlt =
CommentEndAlt =
SingleComment =
SingleCommentCol =
SingleCommentAlt =
SingleCommentColAlt =
SingleCommentEsc =
StringsSpanLines = Yes
StringStart = "
StringEnd = "
StringAlt = '
StringEsc =
CharStart = &
CharEnd = ;
CharEsc =

;Duplicate primary and secondary keywords
; CODE
; DIR
; FRAME
; HTML
; LABEL
; LINK
; SPAN
; STYLE
; TITLE

[Keywords 1]
!DOCTYPE
A
ABBR
ADDRESS
AREA
ARTICLE
ASIDE
AUDIO
B
BASE
BDI
BDO
BLOCKQUOTE
BODY
BUTTON
CANVAS
CITE
CODE
DEL
DETAILS
DFN
DIALOG
DIV
EM
FIGCAPTION
FIGURE
H1
H2
H3
H4
H5
H6
HEAD
HEADER
HTML
I
IFRAME
ILAYER
IMG
INS
KBD
KEYGEN
LAYER
LEGEND
LINK
MAIN
MAP
MARK
MENU
META
NAV
OBJECT
OUTPUT
P
PARAM
PICTURE
PRE
PROGRESS
Q
RP
RT
RUBY
S
SAMP
SCRIPT
SECTION
SERVER
SMALL
SOUND
SOURCE
STRONG
STYLE
SUB
SUP
SVG
TEMPLATE
TIME
TITLE
TRACK
U
VAR
VIDEO
WBR

[Keywords 2]
BR
CAPTION
COL
COLGROUP
DATA
DATALIST
DD
DL
DT
FIELDSET
FORM
HR
INPUT
LABEL
LI
OL
OPTGROUP
OPTION
SELECT
SPAN
TABLE
TBODY
TD
TEXTAREA
TFOOT
TH
THEAD
TR
UL

[Keywords 3]
ACRONYM
APPLET
BASEFONT
BGSOUND
BIG
BLINK
CENTER
DIR
EMBED
FONT
FRAME
FRAMESET
HEADERS
ISINDEX
KEY
LISTING
MARQUEE
MENUITEM
MULTICOL
NOBR
NOEMBED
NOFRAMES
NOLAYER
NOSCRIPT
PLAINTEXT
SPACER
STRIKE
TT
XMP

[Keywords 4]
accesskey
action
alt
background
balance
behavior
bgproperties
checked
class
classid
clear
code
codebase
codetype
cols
colspan
command
compact
content
context
contextmenu
controls
coords
data
datafld
dataformatas
datasrc
default
direction
disabled
dynsrc
enctype
event
for
hidden
href
hspace
html
http
equiv
icon
id
ismap
label
lang
language
leftmargin
loop
lowsrc
marginheight
marginwidth
maxlength
mayscript
method
methods
multiple
name
nohref
noresize
noshade
nowrap
palette
pluginspage
public
radiogroup
rb
rbc
readonly
rel
rev
rightmargin
rows
rowspan
rp
rt
rtc
rules
scroll
scrollamount
scrolldelay
scrolling
selected
shape
size
span
src
start
style
stylesheet
tabindex
target
text
title
topmargin
truespeed
type
url
urn
usemap
value
volume
vrml
vspace
wrap

[Keywords 5]
align
alink
bgcolor
border
bordercolor
bordercolordark
bordercolorlight
bottommargin
cellpadding
cellspacing
color
face
frame
frameborder
framespacing
height
link
valign
vlink
width

[Keywords 6]
onAbort
onAfterPrint
onBeforePrint
onBeforeUnload
onBlur
onCanPlay
onCanPlayThrough
onChange
onClick
onContextMenu
onCopy
onCueChange
onCut
onDblClick
onDrag
onDragEnd
onDragEnter
onDragLeave
onDragOver
onDragStart
onDrop
onDurationChange
onEmptied
onEnded
onError 
onFocus
onHashChange
onInput
onInvalid
onKeyDown
onKeypress
onKeyUp
onLoad 
onLoadedData
onLoadedMetaData
onLoadStart
onMouseDown
onMouseMove
onMouseOut
onMouseOver
onMouseUp
onMouseWheel
onOffline
onOnline
onPageHide
onPageShow
onPaste
onPause
onPlay
onPlaying
onPopState
onProgress
onRateChange
onReset
onResize
onScroll
onSearch
onSeeked
onSeeking
onSelect
onStalled
onStorage
onSubmit
onSuspend
onTimeUpdate
onToggle
onUnload
onVolumeChange
onWaiting
onWheel
User avatar
AmigoJack
Posts: 502
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: HTML syntax file weirdness

Post by AmigoJack »

and dir occurs in the valid attributes keyword section of the syntax file
But not in what you presented here.

I'm pretty sure TextPad is unable to support semantic syntax highlighting, which would also explain why it's all "keywords" and nothing else.
WayneCa
Posts: 50
Joined: Sat Aug 16, 2014 2:13 am

Re: HTML syntax file weirdness

Post by WayneCa »

AmigoJack wrote:
and dir occurs in the valid attributes keyword section of the syntax file
But not in what you presented here.

I'm pretty sure TextPad is unable to support semantic syntax highlighting, which would also explain why it's all "keywords" and nothing else.
It seems there's truth in the old saying two heads is better than one. All this time I thought I had included dir, when I hadn't. I don't know why I kept seeing it there when it wasn't. I have added it and that has corrected the issue. Thanks for looking at it for me.

Fortunately this doesn't really concern semantics. It's a simple division of words based on category and validity, tags (or elements) as opposed to attributes, and valid as opposed to invalid (deprecated or obsolete). So far it's working well.
User avatar
AmigoJack
Posts: 502
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Oh, I'm glad the culprit is so simple. Don't blame yourself: sometimes one has to write it all down and 2 minutes before you'd hit "submit" to let others read your questions it suddenly unfolds to yourself.

I'm also highly satisfied with the syntax highlighting and see no need to ever be more distinctive - it was great enough to have both PHP and HTML supported. Or HTML and CSS. With very few compromises even that works surprisingly good.
Post Reply