aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorGlenn Morris2014-01-02 19:24:27 -0800
committerGlenn Morris2014-01-02 19:24:27 -0800
commit517f20c53356753d00f6df952318ef11d8bf7adc (patch)
tree79dff6ec80b911a490429b2723e9b6dae268a1d7 /admin
parentde229ee3d4597519397f259bab4312edc100dbd1 (diff)
downloademacs-517f20c53356753d00f6df952318ef11d8bf7adc.tar.gz
emacs-517f20c53356753d00f6df952318ef11d8bf7adc.zip
More Texinfo 5 updates for make-manuals (not yet finished)
* admin/admin.el (manual-html-fix-headers): Tweak Texinfo 5 body. (manual-html-fix-node-div): Treat "header" like "node". (manual-html-fix-index-1): Handle Texinfo 5 top heading. (manual-html-fix-index-2): Tweak Texinfo 5 listing tables.
Diffstat (limited to 'admin')
-rw-r--r--admin/ChangeLog8
-rw-r--r--admin/admin.el195
2 files changed, 131 insertions, 72 deletions
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 9f160e9604f..7695391bada 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,11 @@
12014-01-03 Glenn Morris <rgm@gnu.org>
2
3 * admin.el: More Texinfo 5 updates.
4 (manual-html-fix-headers): Tweak Texinfo 5 body.
5 (manual-html-fix-node-div): Treat "header" like "node".
6 (manual-html-fix-index-1): Handle Texinfo 5 top heading.
7 (manual-html-fix-index-2): Tweak Texinfo 5 listing tables.
8
12014-01-02 Xue Fuqiao <xfq.free@gmail.com> 92014-01-02 Xue Fuqiao <xfq.free@gmail.com>
2 10
3 * check-doc-strings: Replace `perl -w' with `use warnings;'. 11 * check-doc-strings: Replace `perl -w' with `use warnings;'.
diff --git a/admin/admin.el b/admin/admin.el
index 58e5b0c830e..119d7202805 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -328,6 +328,7 @@ the @import directive."
328 (manual-html-fix-node-div) 328 (manual-html-fix-node-div)
329 (goto-char (point-max)) 329 (goto-char (point-max))
330 (re-search-backward "</body>[\n \t]*</html>") 330 (re-search-backward "</body>[\n \t]*</html>")
331 ;; Close the div id="content" that fix-index-1 added.
331 (insert "</div>\n\n") 332 (insert "</div>\n\n")
332 (save-buffer))) 333 (save-buffer)))
333 334
@@ -368,6 +369,7 @@ the @import directive."
368 (manual-html-fix-index-2) 369 (manual-html-fix-index-2)
369 (if copyright-text 370 (if copyright-text
370 (insert copyright-text)) 371 (insert copyright-text))
372 ;; Close the div id="content" that fix-index-1 added.
371 (insert "\n</div>\n")) 373 (insert "\n</div>\n"))
372 ;; For normal nodes, give the header div a blue bg. 374 ;; For normal nodes, give the header div a blue bg.
373 (manual-html-fix-node-div)) 375 (manual-html-fix-node-div))
@@ -407,22 +409,28 @@ the @import directive."
407 (setq opoint (match-beginning 0)) 409 (setq opoint (match-beginning 0))
408 (unless texi5 410 (unless texi5
409 (search-forward "<!--") 411 (search-forward "<!--")
410 (goto-char (match-beginning 0)) 412 (goto-char (match-beginning 0))
411 (delete-region opoint (point)) 413 (delete-region opoint (point))
412 (search-forward "<meta http-equiv=\"Content-Style") 414 (search-forward "<meta http-equiv=\"Content-Style")
413 (setq opoint (match-beginning 0))) 415 (setq opoint (match-beginning 0)))
414 (search-forward "</head>") 416 (search-forward "</head>")
415 (goto-char (match-beginning 0)) 417 (goto-char (match-beginning 0))
416 (delete-region opoint (point)) 418 (delete-region opoint (point))
417 (insert manual-style-string))) 419 (insert manual-style-string)
420 ;; Remove Texinfo 5 hard-coding bgcolor, text, link, vlink, alink.
421 (when (re-search-forward "<body lang=\"[^\"]+\"" nil t)
422 (setq opoint (point))
423 (search-forward ">")
424 (if (> (point) (1+ opoint))
425 (delete-region opoint (1- (point))))
426 (search-backward "</head"))))
418 427
428;; Texinfo 5 changed these from class = "node" to "header", yay.
419(defun manual-html-fix-node-div () 429(defun manual-html-fix-node-div ()
420 "Fix up HTML \"node\" divs in the current buffer." 430 "Fix up HTML \"node\" divs in the current buffer."
421 (let (opoint div-end) 431 (let (opoint div-end)
422 (while (search-forward "<div class=\"node\">" nil t) 432 (while (re-search-forward "<div class=\"\\(node\\|header\\)\"\\(>\\)" nil t)
423 (replace-match 433 (replace-match " style=\"background-color:#DDDDFF\">" t t nil 2)
424 "<div class=\"node\" style=\"background-color:#DDDDFF\">"
425 t t)
426 (setq opoint (point)) 434 (setq opoint (point))
427 (re-search-forward "</div>") 435 (re-search-forward "</div>")
428 (setq div-end (match-beginning 0)) 436 (setq div-end (match-beginning 0))
@@ -431,81 +439,124 @@ the @import directive."
431 (replace-match "" t t))))) 439 (replace-match "" t t)))))
432 440
433(defun manual-html-fix-index-1 () 441(defun manual-html-fix-index-1 ()
442 "Remove the h1 header, and the short and long contents lists.
443Also start a \"content\" div."
434 (let (opoint) 444 (let (opoint)
435 (re-search-forward "<body.*>\n") 445 (re-search-forward "<body.*>\n")
436 (setq opoint (match-end 0)) 446 (setq opoint (match-end 0))
437 (search-forward "<h2 class=\"") 447 ;; FIXME? Fragile if a Texinfo 5 document does not use @top.
448 (or (re-search-forward "<h1 class=\"top\"" nil t) ; Texinfo 5
449 (search-forward "<h2 class=\""))
438 (goto-char (match-beginning 0)) 450 (goto-char (match-beginning 0))
439 (delete-region opoint (point)) 451 (delete-region opoint (point))
452 ;; NB caller must close this div.
440 (insert "<div id=\"content\" class=\"inner\">\n\n"))) 453 (insert "<div id=\"content\" class=\"inner\">\n\n")))
441 454
442(defun manual-html-fix-index-2 (&optional table-workaround) 455(defun manual-html-fix-index-2 (&optional table-workaround)
443 "Replace the index list in the current buffer with a HTML table." 456 "Replace the index list in the current buffer with a HTML table."
444 (let (done open-td tag desc) 457 (if (re-search-forward "<table class=\"menu\"\\(.*\\)>" nil t)
445 ;; Convert the list that Makeinfo made into a table. 458 ;; It seems that Texinfo 5 already uses a table.
446 (or (search-forward "<ul class=\"menu\">" nil t) 459 ;; Tweak it a bit. TODO is this worth it?
447 (search-forward "<ul>")) 460 (let (opoint done)
448 (replace-match "<table style=\"float:left\" width=\"100%\">") 461 (replace-match " style=\"float:left\" width=\"100%\"" nil t nil 1)
449 (forward-line 1) 462 ;; Not all manuals have the detailed menu.
450 (while (not done) 463 ;; If it is there, split it into a separate table.
451 (cond 464 (when (re-search-forward "<tr>.*The Detailed Node Listing *" nil t)
452 ((or (looking-at "<li>\\(<a.+</a>\\):[ \t]+\\(.*\\)$") 465 (setq opoint (match-beginning 0))
453 (looking-at "<li>\\(<a.+</a>\\)$")) 466 (while (and (looking-at " *&mdash;")
454 (setq tag (match-string 1)) 467 (zerop (forward-line 1))))
455 (setq desc (match-string 2)) 468 (delete-region opoint (point))
456 (replace-match "" t t) 469 (insert "</table>\n\n\
457 (when open-td 470<h3>Detailed Node Listing</h3>\n")
458 (save-excursion 471 (search-forward "</pre></th></tr>")
459 (forward-char -1) 472 (delete-region (match-beginning 0) (match-end 0))
460 (skip-chars-backward " ") 473 (forward-line -1)
461 (delete-region (point) (line-end-position)) 474 (or (looking-at "^$") (error "Parse error 1"))
462 (insert "</td>\n </tr>"))) 475 (forward-line -1)
463 (insert " <tr>\n ") 476 (if (looking-at "^$") (error "Parse error 2"))
464 (if table-workaround 477 (forward-line -1)
465 ;; This works around a Firefox bug in the mono file. 478 (or (looking-at "^$") (error "Parse error 3"))
466 (insert "<td bgcolor=\"white\">") 479 (forward-line 1)
467 (insert "<td>")) 480 (insert "<table class=\"menu\" style=\"float:left\" width=\"100%\">\n\
468 (insert tag "</td>\n <td>" (or desc "")) 481<tr><th colspan=\"3\" align=\"left\" valign=\"top\">\n\
469 (setq open-td t)) 482")
470 ((eq (char-after) ?\n) 483 (forward-line 1)
471 (delete-char 1) 484 (insert "</th></tr>")
472 ;; Negate the following `forward-line'. 485 ;; Get rid of ugly <pre> formatting of chapter headings.
473 (forward-line -1)) 486 (while (and (not done)
474 ((looking-at "<!-- ") 487 (re-search-forward "\\(<pre class=\"menu-comment\">\n\\|\
475 (search-forward "-->")) 488\n</pre>\\|</table\\)"))
476 ((looking-at "<p>[- ]*The Detailed Node Listing[- \n]*") 489 (if (equal (match-string 1) "</table")
477 (replace-match " </td></tr></table>\n 490 (setq done t)
491 (replace-match "")))))
492 (let (done open-td tag desc)
493 ;; Convert the list that Makeinfo made into a table.
494 (or (search-forward "<ul class=\"menu\">" nil t)
495 ;; FIXME? The following search seems dangerously lax.
496 (search-forward "<ul>"))
497 (replace-match "<table style=\"float:left\" width=\"100%\">")
498 (forward-line 1)
499 (while (not done)
500 (cond
501 ((or (looking-at "<li>\\(<a.+</a>\\):[ \t]+\\(.*\\)$")
502 (looking-at "<li>\\(<a.+</a>\\)$"))
503 (setq tag (match-string 1))
504 (setq desc (match-string 2))
505 (replace-match "" t t)
506 (when open-td
507 (save-excursion
508 (forward-char -1)
509 (skip-chars-backward " ")
510 (delete-region (point) (line-end-position))
511 (insert "</td>\n </tr>")))
512 (insert " <tr>\n ")
513 (if table-workaround
514 ;; 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\">")
518 (insert "<td>"))
519 (insert tag "</td>\n <td>" (or desc ""))
520 (setq open-td t))
521 ((eq (char-after) ?\n)
522 (delete-char 1)
523 ;; Negate the following `forward-line'.
524 (forward-line -1))
525 ((looking-at "<!-- ")
526 (search-forward "-->"))
527 ((looking-at "<p>[- ]*The Detailed Node Listing[- \n]*")
528 (replace-match " </td></tr></table>\n
478<h3>Detailed Node Listing</h3>\n\n" t t) 529<h3>Detailed Node Listing</h3>\n\n" t t)
479 (search-forward "<p>") 530 (search-forward "<p>")
480 (search-forward "<p>" nil t) 531 (search-forward "<p>" nil t)
481 (goto-char (match-beginning 0)) 532 (goto-char (match-beginning 0))
482 (skip-chars-backward "\n ") 533 (skip-chars-backward "\n ")
483 (setq open-td nil) 534 (setq open-td nil)
484 (insert "</p>\n\n<table style=\"float:left\" width=\"100%\">")) 535 (insert "</p>\n\n<table style=\"float:left\" width=\"100%\">"))
485 ((looking-at "</li></ul>") 536 ((looking-at "</li></ul>")
486 (replace-match "" t t)) 537 (replace-match "" t t))
487 ((looking-at "<p>") 538 ((looking-at "<p>")
488 (replace-match "" t t) 539 (replace-match "" t t)
489 (when open-td 540 (when open-td
490 (insert " </td></tr>") 541 (insert " </td></tr>")
491 (setq open-td nil)) 542 (setq open-td nil))
492 (insert " <tr> 543 (insert " <tr>
493 <th colspan=\"2\" align=\"left\" style=\"text-align:left\">") 544 <th colspan=\"2\" align=\"left\" style=\"text-align:left\">")
494 (if (re-search-forward "</p>[ \t\n]*<ul class=\"menu\">" nil t) 545 (if (re-search-forward "</p>[ \t\n]*<ul class=\"menu\">" nil t)
495 (replace-match " </th></tr>"))) 546 (replace-match " </th></tr>")))
496 ((looking-at "[ \t]*</ul>[ \t]*$") 547 ((looking-at "[ \t]*</ul>[ \t]*$")
497 (replace-match 548 (replace-match
498 (if open-td 549 (if open-td
499 " </td></tr>\n</table>" 550 " </td></tr>\n</table>"
500 "</table>") t t) 551 "</table>") t t)
501 (setq done t)) 552 (setq done t))
502 (t 553 (t
503 (if (eobp) 554 (if (eobp)
504 (error "Parse error in %s" 555 (error "Parse error in %s"
505 (file-name-nondirectory buffer-file-name))) 556 (file-name-nondirectory buffer-file-name)))
506 (unless open-td 557 (unless open-td
507 (setq done t)))) 558 (setq done t))))
508 (forward-line 1)))) 559 (forward-line 1)))))
509 560
510 561
511;; Stuff to check new `defcustom's got :version tags. 562;; Stuff to check new `defcustom's got :version tags.