all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: rainer@krugs.de
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: Export to html fails when link to header in non existing file in document present
Date: Wed, 06 May 2015 15:50:30 +0200	[thread overview]
Message-ID: <874mnpddcp.fsf@gmx.us> (raw)
In-Reply-To: <m2vbg59a3l.fsf@krugs.de> (Rainer M. Krug's message of "Wed, 06 May 2015 14:14:22 +0200")

[-- Attachment #1: Type: text/plain, Size: 1495 bytes --]

Rainer M Krug <Rainer@krugs.de> writes:

>> What do you expect?
>>
>> Should the "::*SOMETHING"-part be discarded without warning?
>
> Well - the ideal solution would be a warning (or error message) with a
> reference to the link. At the moment, a link to a non existing file is
> exported, a link to a section in a non existing produces a cryptic
> error message.
>
> At the moment, I have no clue how I can find the link.
>
> So I would hope for
>
> 1) consistent behavior for the two cases
> 2) a meaningful warning which helps to find the culprit
> 3) an html file, where the links do not work, but the export is fine.
> 
> or, if 3) is not possible, meaningful error messages which actually help
> me to track down the error (I only found out what was causing this error
> accidentally)

The issue with warnings is that I don't see them....  Though an error
seems a bit drastic here.

The attached patch inserts a link without the anchor and issues a warning
if exporting such links without ox-publish.

>> The internal link cannot be known without the file, as it is of the form
>> orgheadlineN where N=n+1 and n is the number of headlines prior to
>> "*Something"...
>
> Sure - this is obvious.

Actually, the error you found is more interesting than what I first
though, as any link with anchors will trigger the error, it seems.
org-publish-cache must be non-nil, which seems to linger on publishing a
project.

—Rasmus

-- 
Don't panic!!!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html-Improve-links-with-search.patch --]
[-- Type: text/x-diff, Size: 1575 bytes --]

From 8e1dd6c43e8a358a85a8034825c475199bd2ffb7 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Wed, 6 May 2015 15:44:26 +0200
Subject: [PATCH] ox-html: Improve links with search

* ox-html.el (org-html-link): Handle links with search when
  not using Publish.

Reported-by: Rainer M Krug <Rainer@krugs.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/97420>
---
 lisp/ox-html.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 6c712f6..0e69e6a 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2849,12 +2849,18 @@ INFO is a plist holding contextual information.  See
 	    ;; relative to a custom-id, a headline title a name,
 	    ;; a target or a radio-target.
 	    (let ((option (org-element-property :search-option link)))
-	      (if (not option) raw-path
-		(concat raw-path
-			"#"
-			(org-publish-resolve-external-link
-			 option
-			 (org-element-property :path link))))))
+	      (cond ((and option org-publish-cache)
+		     (concat raw-path
+			     "#"
+			     (org-publish-resolve-external-link
+			      option
+			      (org-element-property :path link))))
+		    ((and option (not org-publish-cache))
+		     (org-display-warning
+		      (format "Link to file %s cannot be resolved.  Please use Org Publish."
+			      (org-element-property :path link)))
+		     raw-path)
+		    (t raw-path))))
 	   (t raw-path)))
 	 ;; Extract attributes from parent's paragraph.  HACK: Only do
 	 ;; this for the first link in parent (inner image link for
-- 
2.4.0


  reply	other threads:[~2015-05-06 13:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 11:47 Bug: Error export to html - "Org-publish-cache-get: `org-publish-cache-get' called, but no cache present" [8.3beta (release_8.3beta-1115-g8f3946 @ /Users/rainerkrug/.emacs.d/org-mode/lisp/)] Rainer M Krug
2015-05-06  7:39 ` Bug: Export to html fails when link to header in non existing file in document present WAS: " Rainer M Krug
2015-05-06 10:40   ` Bug: Export to html fails when link to header in non existing file in document present Rasmus
2015-05-06 12:14     ` Rainer M Krug
2015-05-06 13:50       ` Rasmus [this message]
2015-05-06 23:04         ` Nicolas Goaziou
2015-05-07  9:55           ` Rainer M Krug
2015-05-07 20:18             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874mnpddcp.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    --cc=rainer@krugs.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.