在Emacs中,当htmlize emacs缓冲区时如何将链接导出到可点击的链接?

背景

  • 我用伟大的htmlize.el来导出我的org模式缓冲区内容与字体hi-lock。
  • 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-mode链接导出为HTML?
  • 要使用elisp读取组织模式缓冲区中的真实链接,该怎么做? 阅读文本属性?
  • 感谢您的帮助,我们将非常乐意为您提供帮助。


    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?

    下一篇: How can I "linkify" a non