How to properly export help link into HTML

Original link: https://lujun9972.github.io/blog/2022/05/31/%E5%A6%82%E4%BD%95%E5%90%88%E7%90%86%E7%9A% 84%E5%AF%BC%E5%87%BAhelp-link-%E6%88%90html/index.html

export-help-link.png

Org files will export =help= link as an HTTP link when exporting to html, such as a
#+begin_example
Here is a [[help:lazy-helm/describe-char][Help]] link
#+end_example

When exporting to HTML it becomes
#+begin_src html
Here is a Help link
#+end_src

This operation is very confusing, because there is actually no page corresponding to this link.

A more reasonable method is to keep the original text when exporting, but pop up relevant instructions when the cursor moves to this text.

Through [[help:org-link-set-parameters][org-link-set-parameters]], you can register your own defined link export function. The relevant configuration is as follows:
#+begin_src emacs-lisp
(defun org-link –export-help (path desc backend _)
“Export a \”help\” type link.
PATH is a symbol name, as a string.”
(let ((info (pcase (intern path)
((and (pred fboundp) function) (describe-function function))
((and (pred boundp) variable) (describe-variable variable))
(name (user-error “Unknown function or variable: %s” name)))))
(quit-window) ;Close the newly opened help window
(pcase backend
(‘html (format “%s” info desc))
(_ desc))))
;; register the exported function of help
(org-link-set-parameters “help”
:export #’org-link–export-help)
#+end_src

can be exported as

#+begin_src html
Here is a Help link
#+end_src

The effect is as follows:

[[file:./images/export-help-link.png]]

This article is reprinted from: https://lujun9972.github.io/blog/2022/05/31/%E5%A6%82%E4%BD%95%E5%90%88%E7%90%86%E7%9A% 84%E5%AF%BC%E5%87%BAhelp-link-%E6%88%90html/index.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment