From 3084d1145968d32831270e8f00ca4aaf8c27c820 Mon Sep 17 00:00:00 2001 From: Chunyang Xu 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 "%s" (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