在Emacs中,当htmlize emacs缓冲区时如何将链接导出到可点击的链接?
背景
问题
例如,这里是一个组织模式文件,其内容如下:
[[http://hunmr.blogspot.com][blog]]
当我使用Htmlize.el将HTML缓冲区内容htmlize时,链接丢失。 生成HTML如下所示:
<span style="hyperlinkFOOBAR">blog</span>
预期
我预料它会产生可点击的链接,如:
<a style="hyperlinkFOOBAR" href="http://hunmr.blogspot.com">blog</a>
题
EDIT1 org-export-as-html可以导出链接,但不能为Hi-lock创建CSS。
感谢您的帮助,我们将非常乐意为您提供帮助。
org-export-as-html应该是DTRT
感谢@Andreas的提示,我将下面的代码添加到htmlize.el中。 目前,组织链接可以被html化为可点击的链接。
代码在github上共享:
https://github.com/whunmr/dotemacs/blob/master/site-lisp/htmlize.el
和
http://hunmr.blogspot.com/2012/08/enhance-htmlizeel-now-can-export-org.html
以下是主要代码:
(defun expand-org-link (&optional buffer)
"Change [[url][shortname]] to [[url] [shortname]] by adding a space between url and shortname"
(goto-char (point-min))
(while (re-search-forward "[[([^][]+)]([([^][]+)])?]"
nil t)
(let ((url (match-string 1))
(link-text (match-string 3)))
(delete-region (match-beginning 0) (match-end 0))
(insert "[[" url "] [" link-text "]]"))))
(defun shrink-org-link (&optional buffer)
"Change [[url] [shortname]] to [[url][shortname]], remove the space between url and shortname"
(goto-char (point-min))
(while (re-search-forward "[[([^][]+)] ([([^][]+)])?]"
nil t)
(let ((url (match-string 1))
(link-text (match-string 3)))
(delete-region (match-beginning 0) (match-end 0))
(insert "[[" url "][" link-text "]]"))))
(defun transform-org-link ()
"transform htmlized <span> to <a>"
(goto-char (point-min))
(while (re-search-forward "[[<span ([^>]+)>([^][]+)</span>] [([^][]+)]]"
nil t)
(let ((style (match-string 1))
(url (match-string 2))
(link-text (match-string 3)))
(delete-region (match-beginning 0) (match-end 0))
(insert "<a " style " href="" url "">" link-text "</a>"))))
链接地址: http://www.djcxy.com/p/30637.html
上一篇: In Emacs, How to export Links to a clickable link, when htmlize emacs buffer?