# HTML mode for StrongED
# Original version written by Andrew Black  <andrew@bach.demon.co.uk>
# Addittional work by :
# GV    Guttorm Vik <guttorm.vik@eunet.no>
# PL    Philip Ludlam <pludlam@hotmail.com>

#----------------------------------------------------------------------
# 25.07.98 GV Commented out the ^F4 key definition on the 'escape
#             brackets' fn. It overrode the global fn to set mark 4
# 25.07.98 GV Changed key from F3 to F10 on the 'save & render' fn
#             to get in line with other modes, and to not override the
#             global function GotoMark(3)
# 10.08.98 GV Removed the shift-ESC key binding to change to BaseMode,
#             as that function is now defined by BaseMode (albeit on ctrl-shift-ESC)
# 10.08.98 GV Have changed all tags occuring here, to follow a consistent
#             case-scheme; All tags except <HTML>, <BODY> and <Hx> are now lower case.
# 10.08.98 GV Have changed the way most of the "add xxx" functions work; No longer use Replace
# 10.08.98 GV Shortcuts are now prefixed with `` instead of '' (actually, I've kept the old ones too)
# 10.08.98 GV Merged in the following changes from Philip Ludlam:
#          PL Added HexPrefix
#          PL Made both <xxx and <xxx> reserved words, so that when a tag
#             has no extra parameters, the ending ">" is coloured as part of it.
#          PL Moved <title> to group6 and <hx> to group 1
#          PL Removed all 'attributes' from the reserved words lists,
#             since they can't be coloured reliably (ie 'name=xx' would
#             be coloured even if it was part of a tag where 'name' isn't
#             an allowed attribute
#          PL Added two keystrokes to insert date; ctrl-D and ctr-shift-D
#          PL Added lots of shortcuts
# 04.11.98 GV Added _SpellIgnore
# 13.03.99 GV Had commented out the adjust version of the 'anchor' function.
#             Have now put it back, but not the F9 key binding.
# 16.03.99 GV Set HelpPath to go through my own HTML manual first
#----------------------------------------------------------------------

HelpPath	StrongHTML,

SyntaxOptions
	SingleQuote	No
	DoubleQuote	Yes
	QuoteQuote	Yes
	SplitString	No
	HexPrefix	#
End
SyntaxComment 
	Type		Multiline
	StartWith	<!--
	EndWith		-->
End 

# Id's are used to try and pick up all tags that don't have their
# own colouring.   It also picks out start of tags such as
# <A ( as part of <A HREF=""></A> )
# Of course it will also pick out non-tags such as <ANDREW>

ID_FirstChar	A-Za-z
ID_Middle	A-Za-z0-9
#ID_FirstChar	<
#ID_Middle	/A-Za-z_0-9
#ID_LastChar	A-Za-z_0-9>

#--- The 'outer level' tags + headings

SyntaxWords Group1 EndAlways nocase
	<address> </address> <address 
	<html> </html> <html
	<head> </head> <head
	<body> </body> <body 
	<h1> </h1> <h1 
	<h2> </h2> <h2 
	<h3> </h3> <h3 
	<h4> </h4> <h4 
	<h5> </h5> <h5 
	<h6> </h6> <h6 
End

#--- List, form and table

SyntaxWords Group2 EndAlways nocase
	<ul> </ul> <ul
	<dl> </dl> <dl
	<ol> </ol> <ol
	<form> </form> <form 
	<table> </table> <table
	<thead> </thead <thead
	<tfoot> </tfoot> <tfoot
	<map> </map> <map
End

#--- List, form and table *entries*

SyntaxWords Group3 EndAlways nocase
	<li> </li> <li
	<dt> </dt> <dt
	<dd> </dd> <dd
	<input <select <option> </option>
	<td> </td> <td
	<tr> </tr> <tr
	<th> </th> <th
End

#--- Link and object tags

SyntaxWords Group4 EndAlways nocase
	<a  </a>
	<area
	<embed </embed>
	<img </img>
	<object </object>
End

#--- Physical Styles

SyntaxWords Group5 EndAlways nocase
	<i> </i>
	<b> </b>
	<u> </u>
	<em> </em> <em
	<strong> </strong> <strong
	<sup> </sup> <sup
	<sub> </sub> <sub
	<font> </font> <font
End

#--- Tags that can be in the <head> section

SyntaxWords Group6 EndAlways nocase
	<frame
	<frameset> </frameset> <frameset
	<noframes> </noframes> <noframes
	<meta
	<base
	<title> </title> <title
End

#--- Formatting

