% % 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. % 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) %!% skip forward past html tag define html_skip_tag() { !if (fsearch_char ('>')) return; go_right_1 (); } %!% skip backward past html tag define html_bskip_tag() { () = bsearch_char ('<'); } %!% mark the next html tag forward define html_mark_next_tag() { variable taglng = 1; !if (fsearch_char ('>')) return; go_right(taglng); call("set_mark_cmd"); go_left(taglng); () = find_matching_delimiter (0); } %!% mark the previous html tag define html_mark_prev_tag() { !if (bsearch_char ('<')) return; call("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, 2)); } define html_insert_with_newline (str) { html_insert_move (Sprintf ("<%s>\n@\n%s>\n", str, str, 2)); } define html_template () { insert ("\n"); html_insert_move ("\n\n
\n\n"); } { case 'q': html_insert_with_newline ("blockquote"); } { case 'r': html_insert_with_newline ("pre"); } { pop(); beep (); } } define html_keymap_s () { switch (html_read_key ("Address Bold Cite Emph Ital Kbd cOde Samp Tt Uline Var")) { case 'a': "address"; } { case 'b': "b"; } { case 'c': "cite"; } { case 'e': "em"; } { case 'i': "i"; } { case 'k': "kbd"; } { case 'o': "code"; } { case 's': "samp"; } { case 't': "tt"; } { case 'u': "u"; } { case 'v': "var"; } { pop (); beep (); return; } html_simple_insert (()); } define html_keymap () { switch (html_read_key ("Anchors Dfnlists Forms Headings Images Lists Pstyles cStyles ?help")) { case 2: html_bskip_tag (); } % ^B { case 6: html_skip_tag (); } % ^F { case 14: html_mark_next_tag (); } % ^N { case 14: 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 (); } { ungetkey (()); html_quoted_insert (); } flush (""); } $1 = "html"; !if (keymap_p ($1)) make_keymap ($1); undefinekey ("^C", $1); definekey("html_keymap", "^C", $1); undefinekey ("\e;", $1); definekey ("html_comment", "\e;", $1); definekey ("html_quoted_insert", "`", $1); 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); () = define_keywords ($1, "><", 3); () = define_keywords ($1, "Ð&ð", 4); () = define_keywords ($1, strcat ( "ÄËÏÖÜ", "äëï ö"üÿ" ), 5); () = define_keywords ($1, strcat ( "ÆÂÅÊÎÔÞÛâ", "æåêîôßþû" ), 6); () = define_keywords ($1, strncat ( "ÁÀÃÇÉÈÍÌ", "ÑÓÒØÕÚÙÝ", "áàãçéèíì", "ñóòøõúùý", 4), 7); %!% Prototype: Void html_mode (); %!% @html_mode@ is a mode designed for editing HTML files. %!% If a region is defined (i.e., if a mark is set), many HTML %!% tags will insert around the region, e.g. '' and ''. %!% %!% if the variable 'HTMLModeWraps' is set to 1, this mode will wrap %!% (like @text_mode@ does); otherwise, this mode won't wrap (like @no_mode@). %!% %!% Keybindings begin with ^C and are grouped according to function: %!% ^CA... Anchors (...) %!% ^CD... Definition lists (
,
,