Function: org-html-htmlize-generate-css

org-html-htmlize-generate-css is an autoloaded, interactive and byte-compiled function defined in ox-html.el.gz.

Signature

(org-html-htmlize-generate-css)

Documentation

Create the CSS for all font definitions in the current Emacs session.

Use this to create face definitions in your CSS style file that can then be used by code snippets transformed by htmlize. This command just produces a buffer that contains class definitions for all faces used in the current Emacs session. You can copy and paste the ones you need into your CSS file.

The face definitions are prepended with org-html-htmlize-font-prefix.

If you then set org-html-htmlize-output-type to css, calls to the function org-html-htmlize-region-for-paste will produce code that uses these same face definitions.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-html.el.gz
;;;###autoload
(defun org-html-htmlize-generate-css ()
  "Create the CSS for all font definitions in the current Emacs session.
Use this to create face definitions in your CSS style file that can then
be used by code snippets transformed by htmlize.
This command just produces a buffer that contains class definitions for all
faces used in the current Emacs session.  You can copy and paste the ones you
need into your CSS file.

The face definitions are prepended with
`org-html-htmlize-font-prefix'.

If you then set `org-html-htmlize-output-type' to `css', calls
to the function `org-html-htmlize-region-for-paste' will
produce code that uses these same face definitions."
  (interactive)
  (org-require-package 'htmlize)
  (and (get-buffer "*html*") (kill-buffer "*html*"))
  (with-temp-buffer
    (let ((fl (face-list))
	  (htmlize-css-name-prefix org-html-htmlize-font-prefix)
	  (htmlize-output-type 'css)
	  f i)
      (while fl
        (setq f (pop fl)
	      i (and f (face-attribute f :inherit)))
	(when (and (symbolp f) (or (not i) (not (listp i))))
	  (insert (org-add-props (copy-sequence "1") nil 'face f))))
      (htmlize-region (point-min) (point-max))))
  (pop-to-buffer-same-window "*html*")
  (goto-char (point-min))
  (when (re-search-forward "<style" nil t)
    (delete-region (point-min) (match-beginning 0)))
  (when (re-search-forward "</style>" nil t)
    (delete-region (1+ (match-end 0)) (point-max)))
  (forward-line 0)
  (when (looking-at " +") (replace-match ""))
  (goto-char (point-min)))