SyntaxWords Group7 EndAlways nocase
	<pre> </pre> <tt> </tt>
	<p> </p> <p
	<br> </br> <br

End


#SyntaxWords Group6 EndOfID nocase
#	"<!date src=" "<!size src=" "<!expire date=" <!/expire>
#	<!MakeNew> <!New> <!WasNew> <!NewInserted= <!Update
#End

#----------------------------------------------------------------------


Search
	heading1	"<h"  AlphaNum   ">" @0 *  "</" @9
	heading		"<h"  AlphaNum   ">" @0 * @9 "</"
	tag		"<" ["\\"] { AlphaNum | "/" }+  ">"
	_MarkWord	tag  | {AlphaNum}+   | {Punct}+
	_SpellIgnore	("<" ? {'~<>'}+ ">") | "&nbsp;"

	quote		"\""
	anchor		"<a" {iswhite}+ * "href" {iswhite} "="  {iswhite}  quote @0 ** quote  ">" @9
	anchor1		"<a" {iswhite}+ * "href" {iswhite} "="  {iswhite}  quote @0
	selected_line	{any}+

# match everything sensible but not , 
#	textstr	 { AlphaNum | '\' _\-' }+

	url		{AlphaNum}+ ":/" { ["~"] alphanum | '/_.' }+
	url_text	@1 url @2 {iswhite} @3 {.} @4
	text		@1 @2 @3 {.} @4
	hotlist		url_text
# removing tag
	anch_st		"<a" {iswhite}+ * quote
	anch_end	quote  {iswhite} ">"
	remove_tag	anch_st | anch_end | tag

End

Replace
	h1		"<H1>" @@ "</H1>"
	h2		"<H2>" @@ "</H2>"
	h3		"<H3>" @@  "</H3>" 
	h4		"<H4>" @@  "</H4>"
#misc
	ital		"<i>" @@ "</i>"
	center		"<center>" @@  "</center>"
	red		"<font color=#ff0000>" @@ "</font>"
	blue		"<font color=#3a00aa>" @@ "</font>"
	green		"<font color=#008000>" @@ "</font>"
	bold		"<b>" @@ "</b>"
	typewriter		"<tt>" @@ "</tt>"
	strong		"<strong>" @@ "</strong>"
	emphasis	"<em>" @@  "</em>"
	bigger		"<big>" @@  "</big>"
	smaller		"<small>" @@  "</small>"
	underline	"<u>" @@  "</u>"

	hotlist_r  "<a href=\"" @12  "\">" @34  "</a>"
#	anch     "<A href=\"" @@  "\"> </A>"
End

ClickList Select2
	http	BroadcastURL("<tmp$word>")
END

ClickList Adjust2
	http	BroadcastURL("<tmp$word>")

END

KeyList
	^D	1	"Last updated " DateAndTime ("%we %dy%st %mo %ce%yr")
	^D	1	DateAndTime ("%we %dy%st of %mo %ce%yr")
End

Functions

	Icon	lof
	Select 	ListOfFound (heading1,All,Align,noLine,NoCase)
	Menu	List of headings
	Help	Select - list of headings|MAdjust - list of Anchors

	Adjust	ListOfFound (anchor,All,align,noLine,NoCase)

	Key	F10
	Menu	Save & Render      F10
	Icon	run
	Select	SetTmp() SaveDClick ("<tmp$path>.<tmp$leaf>")
	Help	Click to save text and launch viewer (F3)

	Menu	Create <H1>
	Icon	ab_h1
	Select	NoIndent() GotoBlock_Start() "<H1>" GotoBlock_End() "</H1>" BlockClear()
#	Select	NoIndent() Replace( selected_line,h1 , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text into H1

	Menu	Create <H2>
	Icon	ab_h2
	Select	NoIndent() GotoBlock_Start() "<H2>" GotoBlock_End() "</H2>" BlockClear()
#	Select	Replace( selected_line,h2 , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text into H2
	
	Menu	Create <H3>
	Icon	ab_h3
	Select	NoIndent() GotoBlock_Start() "<H3>" GotoBlock_End() "</H3>" BlockClear()
#	Select	Replace( selected_line,h3 , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text into H3

	Menu	Create <H4>
	Icon	ab_h4
	Select	NoIndent() GotoBlock_Start() "<H4>" GotoBlock_End() "</H4>" BlockClear()
#	Select	Replace( selected_line,h4 , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text into H4

	Menu	Add italic
	Icon	ab_italic
	Select	NoIndent() GotoBlock_Start() "<em>" GotoBlock_End() "</em>" BlockClear()
