|
|
[color="Red"]问题已解决,见帖子:http://www.linuxsir.cn/bbs/showthread.php?p=1882814#post1882814
最近在学习使用muse,我特别需要用到它的代码高亮的功能,看了一下muse的文档,说要使用src tag,必须有htmlize.el的支持,于是搞了个htmlize.el,然后问题就来了,总是出错,把htmlize移除,则可以正常生成html文件,但是这样就没有代码高亮了(如果没有htmlize的支持,muse自动把src标签当作example标签处理,所以没有高亮)。
看来问题在htmlize上,我于是看了一下htmlize的文档,其实这是个小插件,文档就写在插件里面,说明的很简单:
- ;; This package converts the buffer text and the associated
- ;; decorations to HTML. Mail to <hniksic@xemacs.org> to discuss
- ;; features and additions. All suggestions are more than welcome.
- ;; To use this, just switch to the buffer you want HTML-ized and type
- ;; `M-x htmlize-buffer'. You will be switched to a new buffer that
- ;; contains the resulting HTML code. You can edit and inspect this
- ;; buffer, or you can just save it with C-x C-w. `M-x htmlize-file'
- ;; will find a file, fontify it, and save the HTML version in
- ;; FILE.html, without any additional intervention. `M-x
- ;; htmlize-many-files' allows you to htmlize any number of files in
- ;; the same manner. `M-x htmlize-many-files-dired' does the same for
- ;; files marked in a dired buffer.
- ;; htmlize supports three types of HTML output, selected by setting
- ;; `htmlize-output-type': `css', `inline-css', and `font'. In `css'
- ;; mode, htmlize uses cascading style sheets to specify colors; it
- ;; generates classes that correspond to Emacs faces and uses <span
- ;; class=FACE>...</span> to color parts of text. In this mode, the
- ;; produced HTML is valid under the 4.01 strict DTD, as confirmed by
- ;; the W3C validator. `inline-css' is like `css', except the CSS is
- ;; put directly in the STYLE attribute of the SPAN element, making it
- ;; possible to paste the generated HTML to other documents. In `font'
- ;; mode, htmlize uses <font color="...">...</font> to colorize HTML,
- ;; which is not standard-compliant, but works better in older
- ;; browsers. `css' mode is the default.
- ;; You can also use htmlize from your Emacs Lisp code. When called
- ;; non-interactively, `htmlize-buffer' and `htmlize-region' will
- ;; return the resulting HTML buffer, but will not change current
- ;; buffer or move the point.
复制代码
我于是按照最简单的使用方法,不加载什么muse,单独在一个buffer里面随便打些内容,用M-x htmlize-buffer,依旧提示“invalid face”
打开emacs的debug-on-error,详细出错信息如下:
- Debugger entered--Lisp error: (error "Invalid face")
- internal-get-lisp-face-attribute(nil :height nil)
- face-attribute(nil :height)
- (setq h (face-attribute f :height))
- (while (progn (setq f ...) (not ...)) (setq h (face-attribute f :height)) (push (if ... nil h) --cl-var--) (setq --cl-var-- nil))
- (let* ((f nil) (h nil) (--cl-var-- nil) (--cl-var-- t)) (while (progn ... ...) (setq h ...) (push ... --cl-var--) (setq --cl-var-- nil)) (nreverse --cl-var--))
- (catch (quote --cl-block-nil--) (let* (... ... ... ...) (while ... ... ... ...) (nreverse --cl-var--)))
- (cl-block-wrapper (catch (quote --cl-block-nil--) (let* ... ... ...)))
- (block nil (let* (... ... ... ...) (while ... ... ... ...) (nreverse --cl-var--)))
- (loop for f = face then (face-attribute f :inherit) until (eq f (quote unspecified)) for h = (face-attribute f :height) collect (if (eq h ...) nil h))
- (let ((size-list ...)) (reduce (quote htmlize-merge-size) (cons nil size-list)))
- htmlize-face-size(default)
- (let ((size ...)) (unless (eql size 1.0) (setf ... size)))
- (cond (htmlize-running-xemacs (let* ... ... ... ... ...)) ((fboundp ...) (dolist ... ...) (let ... ...)) (t (when ... ...) (when ... ...) (setf ... ...)))
- (let ((fstruct ...)) (cond (htmlize-running-xemacs ...) (... ... ...) (t ... ... ...)) (setf (htmlize-fstruct-css-name fstruct) (let ... ... ... ... ... ... ... name)) fstruct)
- htmlize-face-to-fstruct(default)
- (if (symbolp face) (htmlize-face-to-fstruct face) (htmlize-attrlist-to-fstruct face))
- (let ((fstruct ...)) (setf (gethash face face-map) fstruct) (let* (... ... ...) (while ... ...) (unless ... ...) (push new-name css-names)))
- (if (gethash face face-map) nil (let (...) (setf ... fstruct) (let* ... ... ... ...)))
- (unless (gethash face face-map) (let (...) (setf ... fstruct) (let* ... ... ... ...)))
- (while --cl-dolist-temp-- (setq face (car --cl-dolist-temp--)) (unless (gethash face face-map) (let ... ... ...)) (setq --cl-dolist-temp-- (cdr --cl-dolist-temp--)))
- (let ((--cl-dolist-temp-- faces) face) (while --cl-dolist-temp-- (setq face ...) (unless ... ...) (setq --cl-dolist-temp-- ...)) nil)
- (catch (quote --cl-block-nil--) (let (... face) (while --cl-dolist-temp-- ... ... ...) nil))
- (cl-block-wrapper (catch (quote --cl-block-nil--) (let ... ... nil)))
- (block nil (let (... face) (while --cl-dolist-temp-- ... ... ...) nil))
- (dolist (face faces) (unless (gethash face face-map) (let ... ... ...)))
- (let ((face-map ...) css-names) (dolist (face faces) (unless ... ...)) face-map)
- htmlize-make-face-map((default font-lock-comment-face font-lock-comment-delimiter-face))
- (let* ((buffer-faces ...) (face-map ...) (htmlbuf ...) (places ...) (title ...)) (with-current-buffer htmlbuf (buffer-disable-undo) (insert ... 10 ... "<html>\n ") (plist-put places ... ...) (insert "<head>\n" " <title>" ... "</title>\n" ... htmlize-head-tags) (htmlize-method insert-head buffer-faces face-map) (insert " </head>") (plist-put places ... ...) (insert "\n ") (plist-put places ... ...) (insert ... "\n ") (plist-put places ... ...) (insert "<pre>\n")) (let (... next-change text face-list fstruct-list trailing-ellipsis) (goto-char ...) (while ... ... ... ... ... ... ... ... ... ...)) (with-current-buffer htmlbuf (insert "</pre>") (plist-put places ... ...) (insert "\n </body>") (plist-put places ... ...) (insert "\n</html>\n") (when htmlize-generate-hyperlinks ...) (htmlize-defang-local-variables) (when htmlize-replace-form-feeds ... ...) (goto-char ...) (when htmlize-html-major-mode ...) (set ... places) (run-hooks ...) (buffer-enable-undo)) htmlbuf)
- (save-excursion (save-excursion (run-hooks ...)) (htmlize-ensure-fontified) (clrhash htmlize-extended-character-cache) (clrhash htmlize-memoization-table) (let* (... ... ... ... ...) (with-current-buffer htmlbuf ... ... ... ... ... ... ... ... ... ... ... ...) (let ... ... ...) (with-current-buffer htmlbuf ... ... ... ... ... ... ... ... ... ... ... ... ...) htmlbuf))
- htmlize-buffer-1()
- (save-current-buffer (set-buffer (or buffer ...)) (htmlize-buffer-1))
- (with-current-buffer (or buffer (current-buffer)) (htmlize-buffer-1))
- (let ((htmlbuf ...)) (when (interactive-p) (switch-to-buffer htmlbuf)) htmlbuf)
- htmlize-buffer()
- call-interactively(htmlize-buffer t nil)
- execute-extended-command(nil)
- call-interactively(execute-extended-command nil nil)
复制代码
我找了很久,似乎关于htmlize配置的资料很少,而且我想,按照作者的说明,如果不自己设置什么格式的话,不用配置也可以用吧?
哎,我不懂LISP,看来实在是搞不定了,请高手帮忙指点一下! |
|