[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Conditional link export?

From: Aaron Ecay
Subject: Re: [O] Conditional link export?
Date: Fri, 06 Nov 2015 13:24:09 +0000
User-agent: Notmuch/0.20.2+65~gbd5504e (http://notmuchmail.org) Emacs/ (x86_64-unknown-linux-gnu)

Hi Oleh,

One approach would be to use a parse-tree filter to change one kind of
link into another.  Something like the following (not tested):

| (defun awe/change-info-links (tree backend _info)
|   (org-element-map tree 'link
|     (lambda (link)
|       (when (org-export-derived-backend-p backend 'html)
|         (let* ((target (org-element-property :path link))
|                (parts (split-string target "#")))
|           (org-element-put-property link :type "https")
|           (org-element-put-property
|            link :path
|            (format
|             "//www.gnu.org/software/emacs/manual/html_node/%s/%s.html"
|             (nth 0 parts)
|             (nth 1 parts)))))))
|   tree)
| (add-to-list 'org-export-filter-parse-tree-functions #'awe/change-info-links)

This finds info links in the buffer, and converts them to http ones for
html export.

Exercises for the reader:
- Handle the case of info links with no “#”
- Link to manuals as http links in the document, and convert only the
  relevant http links to info links for info export.

Hope this helps,

Aaron Ecay

reply via email to

[Prev in Thread] Current Thread [Next in Thread]