#	Select	Replace( selected_line,ital , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text italic

	Adjust	NoIndent() GotoBlock_Start() "<i>" GotoBlock_End() "</i>" BlockClear()


	Menu	Add bold
	Icon	ab_bold
	Select	NoIndent() GotoBlock_Start() "<strong>" GotoBlock_End() "</strong>" BlockClear()
#	Select	Replace( selected_line,bold , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text bold 

	Adjust	NoIndent() GotoBlock_Start() "<bold>" GotoBlock_End() "</bold>" BlockClear()

	Menu	Add typewriter
	Icon	ab_tt
	Select	NoIndent() GotoBlock_Start() "<tt>" GotoBlock_End() "</tt>" BlockClear()
#	Select	Replace( selected_line,typewriter , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text typewriter 

	Menu	Underline
#	Icon	ab_ul
	Select	NoIndent() GotoBlock_Start() "<u>" GotoBlock_End() "</u>" BlockClear()
#	Select	Replace( selected_line,underline , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text underlined

	Menu	Make bigger
	Select	NoIndent() GotoBlock_Start() "<big>" GotoBlock_End() "</big>" BlockClear()
#	Select	Replace( selected_line,bigger , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text bigger

	Menu	Make smaller
	Select	NoIndent() GotoBlock_Start() "<small>" GotoBlock_End() "</small>" BlockClear()
#	Select	Replace( selected_line,smaller , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text smaller

	Menu	Make red
	Icon	ab_red
	Select	NoIndent() GotoBlock_Start() "<font color=red>" GotoBlock_End() "</font>" BlockClear()
#	Select	Replace( selected_line,red , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text red

	Menu	Make green
	Icon	ab_green
	Select	NoIndent() GotoBlock_Start() "<font color=green>" GotoBlock_End() "</font>" BlockClear()
#	Select	Replace( selected_line,green , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text green

	Menu	Make blue
	Icon	ab_blue
	Select	NoIndent() GotoBlock_Start() "<font color=blue>" GotoBlock_End() "</font>" BlockClear()
#	Select	Replace( selected_line,blue , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text blue

	Menu	Make <center>
	Icon	ab_center
	Select	NoIndent() GotoBlock_Start() "<center>" GotoBlock_End() "</center>" BlockClear()
#	Select	Replace( selected_line,center , block , noline,nocase) GotoBlock_Start() BlockClear()
	Help	Makes selected text centred

	Menu	Remove tags
	Select	Replace( remove_tag,"" , block , noline,nocase)
	Help	Removes all tags from selected text |M (URL of anchors remain)

	Menu	Escape brackets
#	Key	^F4
	Select	Replace ("<","&#160;", block ) Replace (">","&#162;", block )
	Help	replaces  < with escape |M to embed an HTML example in HTML file

	Menu	Load selected file
	Help	Click to load the HTML file under cursor.
	Select	SetTmp() LoadOne ("<tmp$path>.<tmp$word>","<tmp$word>")
	Help	Hhtml_lod

#        Menu	Insert Anchor
	Icon	ab_anchor
	  Select	"<a href=\"" push() "\"> </a>" pop()
	  Help		Select inserts anchor|M Adjust Convert url + text to anchor

#	  Key f9
	  Adjust	Replace (hotlist,hotlist_r, block )

	Icon		lof
	 Select 	ListOfFound (heading1,All,Align,noLine,NoCase)
	 Menu		List Anchors
	 Help		Select - list of headings|MAdjust - list of Anchors

	 Adjust		ListOfFound (anchor,All,align,noLine,NoCase)
End


Shortcuts
# start of document
	``f	<HTML>\n<head>\n  <title>\@</title>\n</HEAD>\n\n<BODY>\n<H1>\@</H1>\n<hr>\n<address>My name </address>\n</BODY></HTML>
# lists
	``ul	<ul>\n\i  <li>\@\n\i</ul>
	``ol	<ol>\n\i  <li>\@\n\i</ol>
	``li	<li>\@\n\i<li>
	<li>+	<li>\@</li>\n\i<li>\@

	``dl	<dl>\n\i\t\@\n</dl>\@
	``dt	<dt>\@</dt>\n\i\t<dd>\@</dd>\@

# anchors
	``ai	<a href="\@">\@</A>
	``ae	<a href="http://\@/\@">\@</A>
	``ha	<H1><a name="\@">\@</a></H1>

