 ;;; Font-lock settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;; The font lock regular expressions.
+
+(defun inXml (depth)
+  (and
+   (re-search-backward "[<>{}]" nil t)
+   (cond
+    ((looking-at "{")
+     (and (> depth 0)
+          (inXml (- depth 1))))
+    ((looking-at "}")
+     (inXml (+ depth 1)))
+    ((save-excursion (backward-char 1) (or (looking-at "=>") (looking-at "->")))
+     (inXml depth))
+    ((looking-at "<")
+     nil)
+    ((looking-at ">")
+     (if (> depth 0)
+         (and (re-search-backward "<" nil t)
+              (inXml depth))
+       (progn (backward-char 5) (not (looking-at "/html"))))))))
 
 (defconst urweb-font-lock-keywords
   `(;;(urweb-font-comments-and-strings)

	(urweb-skip-siblings))
      fullname)))

(provide 'urweb-mode)

;;; urweb-mode.el ends here

     (1 font-lock-keyword-face)
     (2 font-lock-interface-def-face))

    ("\\(<\\sw+\\)\\(\\s-\\|\\sw\\|=\\|\"[^\"]*\"\\|{[^}]*}\\)*/?\\(>\\)"
     (1 font-lock-tag-face)
     (3 font-lock-tag-face))
    ("\\(</\\sw+>\\)"
     (1 font-lock-tag-face))
    ("\\([^<>{}]+\\)"
     (1 (if (save-excursion (inXml 0))
            font-lock-string-face
          nil)))
    
    (,urweb-keywords-regexp . font-lock-keyword-face)
    (,urweb-sql-keywords-regexp . font-lock-sql-face)
    (,urweb-cident-regexp . font-lock-cvariable-face))
  "Regexps matching standard Ur/Web keywords.")

