From 94f5007433e4f31c4f7d99042376cfeab0173be9 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Tue, 5 Jun 2007 01:00:12 +0000 Subject: [PATCH] Fix bug with and multiple tags 2007-06-04 Michael Olson * lisp/muse-html.el (muse-html-insert-contents): Add documentation. Handle case where heading is read-only, but has muse-contents property. Remove the muse-contents property for any heading we come across so as to avoid double-including an item in an outer table of contents. (muse-html-denote-headings): New function that denotes whether a heading is not read-only by adding the muse-contents property to it. (muse-html-munge-buffer): If we are not to generate contents, still denote headings, in case some outer layer wants to generate contents for our headings. This should fix a bug with table of contents and the tag. Thanks to thorne for the report. * lisp/muse-publish.el (muse-publish-markup-region): Let-bind muse-publish-generate-contents and set it to nil. This should do the right thing when using tags. git-archimport-id: mwolson@gnu.org--2006/muse--main--1.0--patch-334 --- ChangeLog | 19 +++++++++++++++++++ lisp/muse-html.el | 32 ++++++++++++++++++++++++++------ lisp/muse-publish.el | 25 +++++++++++++------------ 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84a5ba3..489422e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2007-06-04 Michael Olson + + * lisp/muse-html.el (muse-html-insert-contents): Add + documentation. Handle case where heading is read-only, but has + muse-contents property. Remove the muse-contents property for any + heading we come across so as to avoid double-including an item in + an outer table of contents. + (muse-html-denote-headings): New function that denotes whether a + heading is not read-only by adding the muse-contents property to + it. + (muse-html-munge-buffer): If we are not to generate contents, + still denote headings, in case some outer layer wants to generate + contents for our headings. This should fix a bug with table of + contents and the tag. Thanks to thorne for the report. + + * lisp/muse-publish.el (muse-publish-markup-region): Let-bind + muse-publish-generate-contents and set it to nil. This should + do the right thing when using tags. + 2007-06-02 Michael Olson * NEWS: Update for non-inlined image change and support for diff --git a/lisp/muse-html.el b/lisp/muse-html.el index 9e192a4..8c3180e 100644 --- a/lisp/muse-html.el +++ b/lisp/muse-html.el @@ -1,6 +1,6 @@ ;;; muse-html.el --- publish to HTML and XHTML -;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. ;; This file is part of Emacs Muse. It is not part of GNU Emacs. @@ -493,6 +493,8 @@ This will be used if no special characters are found." ;; Handling of tags for HTML (defun muse-html-insert-contents (depth) + "Scan the current document and generate a table of contents at point. +DEPTH indicates how many levels of headings to include. The default is 2." (let ((max-depth (or depth 2)) (index 1) base contents l) @@ -501,7 +503,11 @@ This will be used if no special characters are found." (search-forward "Page published by Emacs Muse begins here" nil t) (catch 'done (while (re-search-forward "\\(.+?\\)$" nil t) - (unless (get-text-property (point) 'read-only) + (unless (and (get-text-property (point) 'read-only) + (not (get-text-property (match-beginning 0) + 'muse-contents))) + (remove-text-properties (match-beginning 0) (match-end 0) + '(muse-contents nil)) (setq l (1- (string-to-number (match-string 1)))) (if (null base) (setq base l) @@ -542,6 +548,18 @@ This will be used if no special characters are found." (muse-insert-markup "\n\n") (muse-publish-mark-read-only p (point))))) +(defun muse-html-denote-headings () + "Place a text property on any headings in the current buffer. +This allows the headings to be picked up later on if publishing a +table of contents." + (save-excursion + (goto-char (point-min)) + (search-forward "Page published by Emacs Muse begins here" nil t) + (while (re-search-forward "\\(.+?\\)$" nil t) + (unless (get-text-property (point) 'read-only) + (add-text-properties (match-beginning 0) (match-end 0) + '(muse-contents t)))))) + (defun muse-html-class-tag (beg end attrs) (goto-char beg) (muse-insert-markup "") @@ -618,10 +636,12 @@ This tag requires htmlize 1.34 or later in order to work." (muse-html-encoding))))) (defun muse-html-munge-buffer () - (when muse-publish-generate-contents - (goto-char (car muse-publish-generate-contents)) - (muse-html-insert-contents (cdr muse-publish-generate-contents)) - (setq muse-publish-generate-contents nil))) + (if muse-publish-generate-contents + (progn + (goto-char (car muse-publish-generate-contents)) + (muse-html-insert-contents (cdr muse-publish-generate-contents)) + (setq muse-publish-generate-contents nil)) + (muse-html-denote-headings))) (defun muse-html-finalize-buffer () (when (and (boundp 'buffer-file-coding-system) diff --git a/lisp/muse-publish.el b/lisp/muse-publish.el index 3145ca6..b177708 100644 --- a/lisp/muse-publish.el +++ b/lisp/muse-publish.el @@ -570,18 +570,19 @@ normally." (error "Cannot find any publishing styles to use"))) (save-restriction (narrow-to-region beg end) - (unless muse-publish-inhibit-style-hooks - (muse-style-run-hooks :before style)) - (muse-publish-markup - title - (sort (copy-alist (append muse-publish-markup-regexps - (muse-style-elements-list :regexps style))) - (function - (lambda (l r) - (< (car l) (car r)))))) - (unless muse-publish-inhibit-style-hooks - (muse-style-run-hooks :before-end style)) - (muse-publish-escape-specials (point-min) (point-max) nil 'document) + (let ((muse-publish-generate-contents nil)) + (unless muse-publish-inhibit-style-hooks + (muse-style-run-hooks :before style)) + (muse-publish-markup + title + (sort (copy-alist (append muse-publish-markup-regexps + (muse-style-elements-list :regexps style))) + (function + (lambda (l r) + (< (car l) (car r)))))) + (unless muse-publish-inhibit-style-hooks + (muse-style-run-hooks :before-end style)) + (muse-publish-escape-specials (point-min) (point-max) nil 'document)) (goto-char (point-max)))) (defun muse-publish-markup-buffer (title style) -- 2.11.4.GIT