aboutsummaryrefslogtreecommitdiffstats
path: root/admin/admin.el
diff options
context:
space:
mode:
authorGlenn Morris2014-01-03 18:31:56 -0800
committerGlenn Morris2014-01-03 18:31:56 -0800
commitd16ec91efb551c2a3181d2ae494f8af28d7f254b (patch)
tree61227490ccf7962cad0f2e04707e5507126133ec /admin/admin.el
parent22db5dd5ed7c5d18e8247e91093195ca7af38361 (diff)
downloademacs-d16ec91efb551c2a3181d2ae494f8af28d7f254b.tar.gz
emacs-d16ec91efb551c2a3181d2ae494f8af28d7f254b.zip
Yet more Texinfo 5 tweaks for admin.el's make-manuals
* admin.el (manual-html-fix-node-div): Handle Texinfo 5's movable <hr>. (manual-html-fix-index-2): Tweak Texinfo 5 table format.
Diffstat (limited to 'admin/admin.el')
-rw-r--r--admin/admin.el126
1 files changed, 83 insertions, 43 deletions
diff --git a/admin/admin.el b/admin/admin.el
index 119d7202805..bc7e3cbd824 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -372,7 +372,7 @@ the @import directive."
372 ;; Close the div id="content" that fix-index-1 added. 372 ;; Close the div id="content" that fix-index-1 added.
373 (insert "\n</div>\n")) 373 (insert "\n</div>\n"))
374 ;; For normal nodes, give the header div a blue bg. 374 ;; For normal nodes, give the header div a blue bg.
375 (manual-html-fix-node-div)) 375 (manual-html-fix-node-div t))
376 (save-buffer)))))) 376 (save-buffer))))))
377 377
378(defun manual-pdf (texi-file dest) 378(defun manual-pdf (texi-file dest)
@@ -426,17 +426,38 @@ the @import directive."
426 (search-backward "</head")))) 426 (search-backward "</head"))))
427 427
428;; Texinfo 5 changed these from class = "node" to "header", yay. 428;; Texinfo 5 changed these from class = "node" to "header", yay.
429(defun manual-html-fix-node-div () 429(defun manual-html-fix-node-div (&optional split)
430 "Fix up HTML \"node\" divs in the current buffer." 430 "Fix up HTML \"node\" divs in the current buffer."
431 (let (opoint div-end) 431 (let (opoint div-end type)
432 (while (re-search-forward "<div class=\"\\(node\\|header\\)\"\\(>\\)" nil t) 432 (while (re-search-forward "<div class=\"\\(node\\|header\\)\"\\(>\\)" nil t)
433 (setq type (match-string 1))
434 ;; NB it is this that makes the bg of non-header cells in the
435 ;; index tables be blue. Is that intended?
436 ;; Also, if you don't remove the <hr>, the color of the first
437 ;; row in the table will be wrong.
438 ;; This all seems rather odd to me...
433 (replace-match " style=\"background-color:#DDDDFF\">" t t nil 2) 439 (replace-match " style=\"background-color:#DDDDFF\">" t t nil 2)
434 (setq opoint (point)) 440 (setq opoint (point))
435 (re-search-forward "</div>") 441 (when (or split (equal type "node"))
436 (setq div-end (match-beginning 0)) 442 ;; In Texinfo 4, the <hr> (and anchor) comes after the <div>.
437 (goto-char opoint) 443 (re-search-forward "</div>")
438 (if (search-forward "<hr>" div-end 'move) 444 (setq div-end (if (equal type "node")
439 (replace-match "" t t))))) 445 (match-beginning 0)
446 (line-end-position 2)))
447 (goto-char opoint)
448 (if (search-forward "<hr>" div-end 'move)
449 (replace-match "" t t)
450 (if split (forward-line -1))))
451 ;; In Texinfo 5, the <hr> (and anchor) comes before the <div> (?).
452 ;; Except in split output, where it comes on the line after
453 ;; the <div>. But only sometimes. I have no clue what the
454 ;; logic of where it goes is.
455 (when (equal type "header")
456 (goto-char opoint)
457 (when (re-search-backward "^<hr>$" (line-beginning-position -3) t)
458 (replace-match "")
459 (goto-char opoint))))))
460
440 461
441(defun manual-html-fix-index-1 () 462(defun manual-html-fix-index-1 ()
442 "Remove the h1 header, and the short and long contents lists. 463 "Remove the h1 header, and the short and long contents lists.
@@ -453,42 +474,63 @@ Also start a \"content\" div."
453 (insert "<div id=\"content\" class=\"inner\">\n\n"))) 474 (insert "<div id=\"content\" class=\"inner\">\n\n")))
454 475
455(defun manual-html-fix-index-2 (&optional table-workaround) 476(defun manual-html-fix-index-2 (&optional table-workaround)
456 "Replace the index list in the current buffer with a HTML table." 477 "Replace the index list in the current buffer with a HTML table.
478Leave point after the table."
457 (if (re-search-forward "<table class=\"menu\"\\(.*\\)>" nil t) 479 (if (re-search-forward "<table class=\"menu\"\\(.*\\)>" nil t)
458 ;; It seems that Texinfo 5 already uses a table. 480 ;; Texinfo 5 already uses a table. Tweak it a bit.
459 ;; Tweak it a bit. TODO is this worth it?
460 (let (opoint done) 481 (let (opoint done)
461 (replace-match " style=\"float:left\" width=\"100%\"" nil t nil 1) 482 (replace-match " style=\"float:left\" width=\"100%\"" nil t nil 1)
462 ;; Not all manuals have the detailed menu. 483 (forward-line 1)
463 ;; If it is there, split it into a separate table. 484 (while (not done)
464 (when (re-search-forward "<tr>.*The Detailed Node Listing *" nil t) 485 (cond ((re-search-forward "<tr><td.*&bull; \\(<a.*</a>\\)\
465 (setq opoint (match-beginning 0)) 486:</td><td>&nbsp;&nbsp;</td><td.*>\\(.*\\)" (line-end-position) t)
466 (while (and (looking-at " *&mdash;") 487 (replace-match (format "<tr><td%s>\\1</td>\n<td>\\2"
467 (zerop (forward-line 1)))) 488 (if table-workaround
468 (delete-region opoint (point)) 489 " bgcolor=\"white\"" "")))
469 (insert "</table>\n\n\ 490 (search-forward "</td></tr>")
470<h3>Detailed Node Listing</h3>\n") 491 (forward-line 1))
471 (search-forward "</pre></th></tr>") 492 ((looking-at "<tr><th.*<pre class=\"menu-comment\">\n")
472 (delete-region (match-beginning 0) (match-end 0)) 493 (replace-match "<tr><th colspan=\"2\" align=\"left\" \
473 (forward-line -1) 494style=\"text-align:left\">")
474 (or (looking-at "^$") (error "Parse error 1")) 495 (search-forward "</pre></th></tr>")
475 (forward-line -1) 496 (replace-match "</th></tr>\n"))
476 (if (looking-at "^$") (error "Parse error 2")) 497 ;; Not all manuals have the detailed menu.
477 (forward-line -1) 498 ;; If it is there, split it into a separate table.
478 (or (looking-at "^$") (error "Parse error 3")) 499 ((re-search-forward "<tr>.*The Detailed Node Listing *"
479 (forward-line 1) 500 (line-end-position) t)
480 (insert "<table class=\"menu\" style=\"float:left\" width=\"100%\">\n\ 501 (setq opoint (match-beginning 0))
481<tr><th colspan=\"3\" align=\"left\" valign=\"top\">\n\ 502 (while (and (looking-at " *&mdash;")
482") 503 (zerop (forward-line 1))))
483 (forward-line 1) 504 (delete-region opoint (point))
484 (insert "</th></tr>") 505 (insert "</table>\n\n\
485 ;; Get rid of ugly <pre> formatting of chapter headings. 506<h2>Detailed Node Listing</h2>\n\n<p>")
486 (while (and (not done) 507 ;; FIXME Fragile!
487 (re-search-forward "\\(<pre class=\"menu-comment\">\n\\|\ 508 ;; The Emacs and Elisp manual have some text at the
488\n</pre>\\|</table\\)")) 509 ;; start of the detailed menu that is not part of the menu.
489 (if (equal (match-string 1) "</table") 510 ;; Other manuals do not.
490 (setq done t) 511 ;; FIXME Texinfo 4 branch does not handle this correctly.
491 (replace-match ""))))) 512 ;; See eg s/emacs/manual/html_node/eintr/index.html
513 ;; start of "Detailed Node Listing".
514 (if (re-search-forward "in one step:" (line-end-position 3) t)
515 (forward-line 1))
516 (insert "</p>\n")
517 (search-forward "</pre></th></tr>")
518 (delete-region (match-beginning 0) (match-end 0))
519 (forward-line -1)
520 (or (looking-at "^$") (error "Parse error 1"))
521 (forward-line -1)
522 (if (looking-at "^$") (error "Parse error 2"))
523 (forward-line -1)
524 (or (looking-at "^$") (error "Parse error 3"))
525 (forward-line 1)
526 (insert "<table class=\"menu\" style=\"float:left\" width=\"100%\">\n\
527<tr><th colspan=\"2\" align=\"left\" style=\"text-align:left\">\n")
528 (forward-line 1)
529 (insert "</th></tr>")
530 (forward-line 1))
531 ((looking-at ".*</table")
532 (forward-line 1)
533 (setq done t)))))
492 (let (done open-td tag desc) 534 (let (done open-td tag desc)
493 ;; Convert the list that Makeinfo made into a table. 535 ;; Convert the list that Makeinfo made into a table.
494 (or (search-forward "<ul class=\"menu\">" nil t) 536 (or (search-forward "<ul class=\"menu\">" nil t)
@@ -512,8 +554,6 @@ Also start a \"content\" div."
512 (insert " <tr>\n ") 554 (insert " <tr>\n ")
513 (if table-workaround 555 (if table-workaround
514 ;; This works around a Firefox bug in the mono file. 556 ;; This works around a Firefox bug in the mono file.
515 ;; FIXME Is this still needed?
516 ;; If so, the Texinfo 5 branch needs to add it too.
517 (insert "<td bgcolor=\"white\">") 557 (insert "<td bgcolor=\"white\">")
518 (insert "<td>")) 558 (insert "<td>"))
519 (insert tag "</td>\n <td>" (or desc "")) 559 (insert tag "</td>\n <td>" (or desc ""))