4

I'd like to use org-wiki to keep a personal wiki. Org-wiki will also publish to html. In doing so it converts all org links of the form wiki:foo to foo.html. It does this using the function org-wiki--org-link. I would like to use org-wiki html functions but with a different publishing backend -- specifically ox-pandoc. While this publishing function using pandoc works, it does not convert the wiki:file links from org-wiki into file.html links in html. This suggests that org-wiki--org-link isn't working the way I would want it to. I have tried the following to fix this (I'm on org 9.0.6 & emacs 25.2.1).

(org-link-set-parameters                                        
 "wiki"                                                        
 :export (lambda (path desc backend)                           
  (cond                                                       
   ((eq backend 'html)                                         
   (format "<a href='%s.html'>%s</a>" path (or desc path)))))))

However this doesn't work. In the html output all links are of the form wiki:foo rather than foo.html.

Any ideas about how to fix this are appreciated.

2 Answers 2

1
+50

You probably need to add a pandoc backend like this:

(org-link-set-parameters
 "wiki"
 :export (lambda (path desc backend)
       (message-box "%s" backend)
       (cond
        ((eq backend 'html)
         (format "<a href='%s.html'>%s</a>" path (or desc path)))
        ((eq backend 'pandoc)
         (format "<a href='%s.html'>%s</a>" path (or desc path))))))

ox-pandoc can make html, but it uses a 'pandoc backend symbol.

6
  • Unfortunately this doesn't work. I'm a bit baffled and have also posted and issue on Github.
    – mclear
    Commented May 16, 2017 at 20:07
  • do you get a popup window that says what the backend is? Commented May 16, 2017 at 20:53
  • This works fine for me with ox-pandoc. Commented May 16, 2017 at 20:54
  • I get a popup saying 'pandoc' (one for each link in fact), but the links are printed literally, not as links. This also doesn't work at all once org-wiki is loaded, which suggests that there is more than one problem :(
    – mclear
    Commented May 16, 2017 at 21:14
  • It looks like org-wiki redefines the links in an org-mode hook, so it will overwrite the definition above. See the next solution above. Commented May 16, 2017 at 21:45
1

Maybe you should redefine this function like this:

(defun org-wiki--org-link (path desc backend)
  "Creates an html org-wiki pages when  exporting to html.
Example: The hyperlink [[wiki:Linux][Dealing with Linux]]
will be exported to <a href='Linux.html'>Dealing with Linux</a>"
  (cl-case backend
    (html (format
       "<a href='%s.html'>%s</a>"
       path
       (or desc path)))
    (pandoc (format
         "<a href='%s.html'>%s</a>"
         path
         (or desc path)))))

alternatively remove the hook defined here: https://github.com/caiorss/org-wiki/blob/master/org-wiki.el#L406 and add a new one that has the right link behavior.

2
  • redefining this as you suggest seems to work except that I'm getting weird behavior in that the links are generated as links but rather as literal strings in paragraph markup (e.g. <p>&lt;a href='index.html'&gt;Index&lt;/a&gt;</p>). Any idea why that would be?
    – mclear
    Commented May 16, 2017 at 21:53
  • that looks like something is escaping some html characters, e.g. < and >. I am not sure where that is happening. Commented May 17, 2017 at 1:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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