- "Replace the index list in the current buffer with a HTML table."
- (let (done open-td tag desc)
- ;; Convert the list that Makeinfo made into a table.
- (or (search-forward "<ul class=\"menu\">" nil t)
- (search-forward "<ul>"))
- (replace-match "<table style=\"float:left\" width=\"100%\">")
- (forward-line 1)
- (while (not done)
- (cond
- ((or (looking-at "<li>\\(<a.+</a>\\):[ \t]+\\(.*\\)$")
- (looking-at "<li>\\(<a.+</a>\\)$"))
- (setq tag (match-string 1))
- (setq desc (match-string 2))
- (replace-match "" t t)
- (when open-td
- (save-excursion
- (forward-char -1)
- (skip-chars-backward " ")
- (delete-region (point) (line-end-position))
- (insert "</td>\n </tr>")))
- (insert " <tr>\n ")
- (if table-workaround
- ;; This works around a Firefox bug in the mono file.
- (insert "<td bgcolor=\"white\">")
- (insert "<td>"))
- (insert tag "</td>\n <td>" (or desc ""))
- (setq open-td t))
- ((eq (char-after) ?\n)
- (delete-char 1)
- ;; Negate the following `forward-line'.
- (forward-line -1))
- ((looking-at "<!-- ")
- (search-forward "-->"))
- ((looking-at "<p>[- ]*The Detailed Node Listing[- \n]*")
- (replace-match " </td></tr></table>\n
+ "Replace the index list in the current buffer with a HTML table.
+Leave point after the table."
+ (if (re-search-forward "<table class=\"menu\"\\(.*\\)>" nil t)
+ ;; Texinfo 5 already uses a table. Tweak it a bit.
+ (let (opoint done)
+ (replace-match " style=\"float:left\" width=\"100%\"" nil t nil 1)
+ (forward-line 1)
+ (while (not done)
+ (cond ((re-search-forward "<tr><td.*• \\(<a.*</a>\\)\
+:</td><td> </td><td[^>]*>\\(.*\\)" (line-end-position) t)
+ (replace-match (format "<tr><td%s>\\1</td>\n<td>\\2"
+ (if table-workaround
+ " bgcolor=\"white\"" "")))
+ (search-forward "</td></tr>")
+ (forward-line 1))
+ ((looking-at "<tr><th.*<pre class=\"menu-comment\">\n")
+ (replace-match "<tr><th colspan=\"2\" align=\"left\" \
+style=\"text-align:left\">")
+ (search-forward "</pre></th></tr>")
+ (replace-match "</th></tr>\n"))
+ ;; Not all manuals have the detailed menu.
+ ;; If it is there, split it into a separate table.
+ ((re-search-forward "<tr>.*The Detailed Node Listing *"
+ (line-end-position) t)
+ (setq opoint (match-beginning 0))
+ (while (and (looking-at " *—")
+ (zerop (forward-line 1))))
+ (delete-region opoint (point))
+ (insert "</table>\n\n\
+<h2>Detailed Node Listing</h2>\n\n<p>")
+ ;; FIXME Fragile!
+ ;; The Emacs and Elisp manual have some text at the
+ ;; start of the detailed menu that is not part of the menu.
+ ;; Other manuals do not.
+ (if (re-search-forward "in one step:" (line-end-position 3) t)
+ (forward-line 1))
+ (insert "</p>\n")
+ (search-forward "</pre></th></tr>")
+ (delete-region (match-beginning 0) (match-end 0))
+ (forward-line -1)
+ (or (looking-at "^$") (error "Parse error 1"))
+ (forward-line -1)
+ (if (looking-at "^$") (error "Parse error 2"))
+ (forward-line -1)
+ (or (looking-at "^$") (error "Parse error 3"))
+ (forward-line 1)
+ (insert "<table class=\"menu\" style=\"float:left\" width=\"100%\">\n\
+<tr><th colspan=\"2\" align=\"left\" style=\"text-align:left\">\n")
+ (forward-line 1)
+ (insert "</th></tr>")
+ (forward-line 1))
+ ((looking-at ".*</table")
+ (forward-line 1)
+ (setq done t)))))
+ (let (done open-td tag desc)
+ ;; Convert the list that Makeinfo made into a table.
+ (or (search-forward "<ul class=\"menu\">" nil t)
+ ;; FIXME? The following search seems dangerously lax.
+ (search-forward "<ul>"))
+ (replace-match "<table style=\"float:left\" width=\"100%\">")
+ (forward-line 1)
+ (while (not done)
+ (cond
+ ((or (looking-at "<li>\\(<a.+</a>\\):[ \t]+\\(.*\\)$")
+ (looking-at "<li>\\(<a.+</a>\\)$"))
+ (setq tag (match-string 1))
+ (setq desc (match-string 2))
+ (replace-match "" t t)
+ (when open-td
+ (save-excursion
+ (forward-char -1)
+ (skip-chars-backward " ")
+ (delete-region (point) (line-end-position))
+ (insert "</td>\n </tr>")))
+ (insert " <tr>\n ")
+ (if table-workaround
+ ;; This works around a Firefox bug in the mono file.
+ (insert "<td bgcolor=\"white\">")
+ (insert "<td>"))
+ (insert tag "</td>\n <td>" (or desc ""))
+ (setq open-td t))
+ ((eq (char-after) ?\n)
+ (delete-char 1)
+ ;; Negate the following `forward-line'.
+ (forward-line -1))
+ ((looking-at "<!-- ")
+ (search-forward "-->"))
+ ((looking-at "<p>[- ]*The Detailed Node Listing[- \n]*")
+ (replace-match " </td></tr></table>\n