在你的.emacs中加入下列代码
;; add a <source> tag, which use source-highlight
(defun muse-publish-source-tag (beg end attrs)
(let ((lang (cdr (assoc "lang" attrs)))
(style (muse-style-element :base))
hcodes)
(if (string-equal style "pdf") (setq style "latex"))
(if lang
(progn
(muse-publish-command-tag
beg end
(cons (cons "interp" (format "echo /"<literal><pre class=/"example/">
$(source-highlight -s %s -f %s)
</pre></literal>/"" lang style))
attrs))
(muse-publish-mark-read-only beg (point)))
(error "No lang attribute specified in <source> tag"))))
(add-to-list
'muse-publish-markup-tags '("source" t t nil muse-publish-source-tag))
然后即可在你的muse文件中高亮代码了
#include <stdlib.h>
const char so_interp[] __attribute__((section(".interp")))
= "/lib/ld-linux.so.2";
int soso(int i){
return i*i;
}
void so_start(void){
int argc;
__asm__ (
"movl 0x14(%%esp), %%eax/n"
: "=a" (argc));
exit(argc);hcodes))
}
上面效果的muse源文件:
* 使用source-highlight在Muse中高亮代码
** 在你的.emacs中加入下列代码
<example>
;; add a <source> tag, which use source-highlight
(defun muse-publish-source-tag (beg end attrs)
(let ((lang (cdr (assoc "lang" attrs)))
(style (muse-style-element :base))
hcodes)
(if (string-equal style "pdf") (setq style "latex"))
(if lang
(progn
(muse-publish-command-tag
beg end
(cons (cons "interp" (format "echo /"<literal><pre class=/"example/">
$(source-highlight -s %s -f %s)
</pre></literal>/"" lang style))
attrs))
(muse-publish-mark-read-only beg (point)))
(error "No lang attribute specified in <source> tag"))))
(add-to-list
'muse-publish-markup-tags '("source" t t nil muse-publish-source-tag))
</example>
** 然后即可在你的muse文件中高亮代码了
<source lang="c">
#include <stdlib.h>
const char so_interp[] __attribute__((section(".interp")))
= "/lib/ld-linux.so.2";
int soso(int i){
return i*i;
}
void so_start(void){
int argc;
__asm__ (
"movl 0x14(%%esp), %%eax/n"
: "=a" (argc));
exit(argc);hcodes))
}
</source>