# heads
	``1	<H1>\@</H1>\n
	``2	<H2>\@</H2>\n
	``3	<H3>\@</H3>\n
	``4	<H4>\@</H4>\n  
	``5	<H5>\@</H5>\n
	``6	<H6>\@</H6>\n


# comment :
	``!	<!-- \@ -->

# tables

	``tab	<table\@>\n\i\t\@\n</table>\@\n
	``tr	<tr\@>\n\i\t\@\n</tr>\n
	``td	<td\@>\n\i\t\@\n</td>\n
	``th	<th\@>\n\i\t\@\n</th>\n
	``tf	<tf\@>\n\i\t\@\n</tf>\n

# misc
	``i	<i>\@</i>
	``b	<b>\@</b>
	``m	<img src="\@" alt="[\@]">
	``pp	<p>\@</p>

# the same shortcuts as above, but now with '' instead of ``.
# `` is what I'm trying to use as "standard", but since this mode
# came with '' shortcuts originally, I'm keeping them too.

	''f	<HTML>\n<head>\n  <title>\@</title>\n</head>\n\n<BODY>\n<H1>\@</H1>\n\@\n<hr>\n<address>My name </address>\n</BODY></HTML>
	''ul	<ul>\n\i  <li>\@\n\i</ul>
	''ol	<ol>\n\i  <li>\@\n\i</ol>
	''li	<li>\@\n\i<li>
	''dl	<dl>\n\i\t\@\n</dl>\@
	''dt	<dt>\@</dt>\n\i\t<dd>\@</dd>\@
	''ai	<a href="\@">\@</a>
	''ae	<a href="http://\@/\@">\@</a>
	''ha	<H1><a name="\@">\@</a></H1>
	''1	<H1>\@</H1>\n
	''2	<H2>\@</H2>\n
	''3	<H3>\@</H3>\n
	''4	<H4>\@</H4>\n  
	''5	<H5>\@</H5>\n
	''6	<H6>\@</H6>\n
	''!	<!-- \@ -->
	''tab	<table\@>\n\i\t\@\n</table>\@\n
	''tr	<tr\@>\n\i\t\@\n</tr>\n
	''td	<td\@>\n\i\t\@\n</td>\n
	''th	<th\@>\n\i\t\@\n</th>\n
	''tf	<tf\@>\n\i\t\@\n</tf>\n
	''i	<i>\@</i>
	''b	<b>\@</b>
	''m	<img src="\@" alt="[\@]">
	''pp	<p>\@</p>

# character shortcuts

		&AElig;
		&Aacute;
		&Acirc;
		&Agrave;
		&Aring;
		&Atilde;
		&Auml;
		&Ccedil;
		&Cedilla;
		&Eth;
		&Eacute;
		&Ecirc;
		&Egrave;
		&Euml;
		&Iacute;
		&Icirc;
		&Igrave;
		&Iuml;
		&Ntilde;
		&Oacute;
		&Ocirc;
		&Ograve;
		&Oslash;
		&Otilde;
		&Ouml;
		&Thorn;
		&Uacute;
		&Ucirc;
		&Ugrave;
		&Uuml;
		&Yacute;

		&aacute;
		&acute;
		&acirc;
		&aelig;
		&agrave;
		&aring;
		&atilde;
		&auml;
		&brvbar;
		&ccedil;
		&cent;
		&copy;
		&curren;
		&degree;
		&die;
		&divide;
		&eacute;
		&ecirc;
		&egrave;
		&eth;
		&euml;
#	<><	&fish;
		&frac14;
		&frac12;
		&frac34;
		&iacute;
		&icirc;
		&iexcl;
		&igrave;
		&iquest;
		&iuml;
		&laquo;
		&macron;
		&mdash;
		&ndash;
		&micro;
		&middot;
		&nbsp;
		&not;
		&ntilde;
		&oacute;
		&ocirc;
		&ograve;
		&ordf;
		&ordm;
		&oslash;
		&otilde;
		&ouml;
		&para;
		&plusmn;
		&pound;
		&raquo;
		&reg;
		&sect;
		&shy;
		&sup1;
		&sup2;
		&sup3;
		&szlig;
		&times;
		&trade;
		&ugrave;
		&uacute;
		&ucirc;
		&uml;
		&uuml;
		&yacute;
		&yen;
		&thorn;
		&yuml;

# HTML 4.0 quotes
		&ldquo;
		&rdquo;
		&lsquo;
		&rsquo;

#Common characters
	''>	&lt;
	''<	&rt;
	''&	&amp;
	(C)	&copy;
	(c)	&copy;

End
