15dfecf96Smrg;; 25dfecf96Smrg;; Copyright (c) 2002 by The XFree86 Project, Inc. 35dfecf96Smrg;; 45dfecf96Smrg;; Permission is hereby granted, free of charge, to any person obtaining a 55dfecf96Smrg;; copy of this software and associated documentation files (the "Software"), 65dfecf96Smrg;; to deal in the Software without restriction, including without limitation 75dfecf96Smrg;; the rights to use, copy, modify, merge, publish, distribute, sublicense, 85dfecf96Smrg;; and/or sell copies of the Software, and to permit persons to whom the 95dfecf96Smrg;; Software is furnished to do so, subject to the following conditions: 105dfecf96Smrg;; 115dfecf96Smrg;; The above copyright notice and this permission notice shall be included in 125dfecf96Smrg;; all copies or substantial portions of the Software. 135dfecf96Smrg;; 145dfecf96Smrg;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 155dfecf96Smrg;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 165dfecf96Smrg;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 175dfecf96Smrg;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 185dfecf96Smrg;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 195dfecf96Smrg;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 205dfecf96Smrg;; SOFTWARE. 215dfecf96Smrg;; 225dfecf96Smrg;; Except as contained in this notice, the name of the XFree86 Project shall 235dfecf96Smrg;; not be used in advertising or otherwise to promote the sale, use or other 245dfecf96Smrg;; dealings in this Software without prior written authorization from the 255dfecf96Smrg;; XFree86 Project. 265dfecf96Smrg;; 275dfecf96Smrg;; Author: Paulo César Pereira de Andrade 285dfecf96Smrg;; 295dfecf96Smrg;; 305dfecf96Smrg;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/html.lsp,v 1.2 2002/09/22 18:41:27 paulo Exp $ 315dfecf96Smrg;; 325dfecf96Smrg 335dfecf96Smrg(require "syntax") 345dfecf96Smrg(in-package "XEDIT") 355dfecf96Smrg 365dfecf96Smrg#| 375dfecf96Smrg This is not a validation tool for html. 385dfecf96Smrg 395dfecf96Smrg It is possible to, using macros generate all combinations of text attributes, 405dfecf96Smrg to properly handle <b>...<i>...</i>...</b> etc, as well as generating macros 415dfecf96Smrg to automatically closing tags, but for now this file was built to work as an 425dfecf96Smrg experience with the syntax highlight code. 435dfecf96Smrg|# 445dfecf96Smrg 455dfecf96Smrg(defsynprop *prop-html-default* 465dfecf96Smrg "default" 475dfecf96Smrg :font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1" 485dfecf96Smrg :foreground "Gray10") 495dfecf96Smrg 505dfecf96Smrg(defsynprop *prop-html-bold* 515dfecf96Smrg "bold" 525dfecf96Smrg :font "-*-lucida-bold-r-*-*-14-*-*-*-*-*-*-1" 535dfecf96Smrg :foreground "Gray15") 545dfecf96Smrg 555dfecf96Smrg(defsynprop *prop-html-italic* 565dfecf96Smrg "italic" 575dfecf96Smrg :font "-*-lucida-medium-i-*-*-14-*-*-*-*-*-*-1" 585dfecf96Smrg :foreground "Gray10") 595dfecf96Smrg 605dfecf96Smrg(defsynprop *prop-html-pre* 615dfecf96Smrg "pre" 625dfecf96Smrg :font "-*-courier-medium-r-*-*-14-*-*-*-*-*-*-1" 635dfecf96Smrg :foreground "Gray10") 645dfecf96Smrg 655dfecf96Smrg(defsynprop *prop-html-link* 665dfecf96Smrg "link" 675dfecf96Smrg :font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1" 685dfecf96Smrg :foreground "Blue" 695dfecf96Smrg :underline "t") 705dfecf96Smrg 715dfecf96Smrg(defsynprop *prop-html-small* 725dfecf96Smrg "small" 735dfecf96Smrg :font "-*-lucida-medium-r-*-*-10-*-*-*-*-*-*-1" 745dfecf96Smrg :foreground "Gray10") 755dfecf96Smrg 765dfecf96Smrg(defsynprop *prop-html-big* 775dfecf96Smrg "big" 785dfecf96Smrg :font "-*-lucida-medium-r-*-*-20-*-*-*-*-*-*-1" 795dfecf96Smrg :foreground "Gray15") 805dfecf96Smrg 815dfecf96Smrg(defsynprop *prop-html-name* 825dfecf96Smrg "name" 835dfecf96Smrg :font "-*-lucida-bold-r-*-*-14-*-*-*-*-*-*-1" 845dfecf96Smrg :foreground "Black" 855dfecf96Smrg :background "rgb:e/f/e") 865dfecf96Smrg 875dfecf96Smrg(defsynprop *prop-html-h1* 885dfecf96Smrg "h1" 895dfecf96Smrg :font "-*-lucida-bold-r-*-*-20-*-*-*-*-*-*-1" 905dfecf96Smrg :foreground "Gray15") 915dfecf96Smrg 925dfecf96Smrg(defsynprop *prop-html-h2* 935dfecf96Smrg "h2" 945dfecf96Smrg :font "-*-lucida-bold-r-*-*-17-*-*-*-*-*-*-1" 955dfecf96Smrg :foreground "Gray15") 965dfecf96Smrg 975dfecf96Smrg(defsynprop *prop-html-h4* 985dfecf96Smrg "h4" 995dfecf96Smrg :font "-*-lucida-bold-r-*-*-12-*-*-*-*-*-*-1" 1005dfecf96Smrg :foreground "Gray15") 1015dfecf96Smrg 1025dfecf96Smrg(defsynprop *prop-html-h5* 1035dfecf96Smrg "h5" 1045dfecf96Smrg :font "-*-lucida-bold-r-*-*-10-*-*-*-*-*-*-1" 1055dfecf96Smrg :foreground "Gray15") 1065dfecf96Smrg 1075dfecf96Smrg(defsynprop *prop-html-li* 1085dfecf96Smrg "li" 1095dfecf96Smrg :font "-*-lucida-bold-r-*-*-8-*-*-*-*-*-*-1" 1105dfecf96Smrg :foreground "rgb:0/5/0" 1115dfecf96Smrg :underline t) 1125dfecf96Smrg 1135dfecf96Smrg(defsynprop *prop-html-hr* 1145dfecf96Smrg "hr" 1155dfecf96Smrg :font "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-1" 1165dfecf96Smrg :foreground "rgb:0/5/0" 1175dfecf96Smrg :overstrike t) 1185dfecf96Smrg 1195dfecf96Smrg(defsynprop *prop-html-title* 1205dfecf96Smrg "title" 1215dfecf96Smrg :font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1" 1225dfecf96Smrg :foreground "Red3" 1235dfecf96Smrg :underline "t") 1245dfecf96Smrg 1255dfecf96Smrg(defsynprop *prop-html-tag* 1265dfecf96Smrg "tag" 1275dfecf96Smrg :font "-*-courier-medium-r-*-*-10-*-*-*-*-*-*-1" 1285dfecf96Smrg :foreground "green4") 1295dfecf96Smrg 1305dfecf96Smrg(defsynprop *prop-html-string* 1315dfecf96Smrg "string" 1325dfecf96Smrg :font "-*-lucida-medium-r-*-*-10-*-*-*-*-*-*-1" 1335dfecf96Smrg :foreground "RoyalBlue2") 1345dfecf96Smrg 1355dfecf96Smrg(defsynprop *prop-html-comment* 1365dfecf96Smrg "comment" 1375dfecf96Smrg :font "-*-courier-medium-o-*-*-10-*-*-*-*-*-*-1" 1385dfecf96Smrg :foreground "SlateBlue3") 1395dfecf96Smrg 1405dfecf96Smrg(defsynprop *prop-html-entity* 1415dfecf96Smrg "entity" 1425dfecf96Smrg :font "-*-lucida-medium-r-*-*-12-*-*-*-*-*-*-1" 1435dfecf96Smrg :foreground "Red4") 1445dfecf96Smrg 1455dfecf96Smrg(defsynprop *prop-html-unknown* 1465dfecf96Smrg "unknown" 1475dfecf96Smrg :font "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-1" 1485dfecf96Smrg :foreground "yellow" 1495dfecf96Smrg :background "red") 1505dfecf96Smrg 1515dfecf96Smrg(defmacro html-syntoken (name) 1525dfecf96Smrg `(syntoken (string-concat "<" ,name "\\>") 1535dfecf96Smrg :icase t :contained t 1545dfecf96Smrg :begin (intern (string-concat ,name "$") 'keyword))) 1555dfecf96Smrg(defmacro html-syntable (name property) 1565dfecf96Smrg `(let 1575dfecf96Smrg ((label (intern (string-concat ,name "$") 'keyword)) 1585dfecf96Smrg (nested-label (intern (string (gensym)) 'keyword))) 1595dfecf96Smrg (syntable label *prop-html-tag* nil 1605dfecf96Smrg (synaugment :generic-tag) 1615dfecf96Smrg (syntoken ">" :nospec t :property *prop-html-tag* :begin nested-label) 1625dfecf96Smrg (syntable nested-label ,property nil 1635dfecf96Smrg (syntoken (string-concat "</" ,name ">") 1645dfecf96Smrg :icase t :nospec t :property *prop-html-tag* :switch -2) 1655dfecf96Smrg (syntoken (string-concat "</" ,name "\\s*$") 1665dfecf96Smrg :icase t :contained t :begin :continued-end-tag) 1675dfecf96Smrg (synaugment :main))))) 1685dfecf96Smrg 1695dfecf96Smrg 1705dfecf96Smrg(defsyntax *html-mode* :main *prop-html-default* nil nil 1715dfecf96Smrg (syntoken "<!--" :nospec t :contained t :begin :comment) 1725dfecf96Smrg (syntable :comment *prop-html-comment* nil 1735dfecf96Smrg (syntoken "-->" :nospec t :switch -1)) 1745dfecf96Smrg (syntoken "&([a-zA-Z0-9_.-]+|#\\x\\x?);?" :property *prop-html-entity*) 1755dfecf96Smrg (syntoken "<li>" :nospec t :icase t :property *prop-html-li*) 1765dfecf96Smrg (syntoken "<hr>" :nospec t :icase t :property *prop-html-hr*) 1775dfecf96Smrg 1785dfecf96Smrg (syntoken "<img\\>" :icase t :contained t :begin :tag) 1795dfecf96Smrg (syntoken "<(p|br)>" :icase t :property *prop-html-tag*) 1805dfecf96Smrg 1815dfecf96Smrg ;; If in the toplevel, unbalanced! 1825dfecf96Smrg ;; XXX When adding new nested tables, don't forget to update this pattern. 1835dfecf96Smrg (syntoken 1845dfecf96Smrg (string-concat 1855dfecf96Smrg "</(" 1865dfecf96Smrg "b|strong|i|em|address|pre|code|tt|small|big|a|span|div|" 1875dfecf96Smrg "h1|h2|h3|h4|h5|title|font|ol|ul|dl|dt|dd|menu" 1885dfecf96Smrg ")\\>") 1895dfecf96Smrg :icase t :property *prop-html-unknown* :begin :unbalanced) 1905dfecf96Smrg (syntable :unbalanced *prop-html-unknown* nil 1915dfecf96Smrg (syntoken ">" :nospec t :switch :main) 1925dfecf96Smrg (synaugment :generic-tag) 1935dfecf96Smrg ) 1945dfecf96Smrg 1955dfecf96Smrg #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 1965dfecf96Smrg ;; XXX ONLY add a rule for "html", "head" and "body" if you want to do a 1975dfecf96Smrg ;; more complete check for common errors. If you add those rules, it will 1985dfecf96Smrg ;; reparse the entire file at every character typed (unless there are 1995dfecf96Smrg ;; errors in which case the parser resets the state). 2005dfecf96Smrg ;; For visualization only that would be OK... 2015dfecf96Smrg ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||# 2025dfecf96Smrg 2035dfecf96Smrg (html-syntoken "b") 2045dfecf96Smrg (html-syntable "b" *prop-html-bold*) 2055dfecf96Smrg (html-syntoken "strong") 2065dfecf96Smrg (html-syntable "strong" *prop-html-bold*) 2075dfecf96Smrg 2085dfecf96Smrg (html-syntoken "i") 2095dfecf96Smrg (html-syntable "i" *prop-html-italic*) 2105dfecf96Smrg (html-syntoken "em") 2115dfecf96Smrg (html-syntable "em" *prop-html-italic*) 2125dfecf96Smrg (html-syntoken "address") 2135dfecf96Smrg (html-syntable "address" *prop-html-italic*) 2145dfecf96Smrg 2155dfecf96Smrg (html-syntoken "pre") 2165dfecf96Smrg (html-syntable "pre" *prop-html-pre*) 2175dfecf96Smrg (html-syntoken "code") 2185dfecf96Smrg (html-syntable "code" *prop-html-pre*) 2195dfecf96Smrg (html-syntoken "tt") 2205dfecf96Smrg (html-syntable "tt" *prop-html-pre*) 2215dfecf96Smrg 2225dfecf96Smrg (html-syntoken "small") 2235dfecf96Smrg (html-syntable "small" *prop-html-small*) 2245dfecf96Smrg 2255dfecf96Smrg (html-syntoken "big") 2265dfecf96Smrg (html-syntable "big" *prop-html-big*) 2275dfecf96Smrg 2285dfecf96Smrg ;; Cannot hack html-syntoken and html-syntable to handle this, 2295dfecf96Smrg ;; as the option to <a may be in the next line. 2305dfecf96Smrg (syntoken "<a\\>" :icase t :contained t :begin :a) 2315dfecf96Smrg (syntable :a *prop-html-tag* nil 2325dfecf96Smrg ;; Tag is open 2335dfecf96Smrg (syntoken "\\<href\\>" :icase t :begin :a-href) 2345dfecf96Smrg (syntoken "\\<name\\>" :icase t :begin :a-name) 2355dfecf96Smrg (syntoken "<" :nospec t :property *prop-html-unknown* :switch -2) 2365dfecf96Smrg (synaugment :generic-tag) 2375dfecf96Smrg (syntoken ">" :nospec t :begin :a-generic-text) 2385dfecf96Smrg (syntable :a-href *prop-html-tag* nil 2395dfecf96Smrg (syntoken ">" :nospec t :begin :a-href-text) 2405dfecf96Smrg (synaugment :generic-tag) 2415dfecf96Smrg (syntable :a-href-text *prop-html-link* nil 2425dfecf96Smrg (syntoken "</a>" 2435dfecf96Smrg :icase t :nospec t :property *prop-html-tag* :switch -3) 2445dfecf96Smrg (syntoken "</a\\s*$" :icase t :begin :continued-nested-end-tag) 2455dfecf96Smrg (synaugment :main) 2465dfecf96Smrg ) 2475dfecf96Smrg ) 2485dfecf96Smrg (syntable :a-name *prop-html-tag* nil 2495dfecf96Smrg (syntoken ">" :nospec t :begin :a-name-text) 2505dfecf96Smrg (synaugment :generic-tag) 2515dfecf96Smrg (syntable :a-name-text *prop-html-name* nil 2525dfecf96Smrg (syntoken "</a>" 2535dfecf96Smrg :icase t :nospec t :property *prop-html-tag* :switch -3) 2545dfecf96Smrg (syntoken "</a\\s*$" :icase t :begin :continued-nested-end-tag) 2555dfecf96Smrg (synaugment :main) 2565dfecf96Smrg ) 2575dfecf96Smrg ) 2585dfecf96Smrg (syntable :a-generic-text nil nil 2595dfecf96Smrg (syntoken "</a>" 2605dfecf96Smrg :icase t :nospec t :property *prop-html-tag* :switch -2) 2615dfecf96Smrg (syntoken "<a/\\s$" :icase t :begin :continued-end-tag) 2625dfecf96Smrg (synaugment :main) 2635dfecf96Smrg ) 2645dfecf96Smrg ) 2655dfecf96Smrg 2665dfecf96Smrg ;; Do nothing, just check start/end tags 2675dfecf96Smrg (html-syntoken "ol") 2685dfecf96Smrg (html-syntable "ol" nil) 2695dfecf96Smrg (html-syntoken "ul") 2705dfecf96Smrg (html-syntable "ul" nil) 2715dfecf96Smrg (html-syntoken "dl") 2725dfecf96Smrg (html-syntable "dl" nil) 2735dfecf96Smrg ;; Maybe <dt> and <dd> should be in a special table, to not require 2745dfecf96Smrg ;; and ending tag. 2755dfecf96Smrg ;; XXX Maybe should also add a table for <p>. 2765dfecf96Smrg (html-syntoken "dt") 2775dfecf96Smrg (html-syntable "dt" nil) 2785dfecf96Smrg (html-syntoken "dd") 2795dfecf96Smrg (html-syntable "dd" nil) 2805dfecf96Smrg 2815dfecf96Smrg (html-syntoken "span") 2825dfecf96Smrg (html-syntable "span" nil) 2835dfecf96Smrg (html-syntoken "div") 2845dfecf96Smrg (html-syntable "div" nil) 2855dfecf96Smrg (html-syntoken "menu") 2865dfecf96Smrg (html-syntable "menu" nil) 2875dfecf96Smrg 2885dfecf96Smrg (html-syntoken "h1") 2895dfecf96Smrg (html-syntable "h1" *prop-html-h1*) 2905dfecf96Smrg (html-syntoken "h2") 2915dfecf96Smrg (html-syntable "h2" *prop-html-h2*) 2925dfecf96Smrg (html-syntoken "h3") 2935dfecf96Smrg (html-syntable "h3" *prop-html-bold*) 2945dfecf96Smrg (html-syntoken "h4") 2955dfecf96Smrg (html-syntable "h4" *prop-html-h4*) 2965dfecf96Smrg (html-syntoken "h5") 2975dfecf96Smrg (html-syntable "h5" *prop-html-h5*) 2985dfecf96Smrg (html-syntoken "title") 2995dfecf96Smrg (html-syntable "title" *prop-html-title*) 3005dfecf96Smrg 3015dfecf96Smrg (html-syntoken "font") 3025dfecf96Smrg (html-syntable "font" *prop-control*) 3035dfecf96Smrg 3045dfecf96Smrg (syntoken "<" :nospec t :contained t :begin :tag) 3055dfecf96Smrg (syntable :generic-tag *prop-html-tag* nil 3065dfecf96Smrg (syntoken "\"" :nospec t :contained t :begin :string) 3075dfecf96Smrg (syntoken "<" :nospec t :property *prop-html-unknown*) 3085dfecf96Smrg ) 3095dfecf96Smrg (syntable :tag *prop-html-tag* nil 3105dfecf96Smrg (syntoken ">" :nospec t :switch -1) 3115dfecf96Smrg (synaugment :generic-tag) 3125dfecf96Smrg ) 3135dfecf96Smrg ;; Tag ended in a newline, common practice... 3145dfecf96Smrg (syntable :continued-end-tag *prop-html-tag* nil 3155dfecf96Smrg (syntoken ">" :nospec t :switch -3) 3165dfecf96Smrg (synaugment :generic-tag) 3175dfecf96Smrg ) 3185dfecf96Smrg (syntable :continued-nested-end-tag *prop-html-tag* nil 3195dfecf96Smrg (syntoken ">" :nospec t :switch -4) 3205dfecf96Smrg (synaugment :generic-tag) 3215dfecf96Smrg ) 3225dfecf96Smrg 3235dfecf96Smrg (syntable :string *prop-html-string* nil 3245dfecf96Smrg (syntoken "\\\\.") 3255dfecf96Smrg (syntoken "\"" :nospec t :switch -1) 3265dfecf96Smrg ) 3275dfecf96Smrg) 328