emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: dongdigua <dongdigua@outlook.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-faq.org: rename org-export-htmlize-* options to org-html-htmlize-*
Date: Thu, 04 Apr 2024 11:27:51 +0000	[thread overview]
Message-ID: <87a5m92wqw.fsf@localhost> (raw)
In-Reply-To: <875y77wm6u.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 363 bytes --]

Ihor Radchenko <yantar92@posteo.net> writes:

> dongdigua <dongdigua@outlook.com> writes:
>
>> sorry, my email client wrapped the lines
>
> Thanks!
> I looked into this again, and I can see that the FAQ entry is dubious.
> ...
> So, we need a much more significant rewrite to make this FAQ entry up to
> date.

See the attached alternative version of the patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-faq.org-How-can-I-preserve-faces.-Update-answer.patch --]
[-- Type: text/x-patch, Size: 3951 bytes --]

From 3d6e938c09f896c9c55575b318829d2ef7d1c9ea Mon Sep 17 00:00:00 2001
Message-ID: <3d6e938c09f896c9c55575b318829d2ef7d1c9ea.1712229941.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Thu, 4 Apr 2024 14:22:01 +0300
Subject: [PATCH] org-faq.org (How can I preserve faces...): Update answer

* org-faq.org (How can I preserve faces when I export an agenda from
the command line?): Fix the answer, making sure that the instructions
actually work on the latest Org mode.

Link: https://list.orgmode.org/orgmode/PS2P216MB113830307EE638A1FF044F55A024A@PS2P216MB1138.KORP216.PROD.OUTLOOK.COM/
---
 org-faq.org | 51 +++++++++++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/org-faq.org b/org-faq.org
index 3674165c..f2b7d510 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -3643,41 +3643,48 @@ ** How can I preserve faces when I export an agenda from the command line?
 #+index: Export!Agenda
 #+index: Export!Faces
 
-Normally, when you export an org file or an agenda view from within
-emacs, htmlize will convert your face definitions to direct color css
-styles inlined into each =<span>= object, resulting in an HTML output
-that preserves the general look of your Org buffers and agenda views.
+Normally, when you export an agenda view from within emacs, htmlize
+will convert your face definitions to direct color css styles inlined
+into each =<span>= object, resulting in an HTML output that preserves
+the general look of your Org buffers and agenda views.
 
 Let's say you generate an export from the command line, such as the
 following:
 
-: emacs -batch -l ~/.emacs -eval '(org-batch-agenda "e")'
-
-or
-
-: emacs -batch -l ~/.emacs -eval '(org-publish-all)'
+: emacs -batch -l ~/.emacs.d/init.el \
+: -eval '(progn \
+:         (org-agenda nil "a") \
+:         (org-agenda-write "~/agenda.html"))'
 
 In such an instance, the exported HTML will contain only very basic
 color styles. The reason is that when Emacs is run in batch mode, it
 does not have a display and therefore only rudimentary face
 definitions.  If you'd like to use more complex styles, you'll have to
-make sure that the export process only assigns classes instead of
-direct color values.  This can be done by binding the variable
-=org-export-htmlize-output-style= to =css= for the duration of the
-export, for example with
-
-: emacs -batch -l ~/.emacs
-:   -eval '(let ((org-export-htmlize-generate-css (quote css)))
-:            (org-batch-agenda "e"))'
+supply custom css styles to make these classes look any way you like.
+To generate face definitions for a CSS file based on any faces you are
+currently using in Emacs, you can use the following command:
 
-Then you can use a style file to make these classes look any way you
-like.  To generate face definitions for a CSS file based on any faces
-you are currently using in Emacs, you can use the following command:
+#+begin_src emacs-lisp
+(defun org-html-htmlize-generate-css-for-agenda ()
+  "Create the CSS for all font definitions in the current Emacs session.
+Unlike `org-html-htmlize-generate-css', do not prepend
+`org-html-htmlize-font-prefix' to face names."
+  (interactive)
+  (require 'ox-html)
+  (let ((org-html-htmlize-font-prefix ""))
+    (org-html-htmlize-generate-css)))
+#+end_src
 
-: M-x org-export-htmlize-generate-css RET
+: M-x org-html-htmlize-generate-css-for-agenda RET
 
 This will generate a =<style>...</style>= section, the content of
-which you can add to your style file.
+which you can manually copy to your style file:
+
+: emacs -batch -l ~/.emacs.d/init.el \
+: -eval '(let ((org-agenda-export-html-style \
+:               "<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">")) \
+:         (org-agenda nil "a") \
+:         (org-agenda-write "~/agenda.html"))'
 
 ** How can I avoid dark color background when exporting agenda to ps format?
    :PROPERTIES:
-- 
2.44.0


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2024-04-04 11:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 15:29 [PATCH] org-faq.org: rename org-export-htmlize-* options to org-html-htmlize-* dongdigua
2023-06-28 17:06 ` Ihor Radchenko
2024-04-04 11:27   ` Ihor Radchenko [this message]
2024-04-04 19:55     ` Rudolf Adamkovič
2024-04-05 13:58       ` Ihor Radchenko
2024-04-12 18:00         ` Ihor Radchenko
  -- strict thread matches above, loose matches on Subject: below --
2023-06-07  2:40 dongdigua
2023-06-14 12:22 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5m92wqw.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=dongdigua@outlook.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).