emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-info: Fix html export of info link
@ 2017-01-19 17:51 Chunyang Xu
  2017-01-21 13:21 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Chunyang Xu @ 2017-01-19 17:51 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

I notice the html export (actually, the HTML URL anchor part) of info
link is incorrect in some cases, for example
in (info "(org) Built-in table editor"), the corresponding org link is

  [[info:org#Built-in%20table%20editor][info:org#Built-in table editor]]

org exports it to

  https://www.gnu.org/software/emacs/manual/html_mono/org.html#Built-in-table-editor

but the correct one is

  https://www.gnu.org/software/emacs/manual/html_mono/org.html#Built_002din-table-editor

I have submitted a patch to fix this.

[-- Attachment #2: 0001-org-info-Fix-html-export-of-info-link.patch --]
[-- Type: text/plain, Size: 1925 bytes --]

From 3084d1145968d32831270e8f00ca4aaf8c27c820 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <mail@xuchunyang.me>
Date: Fri, 20 Jan 2017 01:08:26 +0800
Subject: [PATCH] org-info: Fix html export of info link

* org-info.el (org-info-map-node-url): New defun.
(org-info-export): Use the new function.
---
 lisp/org-info.el | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/org-info.el b/lisp/org-info.el
index cbe4289fc..821348b61 100644
--- a/lisp/org-info.el
+++ b/lisp/org-info.el
@@ -113,6 +113,24 @@ See `org-info-emacs-documents' and `org-info-other-documents' for details."
 	((cdr (assoc filename org-info-other-documents)))
 	(t (concat filename ".html"))))
 
+(defun org-info-map-anchor-url (node)
+  "Return URL associated to Info NODE."
+  ;; See (info "(texinfo) HTML Xref Node Name Expansion") for the
+  ;; expansion rule
+  (let* ((node (replace-regexp-in-string "[ \t\n\r]+" " " (org-trim node)))
+         (node (mapconcat (lambda (c)
+                            (if (string-match "[a-zA-Z0-9 ]" (string c))
+                                (string c)
+                              (format "_%04x" c)))
+                          (string-to-list node) ""))
+         (node (replace-regexp-in-string " " "-" node))
+         (url (if (string= node "")
+		  ""
+		(if (string-match "[0-9]" (substring node 0 1))
+		    (concat "g_t" node)
+		  node))))
+    url))
+
 (defun org-info-export (path desc format)
   "Export an info link.
 See `org-link-parameters' for details about PATH, DESC and FORMAT."
@@ -123,7 +141,7 @@ See `org-link-parameters' for details about PATH, DESC and FORMAT."
 	  (node (or (match-string 2 path) "Top")))
       (format "<a href=\"%s#%s\">%s</a>"
 	      (org-info-map-html-url filename)
-	      (replace-regexp-in-string " " "-" node)
+	      (org-info-map-anchor-url node)
 	      (or desc path)))))
 
 (provide 'org-info)
-- 
2.11.0


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

* Re: [PATCH] org-info: Fix html export of info link
  2017-01-19 17:51 [PATCH] org-info: Fix html export of info link Chunyang Xu
@ 2017-01-21 13:21 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-01-21 13:21 UTC (permalink / raw)
  To: Chunyang Xu; +Cc: emacs-orgmode

Hello,

Chunyang Xu <mail@xuchunyang.me> writes:


> I notice the html export (actually, the HTML URL anchor part) of info
> link is incorrect in some cases, for example
> in (info "(org) Built-in table editor"), the corresponding org link is
>
>   [[info:org#Built-in%20table%20editor][info:org#Built-in table editor]]
>
> org exports it to
>
>   https://www.gnu.org/software/emacs/manual/html_mono/org.html#Built-in-table-editor
>
> but the correct one is
>
>   https://www.gnu.org/software/emacs/manual/html_mono/org.html#Built_002din-table-editor
>
> I have submitted a patch to fix this.

Thank you. I applied your patch with some minor refactoring.

I also added TINYCHANGE at the end of the commit message. Please
consider signing FSF papers if you want to further contribute to Org
mode.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2017-01-21 13:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19 17:51 [PATCH] org-info: Fix html export of info link Chunyang Xu
2017-01-21 13:21 ` Nicolas Goaziou

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).