emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: HTML export of link to target in another file
@ 2010-03-18 22:52 Dan Davison
  2010-03-19 17:20 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Davison @ 2010-03-18 22:52 UTC (permalink / raw)
  To: emacs org-mode mailing list

Below are a bug report, a tentative patch and a proposed doc patch.

Bug report
==========
If I have this:

A [[file:zz.org::#mytarget][link]] to a target with a custom ID

and export it to HTML, I get

A <a href="zz.html##mytarget">link</a> to a target with a custom ID

which (in firefox on linux) links to the file but does not jump to the
target. However, if I change the '##' to '#' then firefox jumps to the
correct location. Is this an org bug?

Very tentatively proposed patch
===============================
I've investigated a bit (notes below), resulting in this proposed patch:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-html.el b/lisp/org-html.el
index aa70408..5ee5b19 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1110,7 +1110,7 @@ lang=\"%s\" xml:lang=\"%s\">
                     (abs-p (file-name-absolute-p filename))
                     thefile file-is-image-p search)
                (save-match-data
-                 (if (string-match "::\\(.*\\)" filename)
+                 (if (string-match "::#?\\(.*\\)" filename)
                      (setq search (match-string 1 filename)
                            filename (replace-match "" t nil filename)))
                  (setq valid
--8<---------------cut here---------------end--------------->8---

Doc patch
=========
The link above (file:zz.org::#mytarget) was created by C-c l on a
heading with a CUSTOM_ID property. However, I couldn't see where in the
manual links of this form are documented. Do we need to add this link
type to section 4.7 "Search options in file links", e.g.

--8<---------------cut here---------------start------------->8---
diff --git a/doc/org.texi b/doc/org.texi
index f49f056..c8cc1a5 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3116,6 +3116,7 @@ link, together with an explanation:
 [[file:~/code/main.c::255]]
 [[file:~/xx.org::My Target]]
 [[file:~/xx.org::*My Target]]
+[[file:~/xx.org::#my-custom-id]]
 [[file:~/xx.org::/regexp/]]
 @end example
 
@@ -3130,6 +3131,8 @@ link will become an HTML reference to the corresponding named anchor in
 the linked file.
 @item *My Target
 In an Org file, restrict search to headlines.
+@item #my-custom-id
+Link to a heading with a @code{CUSTOM_ID} property
 @item /regexp/
 Do a regular expression search for @code{regexp}.  This uses the Emacs
 command @code{occur} to list all matches in a separate window.  If the
--8<---------------cut here---------------end--------------->8---

Notes
=====
At line 1134 of org-html.el there is

			(setq thefile (concat thefile "#"
					      (org-solidify-link-text
					       (org-link-unescape search)))))

during evaluation of which 'search is bound to "#mytarget", which
suggested that the problem might be in the regexp parsing creating
'search.

Dan

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Bug: HTML export of link to target in another file
  2010-03-18 22:52 Bug: HTML export of link to target in another file Dan Davison
@ 2010-03-19 17:20 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2010-03-19 17:20 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs org-mode mailing list

Hi Dan,

thanks for the report and analysis.  I have fixed
is almost like you proposed, and I did apply the
docfix as well.

- Carsten

On Mar 18, 2010, at 11:52 PM, Dan Davison wrote:

> Below are a bug report, a tentative patch and a proposed doc patch.
>
> Bug report
> ==========
> If I have this:
>
> A [[file:zz.org::#mytarget][link]] to a target with a custom ID
>
> and export it to HTML, I get
>
> A <a href="zz.html##mytarget">link</a> to a target with a custom ID
>
> which (in firefox on linux) links to the file but does not jump to the
> target. However, if I change the '##' to '#' then firefox jumps to the
> correct location. Is this an org bug?
>
> Very tentatively proposed patch
> ===============================
> I've investigated a bit (notes below), resulting in this proposed  
> patch:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index aa70408..5ee5b19 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -1110,7 +1110,7 @@ lang=\"%s\" xml:lang=\"%s\">
>                     (abs-p (file-name-absolute-p filename))
>                     thefile file-is-image-p search)
>                (save-match-data
> -                 (if (string-match "::\\(.*\\)" filename)
> +                 (if (string-match "::#?\\(.*\\)" filename)
>                      (setq search (match-string 1 filename)
>                            filename (replace-match "" t nil  
> filename)))
>                  (setq valid
> --8<---------------cut here---------------end--------------->8---
>
> Doc patch
> =========
> The link above (file:zz.org::#mytarget) was created by C-c l on a
> heading with a CUSTOM_ID property. However, I couldn't see where in  
> the
> manual links of this form are documented. Do we need to add this link
> type to section 4.7 "Search options in file links", e.g.
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/doc/org.texi b/doc/org.texi
> index f49f056..c8cc1a5 100644
> --- a/doc/org.texi
> +++ b/doc/org.texi
> @@ -3116,6 +3116,7 @@ link, together with an explanation:
> [[file:~/code/main.c::255]]
> [[file:~/xx.org::My Target]]
> [[file:~/xx.org::*My Target]]
> +[[file:~/xx.org::#my-custom-id]]
> [[file:~/xx.org::/regexp/]]
> @end example
>
> @@ -3130,6 +3131,8 @@ link will become an HTML reference to the  
> corresponding named anchor in
> the linked file.
> @item *My Target
> In an Org file, restrict search to headlines.
> +@item #my-custom-id
> +Link to a heading with a @code{CUSTOM_ID} property
> @item /regexp/
> Do a regular expression search for @code{regexp}.  This uses the Emacs
> command @code{occur} to list all matches in a separate window.  If the
> --8<---------------cut here---------------end--------------->8---
>
> Notes
> =====
> At line 1134 of org-html.el there is
>
> 			(setq thefile (concat thefile "#"
> 					      (org-solidify-link-text
> 					       (org-link-unescape search)))))
>
> during evaluation of which 'search is bound to "#mytarget", which
> suggested that the problem might be in the regexp parsing creating
> 'search.
>
> Dan
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-19 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 22:52 Bug: HTML export of link to target in another file Dan Davison
2010-03-19 17:20 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).