LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1082|回复: 0

有谁用过htmlize.el,我实在是搞不定了啊(解决了)

[复制链接]
发表于 2008-7-30 01:27:00 | 显示全部楼层 |阅读模式
[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的文档,其实这是个小插件,文档就写在插件里面,说明的很简单:
  1. ;; This package converts the buffer text and the associated
  2. ;; decorations to HTML.  Mail to <hniksic@xemacs.org> to discuss
  3. ;; features and additions.  All suggestions are more than welcome.

  4. ;; To use this, just switch to the buffer you want HTML-ized and type
  5. ;; `M-x htmlize-buffer'.  You will be switched to a new buffer that
  6. ;; contains the resulting HTML code.  You can edit and inspect this
  7. ;; buffer, or you can just save it with C-x C-w.  `M-x htmlize-file'
  8. ;; will find a file, fontify it, and save the HTML version in
  9. ;; FILE.html, without any additional intervention.  `M-x
  10. ;; htmlize-many-files' allows you to htmlize any number of files in
  11. ;; the same manner.  `M-x htmlize-many-files-dired' does the same for
  12. ;; files marked in a dired buffer.

  13. ;; htmlize supports three types of HTML output, selected by setting
  14. ;; `htmlize-output-type': `css', `inline-css', and `font'.  In `css'
  15. ;; mode, htmlize uses cascading style sheets to specify colors; it
  16. ;; generates classes that correspond to Emacs faces and uses <span
  17. ;; class=FACE>...</span> to color parts of text.  In this mode, the
  18. ;; produced HTML is valid under the 4.01 strict DTD, as confirmed by
  19. ;; the W3C validator.  `inline-css' is like `css', except the CSS is
  20. ;; put directly in the STYLE attribute of the SPAN element, making it
  21. ;; possible to paste the generated HTML to other documents.  In `font'
  22. ;; mode, htmlize uses <font color="...">...</font> to colorize HTML,
  23. ;; which is not standard-compliant, but works better in older
  24. ;; browsers.  `css' mode is the default.

  25. ;; You can also use htmlize from your Emacs Lisp code.  When called
  26. ;; non-interactively, `htmlize-buffer' and `htmlize-region' will
  27. ;; return the resulting HTML buffer, but will not change current
  28. ;; buffer or move the point.
复制代码

我于是按照最简单的使用方法,不加载什么muse,单独在一个buffer里面随便打些内容,用M-x htmlize-buffer,依旧提示“invalid face”
打开emacs的debug-on-error,详细出错信息如下:
  1. Debugger entered--Lisp error: (error "Invalid face")
  2.   internal-get-lisp-face-attribute(nil :height nil)
  3.   face-attribute(nil :height)
  4.   (setq h (face-attribute f :height))
  5.   (while (progn (setq f ...) (not ...)) (setq h (face-attribute f :height)) (push (if ... nil h) --cl-var--) (setq --cl-var-- nil))
  6.   (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--))
  7.   (catch (quote --cl-block-nil--) (let* (... ... ... ...) (while ... ... ... ...) (nreverse --cl-var--)))
  8.   (cl-block-wrapper (catch (quote --cl-block-nil--) (let* ... ... ...)))
  9.   (block nil (let* (... ... ... ...) (while ... ... ... ...) (nreverse --cl-var--)))
  10.   (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))
  11.   (let ((size-list ...)) (reduce (quote htmlize-merge-size) (cons nil size-list)))
  12.   htmlize-face-size(default)
  13.   (let ((size ...)) (unless (eql size 1.0) (setf ... size)))
  14.   (cond (htmlize-running-xemacs (let* ... ... ... ... ...)) ((fboundp ...) (dolist ... ...) (let ... ...)) (t (when ... ...) (when ... ...) (setf ... ...)))
  15.   (let ((fstruct ...)) (cond (htmlize-running-xemacs ...) (... ... ...) (t ... ... ...)) (setf (htmlize-fstruct-css-name fstruct) (let ... ... ... ... ... ... ... name)) fstruct)
  16.   htmlize-face-to-fstruct(default)
  17.   (if (symbolp face) (htmlize-face-to-fstruct face) (htmlize-attrlist-to-fstruct face))
  18.   (let ((fstruct ...)) (setf (gethash face face-map) fstruct) (let* (... ... ...) (while ... ...) (unless ... ...) (push new-name css-names)))
  19.   (if (gethash face face-map) nil (let (...) (setf ... fstruct) (let* ... ... ... ...)))
  20.   (unless (gethash face face-map) (let (...) (setf ... fstruct) (let* ... ... ... ...)))
  21.   (while --cl-dolist-temp-- (setq face (car --cl-dolist-temp--)) (unless (gethash face face-map) (let ... ... ...)) (setq --cl-dolist-temp-- (cdr --cl-dolist-temp--)))
  22.   (let ((--cl-dolist-temp-- faces) face) (while --cl-dolist-temp-- (setq face ...) (unless ... ...) (setq --cl-dolist-temp-- ...)) nil)
  23.   (catch (quote --cl-block-nil--) (let (... face) (while --cl-dolist-temp-- ... ... ...) nil))
  24.   (cl-block-wrapper (catch (quote --cl-block-nil--) (let ... ... nil)))
  25.   (block nil (let (... face) (while --cl-dolist-temp-- ... ... ...) nil))
  26.   (dolist (face faces) (unless (gethash face face-map) (let ... ... ...)))
  27.   (let ((face-map ...) css-names) (dolist (face faces) (unless ... ...)) face-map)
  28.   htmlize-make-face-map((default font-lock-comment-face font-lock-comment-delimiter-face))
  29.   (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)
  30.   (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))
  31.   htmlize-buffer-1()
  32.   (save-current-buffer (set-buffer (or buffer ...)) (htmlize-buffer-1))
  33.   (with-current-buffer (or buffer (current-buffer)) (htmlize-buffer-1))
  34.   (let ((htmlbuf ...)) (when (interactive-p) (switch-to-buffer htmlbuf)) htmlbuf)
  35.   htmlize-buffer()
  36.   call-interactively(htmlize-buffer t nil)
  37.   execute-extended-command(nil)
  38.   call-interactively(execute-extended-command nil nil)
复制代码

我找了很久,似乎关于htmlize配置的资料很少,而且我想,按照作者的说明,如果不自己设置什么格式的话,不用配置也可以用吧?
哎,我不懂LISP,看来实在是搞不定了,请高手帮忙指点一下!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表