Source

psgml / psgml-api.el

Diff from to

psgml-api.el

 (provide 'psgml-api)
 (require 'psgml)
 (require 'psgml-parse)
-
+(eval-when-compile (require 'cl))
 
 ;;;; Mapping: map and modify
 
   (sgml-pop-all-entities)
   (sgml-need-dtd)
   (sgml-element-end element)		; Make sure all content is parsed
-  (let ((main-buffer-max (point-max)))
-    (save-excursion
-      (sgml-with-parser-syntax-ro
-       (sgml-set-parse-state element 'start)
-       (when (eobp) (sgml-pop-entity))
-       (when (eolp) (forward-char 1))
-       (sgml-parse-data main-buffer-max data-fun pi-fun entity-fun)
-       (let ((c (sgml-tree-content element)))
-         (while c
-           (sgml-pop-all-entities)
-           (funcall element-fun c)
-           (sgml-set-parse-state c 'after)
-           (sgml-parse-data main-buffer-max data-fun pi-fun entity-fun)
-           (setq c (sgml-tree-next c))))))
-    )
-  (sgml-pop-all-entities))
+  (unless (sgml-element-empty element)
+    (let ((main-buffer-max (point-max)))
+      (save-excursion
+        (sgml-with-parser-syntax-ro
+         (sgml-set-parse-state element 'start)
+         (when (eobp) (sgml-pop-entity))
+         (when (eolp) (forward-char 1))
+         (sgml-parse-data main-buffer-max data-fun pi-fun entity-fun)
+         (let ((c (sgml-tree-content element)))
+           (while c
+             (sgml-pop-all-entities)
+             (funcall element-fun c)
+             (sgml-set-parse-state c 'after)
+             (sgml-parse-data main-buffer-max data-fun pi-fun entity-fun)
+             (setq c (sgml-tree-next c)))))))))
 
 (defun sgml-parse-data (sgml-goal sgml-data-function sgml-pi-function
 				  sgml-entity-function)