[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] org-info: Fix html export of info link
From: |
Chunyang Xu |
Subject: |
[O] [PATCH] org-info: Fix html export of info link |
Date: |
Fri, 20 Jan 2017 01:51:38 +0800 |
User-agent: |
mu4e 0.9.18; emacs 25.1.1 |
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.
>From 3084d1145968d32831270e8f00ca4aaf8c27c820 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <address@hidden>
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
- [O] [PATCH] org-info: Fix html export of info link,
Chunyang Xu <=