0

I have defined an org-link as follows:

(org-link-set-parameters my-link
 :follow (lambda (path) (message "This my link"))
 :export (lambda (path desc backend) "") ; I need to remove the space before the link.
)

In my case, this type of a link is always preceded by a space which should not appear in the exported file. How can I cause the character immediately preceding the link to be deleted during export?

For example, when exporting the following:

Some text my-link:path more text.

if the link is simply replaced by an empty string two spaces would result in the output. I want to avoid the extra space.

  • Can you post an example of what your link looks like in org, and how you want it to export? You might be able to eliminate the space by using the bracket form of the link like this[[mylink:some path]]. – John Kitchin Jan 6 '18 at 17:25
  • I edited the question. – AlwaysLearning Jan 7 '18 at 7:05
1

I think this is a backend specific "feature". I see what you see (the extra space) for html and latex export, but not for ascii export. I think you can use a filter to eliminate the space like this:

(let ((org-export-filter-link-functions '((lambda (txt _ _) (if (string= txt " ") "" txt)))))
  (org-html-export-as-html))
  • What will be passed to this filter as txt, i.e. when will it be " "? – AlwaysLearning Jan 8 '18 at 6:17
  • txt is the "transcoded" link. It is " " when you export the link as "" in html and latex exports as far as I can tell, i.e. they are adding an extra space to it, and the filter just replaces it with "". – John Kitchin Jan 8 '18 at 16:30
0

Use substring?

(substring " http://www.google.com" 1)

Test:

(message "%s" (substring " http://www.google.com" 1))

or is that not what you mean?

  • I mean that I want the character before the link not to get exported. – AlwaysLearning Jan 6 '18 at 17:56
  • I edited the question. – AlwaysLearning Jan 7 '18 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.