From 5ad3cb2b6218407a22e1fa3dae7cb69f21f97bc3 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sun, 17 Jul 2005 20:52:18 +0000 Subject: [PATCH] Fix links in table, links in verbatim, emphasis publishing, publishing from script. * lisp/muse-colors.el (muse-colors-emphasized): Fix an edge case where the beginning of a header would be emphasized if an asterisk came before it. (muse-colors-underlined): Don't allow end of underlined text to be the beginning of a line. Don't use memq to check for whitespace syntax; eq is sufficient. * lisp/muse-publish.el (muse-publish-markup-regexps): Mark links later on. We'll use a more clever trick to keep emphasis characters from being interpreted in explicit links -- add a custom 'noemphasis text property to them. Move mdash rule further down so that I can add designations after blockquoted text. * lisp/muse-publish.el (muse-publish-markup-word): If beginning or end of text has the 'noemphasis property, ignore it. (muse-publish-mark-noemphasis): New function that adds the 'noemphasis property to the text between BEG and END, or match beginning and end. * lisp/muse.el (muse-with-temp-buffer): Make sure the buffer is alive before trying to set buffer-modified to nil. This should fix a "selecting deleted buffer" error when publishing from command line. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-149 --- ChangeLog | 34 ++++++++++++++++++++++++++++++++++ lisp/muse-colors.el | 6 +++--- lisp/muse-publish.el | 44 ++++++++++++++++++++++++++++---------------- lisp/muse.el | 8 ++++---- 4 files changed, 69 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0617a2..2cde39d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,40 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-07-17 20:52:18 GMT Michael Olson patch-149 + + Summary: + Fix links in table, links in verbatim, emphasis publishing, publishing from script. + Revision: + muse--main--1.0--patch-149 + + * lisp/muse-colors.el (muse-colors-emphasized): Fix an edge case where + the beginning of a header would be emphasized if an asterisk came + before it. + (muse-colors-underlined): Don't allow end of underlined text to be the + beginning of a line. Don't use memq to check for whitespace syntax; eq + is sufficient. + + * lisp/muse-publish.el (muse-publish-markup-regexps): Mark links later + on. We'll use a more clever trick to keep emphasis characters from + being interpreted in explicit links -- add a custom 'noemphasis text + property to them. Move mdash rule further down so that I can add + designations after blockquoted text. + + * lisp/muse-publish.el (muse-publish-markup-word): If beginning or end of + text has the 'noemphasis property, ignore it. + (muse-publish-mark-noemphasis): New function that adds the 'noemphasis + property to the text between BEG and END, or match beginning and end. + + * lisp/muse.el (muse-with-temp-buffer): Make sure the buffer is alive + before trying to set buffer-modified to nil. This should fix a + "selecting deleted buffer" error when publishing from command line. + + modified files: + ChangeLog lisp/muse-colors.el lisp/muse-publish.el + lisp/muse.el + + 2005-07-17 18:36:55 GMT Michael Olson patch-148 Summary: diff --git a/lisp/muse-colors.el b/lisp/muse-colors.el index 6409a65..2870f84 100644 --- a/lisp/muse-colors.el +++ b/lisp/muse-colors.el @@ -212,7 +212,7 @@ whether progress messages should be displayed to the user." ;; or no '*' at end (unless (or (> leader 3) (not (eq leader (- e2 b2))) - (eq (char-before b2) ?\ ) + (eq (char-syntax (char-before b2)) ?\ ) (not (eq (char-after b2) ?*))) (add-text-properties beg e1 '(invisible muse)) (add-text-properties @@ -230,7 +230,7 @@ whether progress messages should be displayed to the user." (unless (eq (get-text-property start 'invisible) 'muse) ;; beginning of line or space or symbol (when (or (= start (point-min)) - (memq (char-syntax (char-before start)) '(?\ ?\-)) + (eq (char-syntax (char-before start)) ?\ ) (memq (char-before start) '(?\- ?\[ ?\< ?\( ?\' ?\` ?\" ?\n))) (save-excursion @@ -240,7 +240,7 @@ whether progress messages should be displayed to the user." (skip-chars-forward "^_<>" end)) ;; Abort if space exists just before end ;; or no '_' at end - (unless (or (eq (char-before (point)) ?\ ) + (unless (or (eq (char-syntax (char-before (point))) ?\ ) (not (eq (char-after (point)) ?_))) (add-text-properties start (1+ start) '(invisible muse)) (add-text-properties (1+ start) (point) '(face underline)) diff --git a/lisp/muse-publish.el b/lisp/muse-publish.el index 67af84b..083bbb5 100644 --- a/lisp/muse-publish.el +++ b/lisp/muse-publish.el @@ -83,8 +83,8 @@ Each is passed the URL and expects a URL to be returned." ;; define anchor points (1400 "^#\\(\\S-+\\)\\s-*" 0 anchor) - ;; replace links in the buffer (links to other pages) - (1500 muse-explicit-link-regexp 0 link) + ;; prevent emphasis characters in explicit links from being marked + (1500 muse-explicit-link-regexp 0 muse-publish-mark-noemphasis) ;; emphasized or literal text (1600 ,(concat @@ -109,17 +109,10 @@ Each is passed the URL and expects a URL to be returned." ;; horizontal rule, or section separator (1900 "^----+" 0 rule) - (2000 ,(concat "\n*\\(^\\|[" - muse-regexp-blank - "]+\\)--\\($\\|[" - muse-regexp-blank - "]+\\)") - 0 emdash) - ;; beginning of footnotes section - (2100 "^Footnotes:?\\s-*" 0 fn-sep) + (2000 "^Footnotes:?\\s-*" 0 fn-sep) ;; footnote definition/reference (def if at beginning of line) - (2200 "\\[\\([1-9][0-9]*\\)\\]" 0 footnote) + (2100 "\\[\\([1-9][0-9]*\\)\\]" 0 footnote) ;; unnumbered List items begin with a -. numbered list items ;; begin with number and a period. definition lists have a @@ -129,7 +122,7 @@ Each is passed the URL and expects a URL to be returned." ;; reason all of these rules are handled here, is so that ;; blockquote detection doesn't interfere with indented list ;; members. - (2300 ,(concat "^[" + (2200 ,(concat "^[" muse-regexp-blank "]+\\(-[" muse-regexp-blank @@ -140,16 +133,23 @@ Each is passed the URL and expects a URL to be returned." "]+::\n?\\)") 1 list) - (2400 ,(concat "^\\(\\(?:.+?\\)[" + (2300 ,(concat "^\\(\\(?:.+?\\)[" muse-regexp-blank "]+::\n?\\)") 0 list) - (2500 ,(concat "^\\([" + (2400 ,(concat "^\\([" muse-regexp-blank "]+\\)") 0 quote) + (2500 ,(concat "\\(^\\|[" + muse-regexp-blank + "]+\\)--\\($\\|[" + muse-regexp-blank + "]+\\)") + 0 emdash) + ;; "verse" text is indicated the same way as a quoted e-mail ;; response: "> text", where text may contain initial whitespace ;; (see below). @@ -170,7 +170,10 @@ Each is passed the URL and expects a URL to be returned." "]+.+?\\)\\)$") 0 table) - ;; base URLs + ;; replace links in the buffer (links to other pages) + (2900 muse-explicit-link-regexp 0 link) + + ;; bare URLs (3000 muse-url-regexp 0 url) ;; bare email addresses @@ -664,8 +667,11 @@ the file is published no matter what." close-tag (muse-markup-text 'end-more-emph))) ((= l 3) (setq open-tag (muse-markup-text 'begin-most-emph) close-tag (muse-markup-text 'end-most-emph))))))) - (if (and (setq loc (search-forward leader nil t)) + (if (and (not (get-text-property beg 'noemphasis)) + (setq loc (search-forward leader nil t)) (eq 0 (skip-syntax-forward "w" (1+ loc))) + (not (eq (char-syntax (char-before (point))) ?\ )) + (not (get-text-property (point) 'noemphasis)) (or multi-line (= 1 (count-lines beg loc)))) (progn (replace-match "") @@ -996,6 +1002,12 @@ like read-only from being inadvertently deleted." (add-text-properties beg end '(rear-nonsticky (read-only) read-only t)) nil) +(defun muse-publish-mark-noemphasis (&optional beg end) + (unless beg (setq beg (match-beginning 0))) + (unless end (setq end (match-end 0))) + (add-text-properties beg end '(noemphasis t)) + nil) + (defun muse-publish-verbatim-tag (beg end) (muse-publish-escape-specials beg end) (muse-publish-mark-read-only beg end)) diff --git a/lisp/muse.el b/lisp/muse.el index e812d65..910d1fb 100644 --- a/lisp/muse.el +++ b/lisp/muse.el @@ -198,10 +198,10 @@ Unlike `with-temp-buffer', this will never attempt to save the temp buffer." (message "%s: Error occured: %s" (muse-page-name) err)))) - (with-current-buffer ,temp-buffer - (set-buffer-modified-p nil)) - (and (buffer-name ,temp-buffer) - (kill-buffer ,temp-buffer)))))) + (and (buffer-name ,temp-buffer) + (with-current-buffer ,temp-buffer + (set-buffer-modified-p nil)) + (kill-buffer ,temp-buffer)))))) (put 'muse-with-temp-buffer 'lisp-indent-function 0) (put 'muse-with-temp-buffer 'edebug-form-spec '(body)) -- 2.11.4.GIT