          ) ;; end: Between two start tags.
 
         ;; [/TAG1] ..pt.. [/TAG2]
+        ;; [/TAG2] ..pt.. [/TAG2]
         ((and (cadr info-last-tag) (cadr info-next-tag))
          ;; We're between end start tags.  Search backwards for the
          ;; matching start tag.
+         ;; The latter case, where a tag is nested inside of itself, is
+         ;; allowed, and must be handled by counting repeated occurrences of
+         ;; "TAG2".
+         (setq nested-tag-count
+               (if (equal (caddr info-last-tag) next-tag) 2 1))
          (while (and info-last-tag
-                     (not (and (not (cadr info-last-tag)) ;; is start tag
-                               (equal (caddr info-last-tag) next-tag)
-                               )
-                          )
-                     )
+                     (> nested-tag-count 0))
            (setq info-last-tag 
                  (jpw-phpBB-tag-pos-to-syntactic
                   (jpw-phpBB-tag-find-last (car info-last-tag) from-pos)))
+           (if (equal (caddr info-last-tag) next-tag)
+               (if (cadr info-last-tag) ;; is end tag
+                   (setq nested-tag-count (1+ nested-tag-count))
+                 ;; else:  it's a matching start tag 
+                 (setq nested-tag-count (1- nested-tag-count))
+                 );;end if end-or-start tag
+             );;end if equal
            );; end while
 
          ;; Loop stopped.  Do we have a result?

{jpw: 09/2005}"
  (let* ((buffer-state (list (buffer-modified-p) (buffer-modified-tick)
                             (buffer-size)))
         (cache-pos-cdr-iter (cons 'nil jpw-phpBB-tag-analysis-cache))
         (taginfo-from-iter (cadr cache-pos-cdr-iter))
         (cached-startag-pos (car (cadr taginfo-from-iter)))
         (cached-endtag-pos (cadr (cadr taginfo-from-iter)))

  ;; Set up font-lock for phpBB-mode
  (make-local-variable 'font-lock-defaults)
  (make-local-variable 'font-lock-multiline)
  (make-local-variable 'font-lock-support-mode)
  (make-local-variable 'lazy-lock-minimum-size)
  (make-local-variable 'lazy-lock-)
  (setq font-lock-defaults phpBB-font-lock-defaults
        font-lock-multiline t
        ;; `jit-lock-mode' doesn't correctly fontify everything we want it to.
        ;; 
        ;; `fast-lock-mode' and `lazy-lock-mode' require you to
        ;; manually-refontify when editing text in some of the more complex
        ;; multiline expressions.  `fast-lock-mode' works by keeping a cache
        ;; of fontifications.  Great for programming modes.  Bad for modes
        ;; operating on temporary buffers.
        ;; 
        ;; So, we'll use `lazy-lock-mode', suitably tuned to behave as
        ;; desired.
        font-lock-support-mode lazy-lock-mode
        lazy-lock-minimum-size nil
        fill-column 0)
  (auto-fill-mode -1)
  )
