Skip to content

Commit

Permalink
Make implicit URL descriptions publish better.
Browse files Browse the repository at this point in the history
* lisp/muse-publish.el (muse-publish-this-file): Display message
  if the buffer is not associated with any file, so that we avoid
  errors later on.
  (muse-publish-url-desc): New function taken from muse-publish-url
  that causes a URL description to be transformed.
  (muse-publish-url): Call muse-publish-url-desc on either the
  description or the original URL if it will be used as a
  description.  Accept the original URL as an argument, in case it
  was transformed earlier.
  (muse-publish-insert-url): Pass original URL as an argument.
  (muse-publish-markup-link): Make this somewhat easier to follow.
  Pass original URL as argument.
git-archimport-id: mwolson@gnu.org--2006/muse--main--1.0--patch-185
  • Loading branch information
mwolson committed Aug 12, 2006
1 parent 08acaee commit adb6867
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
@@ -1,3 +1,18 @@
2006-08-12 Michael Olson <mwolson@gnu.org>

* lisp/muse-publish.el (muse-publish-this-file): Display message
if the buffer is not associated with any file, so that we avoid
errors later on.
(muse-publish-url-desc): New function taken from muse-publish-url
that causes a URL description to be transformed.
(muse-publish-url): Call muse-publish-url-desc on either the
description or the original URL if it will be used as a
description. Accept the original URL as an argument, in case it
was transformed earlier.
(muse-publish-insert-url): Pass original URL as an argument.
(muse-publish-markup-link): Make this somewhat easier to follow.
Pass original URL as argument.

2006-08-10 Michael Olson <mwolson@gnu.org>

* lisp/muse-html.el (muse-html-finalize-buffer): Since the html
Expand Down
50 changes: 27 additions & 23 deletions lisp/muse-publish.el
Expand Up @@ -661,9 +661,11 @@ the file is published no matter what."
Prompt for both the STYLE and OUTPUT-DIR if they are not
supplied."
(interactive (muse-publish-get-info))
(unless (muse-publish-file buffer-file-name style output-dir force)
(message (concat "The published version is up-to-date; use"
" C-u C-c C-T to force an update."))))
(if buffer-file-name
(unless (muse-publish-file buffer-file-name style output-dir force)
(message (concat "The published version is up-to-date; use"
" C-u C-c C-T to force an update.")))
(message "This buffer is not associated with any file")))

(defun muse-batch-publish-files ()
"Publish Muse files in batch mode."
Expand Down Expand Up @@ -1307,20 +1309,23 @@ the cadr is the page name, and the cddr is the anchor."
(t
(cons 'link (cons (muse-publish-link-page target) nil))))))

(defun muse-publish-url (url &optional desc explicit)
"Resolve a URL into its final <a href> form."
(let ((orig-url url)
type anchor)
(dolist (transform muse-publish-url-transforms)
(setq url (save-match-data (when url (funcall transform url explicit)))))
(defun muse-publish-url-desc (desc)
(when desc
(dolist (transform muse-publish-desc-transforms)
(setq desc (save-match-data
(when desc (funcall transform desc explicit)))))
(when desc
(setq desc (muse-link-unescape desc))
(setq desc (muse-publish-escape-specials-in-string desc 'url-desc)))
(setq orig-url
(muse-publish-escape-specials-in-string orig-url 'url-desc))
(setq desc (muse-link-unescape desc))
(muse-publish-escape-specials-in-string desc 'url-desc)))

(defun muse-publish-url (url &optional desc orig-url explicit)
"Resolve a URL into its final <a href> form."
(let (type anchor)
(dolist (transform muse-publish-url-transforms)
(setq url (save-match-data (when url (funcall transform url explicit)))))
(if desc
(setq desc (muse-publish-url-desc desc))
(if orig-url
(setq orig-url (muse-publish-url-desc orig-url))))
(let ((target (muse-publish-classify-url url)))
(setq type (car target)
url (if (eq type 'image)
Expand Down Expand Up @@ -1355,25 +1360,24 @@ the cadr is the page name, and the cddr is the anchor."
text)))
(muse-markup-text 'url url (or desc orig-url)))))))

(defun muse-publish-insert-url (url &optional desc explicit)
(defun muse-publish-insert-url (url &optional desc orig-url explicit)
"Resolve a URL into its final <a href> form."
(delete-region (match-beginning 0) (match-end 0))
(let ((text (muse-publish-url url desc explicit)))
(let ((text (muse-publish-url url desc orig-url explicit)))
(when text
(muse-insert-markup text))))

(defun muse-publish-markup-link ()
(let (desc explicit link)
(let (desc explicit orig-link link)
(setq explicit (save-match-data
(if (string-match muse-explicit-link-regexp
(match-string 0))
t nil)))
(setq desc (if explicit
(match-string 2)
(match-string 0)))
(setq orig-link (if explicit (match-string 1) (match-string 0)))
(setq desc (when explicit (match-string 2)))
(setq link (if explicit
(muse-handle-explicit-link (match-string 1))
(muse-handle-implicit-link (match-string 0))))
(muse-handle-explicit-link orig-link)
(muse-handle-implicit-link orig-link)))
(when (and link
(or explicit
(not (or (eq (char-before (match-beginning 0)) ?\")
Expand All @@ -1382,7 +1386,7 @@ the cadr is the page name, and the cddr is the anchor."
;; as if it were an implicit link
(when (and explicit (not desc))
(setq explicit nil))
(muse-publish-insert-url link desc explicit))))
(muse-publish-insert-url link desc orig-link explicit))))

(defun muse-publish-markup-url ()
(unless (or (eq (char-before (match-beginning 0)) ?\")
Expand Down

0 comments on commit adb6867

Please sign in to comment.