我想在一个org-babel源码块的注释上有一些超链接。我的目标是将文件导出为html,并能够跟踪一些引用,如下面的最小示例所示:
#+BEGIN_SRC lisp
(princ "Hello World!") ;; [[stackoverflow.com/blabla1234][Got this from SO.]]
#+END_SRC“问题”是链接不会嵌入到源代码块中(这实际上很有意义)。
有没有一种方法可以覆盖这种行为,或者有一种替代的语法可以在src块中插入超链接?
发布于 2016-05-24 12:15:25
现在可能还不可能(从org-mode 8.3.4开始)。HTML导出引擎目前似乎没有用于转义受保护字符的机制。您应该提交实现它或提交功能请求!(details)
一些解决方法:
用原始的HTML模拟输出
您可以输出看起来像源块的原始HTML,它将以完整的链接呈现:
#+BEGIN_HTML
<pre class="src src-sh">
(princ "Hello World!") ;; <a href="stackoverflow.com/blabla1234">Got this from SO.</a>
</pre>
#+END_HTML防止替换如果代码中没有大于和小于的符号,则可以防止它们被替换为
(setq org-html-protect-char-alist '(("&" . "&"))或者,如果这不起作用:
(setq htmlize-basic-character-table
;; Map characters in the 0-127 range to either one-character strings
;; or to numeric entities.
(let ((table (make-vector 128 ?\0)))
;; Map characters in the 32-126 range to themselves, others to
;; &#CODE entities;
(dotimes (i 128)
(setf (aref table i) (if (and (>= i 32) (<= i 126))
(char-to-string i)
(format "&#%d;" i))))
;; Set exceptions manually.
(setf
;; Don't escape newline, carriage return, and TAB.
(aref table ?\n) "\n"
(aref table ?\r) "\r"
(aref table ?\t) "\t"
;; Escape &, <, and >.
(aref table ?&) "&"
;;(aref table ?<) "<"
;;(aref table ?>) ">"
;; Not escaping '"' buys us a measurable speedup. It's only
;; necessary to quote it for strings used in attribute values,
;; which htmlize doesn't typically do.
;(aref table ?\") """
)
table))请注意,这两种方法都是不能转义HTML标记分隔符本身的技巧。如果语法突出显示应用于任何字符,它将通过插入<span>来断开生成的超文本标记语言链接。
https://stackoverflow.com/questions/37302756
复制相似问题