-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml-fix.el
More file actions
executable file
·47 lines (41 loc) · 1.14 KB
/
Copy pathhtml-fix.el
File metadata and controls
executable file
·47 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;;;(require 'sgml)
(defvar html-doctype-decl
"<!DOCTYPE HTML PUBLIC \"-//W3O//DTD WWW HTML 2.0//EN\">")
(defvar html-body-element
'(H1 H2 H3 H4 H5 H6 DL UL OL ADDRESS BLOCKQUOTE PRE XMP LISTING))
(defun html-update ()
(interactive)
(html-maybe-add-doctype)
(html-infer-p-tags)
)
(defun html-maybe-add-doctype ()
(goto-char (point-min))
(cond ((looking-at "<!DOCTYPE") ;; nothing
)
((looking-at "<!SGML") ;; nothing
)
(t (insert html-doctype-decl)
(insert "\n"))
)
)
(defun html-infer-p-tags ()
(goto-char (point-min))
(while (re-search-forward (concat sgml-etago-gi sgml-tagc sgml-s) nil t)
(let ((gi (sgml-make-name (match-beginning 1) (match-end 1)))
)
(if (and (or (eq gi 'TITLE) (member gi html-body-element))
;; @@ comment will screw this up, resulting in extra <P>'s,
;; for example, an extra <P> will be inserted before the
;; coment in the following:
;; <h1>header</h1>
;; <!-- comment hides <P> tag from this thing -->
;; <p>
;;
(not (or (looking-at sgml-stago-gi)
(looking-at sgml-etago-gi)))
)
(insert "<P>")
)
)
)
)