% % file : html.sl % % Original Author : Raikanta Sahu, rsahu@mail.unm.edu % Substantial additions by Jim Knoble. % Modified by John E. Davis for incorporation into JED. %% %% Modified by Michael D Johnson to conform with the standards recommendation %% on capitalization. %% % Modified by Kees Serier % All lower case except for DOCTYPE (like all W3C code), html: 2 3.2 4 XHTML % Definition lists complete, tables, euro symbol and more. % 1 => html_mode wraps, like text_mode % 0 => html_mode doesn't wrap, like no_mode define html_paragraph_separator () { bol_skip_white (); eolp () or ffind_char ('>') or ffind_char ('<'); } % Movement function (JM) %!%+ %\function{html_skip_tag} %\synopsis{html_skip_tag} %\description % skip forward past html tag %!%- define html_skip_tag() { !if (fsearch_char ('>')) return; go_right_1 (); } %!%+ %\function{html_bskip_tag} %\synopsis{html_bskip_tag} %\description % skip backward past html tag %!%- define html_bskip_tag() { () = bsearch_char ('<'); } %!%+ %\function{html_mark_next_tag} %\synopsis{html_mark_next_tag} %\description % mark the next html tag forward %!%- define html_mark_next_tag() { variable taglng = 1; !if (fsearch_char ('>')) return; go_right(taglng); set_mark_cmd (); go_left(taglng); () = find_matching_delimiter (0); } %!%+ %\function{html_mark_prev_tag} %\synopsis{html_mark_prev_tag} %\description % mark the previous html tag %!%- define html_mark_prev_tag() { !if (bsearch_char ('<')) return; set_mark_cmd (); () = find_matching_delimiter(0); go_right_1 (); exchange_point_and_mark(); } % % First define some useful functions % define html_insert_pair_around_region (lfttag, rgttag) { % make sure mark is before point; % 1 => push spot first check_region(1); % put tags on appropriate sides of region, % then return to where we were exchange_point_and_mark(); insert(lfttag); exchange_point_and_mark(); insert(rgttag); pop_spot(); pop_mark_0 (); } define html_insert_move (str) { variable len; variable beg, end; len = is_substr (str, "@"); !if (len) return; len--; if (markp ()) { beg = substr (str, 1, len); end = substr (str, len + 2, strlen (str)); html_insert_pair_around_region (beg, end); return; } push_spot (); insert (str); pop_spot (); go_right (len); del (); } define html_simple_insert (str) { html_insert_move (sprintf ("<%s>@%s>", str, str)); } define html_insert_with_newline (str) { html_insert_move (sprintf ("<%s>\n@%s>\n", str, str)); } define html_insert_with_2newlines (str) { html_insert_move (sprintf ("<%s>\n@\n%s>\n", str, str)); } define html_form () { html_insert_move ("
"); } define html_input () { insert (""); } define html_input_text () { insert (""); } define html_input_password () { insert (""); } define html_input_checkbox () { insert (""); } define html_input_radio () { insert (""); } define html_input_submit () { insert (""); } define html_input_reset () { insert (""); } define html_input_hidden () { insert (""); } define html_select () { html_insert_move (""); } define html_text_area () { html_insert_move (""); } % % Make comment % define html_comment () { html_insert_move (""); } % % insert Horizontal rule TJO % define html_horiz_rule () { insert("\n\n"); } define html_read_key (hlp) { variable key; !if (input_pending (3)) flush (hlp); tolower (getkey ()); } define html_doctype () { variable key2; key2 = html_read_key ("HTML version: 2 3.2 4 Xhtml"); switch (key2) {case '2': insert ("\n");} {case '3': insert ("\n");} {case '4': insert ("\n");} {case 'x' or case 'X': insert ("\n");} { beep (); } } define html_template () { html_doctype (); html_insert_move ("\n\n
\n\n"); }
{ case 'q': html_insert_with_newline ("blockquote"); }
{ case 'r': html_insert_with_newline ("pre"); }
{
beep ();
}
}
define html_keymap_s ()
{
switch (html_read_key ("Address Bold Cite Emph Font Ital Kbd cOde Samp Tt Uline Var"))
{ case 'a': "address"; }
{ case 'b': "b"; }
{ case 'c': "cite"; }
{ case 'e': "em"; }
{ case 'f': "font"; }
{ case 'i': "i"; }
{ case 'k': "kbd"; }
{ case 'o': "code"; }
{ case 's': "samp"; }
{ case 't': "tt"; }
{ case 'u': "u"; }
{ case 'v': "var"; }
{
beep (); return;
}
html_simple_insert (());
}
define html_keymap_t ()
{
switch (html_read_key ("Table Row Header Data"))
{ case 't': html_insert_with_newline ("table"); }
{ case 'r': html_insert_with_newline ("tr"); }
{ case 'h': html_simple_insert ("th"); }
{ case 'd': html_simple_insert ("td"); }
{
beep (); return;
}
}
define html_keymap ()
{
variable key = html_read_key ("Anchors Dfnlists Forms Headings Images Lists Pstyles cStyles Tables");
switch (key)
{ case 2: html_bskip_tag (); } % ^B
{ case 6: html_skip_tag (); } % ^F
{ case 14: html_mark_next_tag (); } % ^N
{ case 16: html_mark_prev_tag (); } % ^P
{ case 'c': html_comment (); }
{ case 'a': html_keymap_a (); }
{ case 'd': html_keymap_d (); }
{ case 'f': html_keymap_f (); }
{ case 'h': html_keymap_h (); }
{ case 'i': html_keymap_i (); }
{ case 'l': html_keymap_l (); }
{ case 'p': html_keymap_p (); }
{ case 's': html_keymap_s (); }
{ case 't': html_keymap_t (); }
{
ungetkey (key);
html_quoted_insert ();
}
flush ("");
}
$1 = "html";
!if (keymap_p ($1)) make_keymap ($1);
undefinekey (_Reserved_Key_Prefix, $1);
definekey("html_keymap", _Reserved_Key_Prefix, $1);
undefinekey ("\e;", $1);
definekey ("html_comment", "\e;", $1);
definekey ("html_quoted_insert", "`", $1);
definekey("html_par_insert", "\e^M", $1); % Neater paragraph insert (MDJ 04/06/98)
create_syntax_table ($1);
define_syntax ("<", ">", '(', $1); % make these guys blink match
define_syntax ("<>", '<', $1);
define_syntax ("", '%', $1);
define_syntax ("A-Za-z&", 'w', $1);
define_syntax ('#', '#', $1);
#ifdef HAS_DFA_SYNTAX
% The highlighting copes with comments, "ð" type things, and , ...
)
% ^CF... Forms ()
% ^CH... Headings, document type, etc.
% ^CI... Images
% ^CL... Lists (...
)
% ^CP... Paragraph styles, etc. (
,
, , etc.)
% ^CS... Character styles (, , , , etc.)
% ^CT... Tables
% Additionally, some special movement commands and miscellaneous
% characters are defined:
% ^C^B skip to beginning of prior HTML tag
% ^C^F skip to end of next HTML tag
% ^C^N mark next HTML tag from '<' to '>'
% ^C^P mark prior HTML tag from '<' to '>'
% ^C& insert HTML text for '&'
% ^C> insert HTML text for '>'
% ^C< insert HMTL text for '<'
% ^C
'
% ^C