From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: exporting HTML - content only Date: Mon, 27 Jun 2011 11:56:45 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbGzK-0002vl-TX for emacs-orgmode@gnu.org; Mon, 27 Jun 2011 14:56:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QbGzI-0000dJ-9R for emacs-orgmode@gnu.org; Mon, 27 Jun 2011 14:56:50 -0400 Received: from mail-pz0-f41.google.com ([209.85.210.41]:34057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbGzH-0000dB-Ob for emacs-orgmode@gnu.org; Mon, 27 Jun 2011 14:56:48 -0400 Received: by pzk4 with SMTP id 4so3825981pzk.0 for ; Mon, 27 Jun 2011 11:56:45 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Tamas K Papp Cc: emacs-orgmode@gnu.org Hi Tamas, As a partial solution for you, here is the latest complete solution for me. Perhaps you can tailor it to your needs. I also include a pretty fast exact word count command. Samuel (defconst alpha-org-blog-html-buffer "alpha-org-blog.html") (defun alpha-org-blog-subtree () "Copy the subtree, converted to HTML, for pasting into Blogger as a blog post. If there is an active region, use that instead. No other software needs to be installed. No temporary file is created. For an example of this code in action, see http://thekafkapandemic.blogspot.com/ . === You have to turn off Blogger's conversion of newline to br tags in two places in settings. This requires the new Blogger post editor. The HTML code is left in a buffer. To display it in a browser, use M-x browse-url-of-buffer or similar. mail2blogger is a very intriguing option here and I'd like to do that. Avoids the web entirely. See comments. === The top level headline is not interpreted with Blogger title semantics. By default it is not exported at all, because Blogger already has a title. For both posts and pages, Blogger's title field forms the URL and is therefore manually entered. === Advanced: You can export the top level headline with :title:. For pasting into Blogger, I don't do this, because it shows up with what looks like two titles. In the future, we can make it work with backends like mail2blogger. Then it will have title semantics (the top level will become the title). In Blogger, pages are different from posts. They are accessed by tabs like About, Contribute, Contact. :title: is also useful if you want to try a different strategy. I did this for my first blog post. You can change whether to include title fields in Blogger settings. You can only do this for posts. Turning off titles has one convenience: you don't have to enter them manually. It also has two drawbacks: (1) people who link to your post by copying that link cannot do so (they can get it from other places, including the URL bar and Archives in the sidebar) and (2) the URL gets formed a litle funnily. === I use Blogger.com for hosted blogging instead of Wordpress.com because Google has a better attitude toward accessibility. " (interactive) ;;; todo list ;;; ;;; === mail2blogger === ;;; ;;; I tried using mail2blogger, but the HTML got posted. There might ;;; be a way to fix this. How do you do an HTML email in a format ;;; that gets recognized as HTML? ;;; ;;; We want to use raw programmatic email, such as sent using msmtp ;;; or the built-in Emacs client. The ability to do so will obviate ;;; the need to use Google's command line client or to run Emacs 23. ;;; ;;; Patch welcome. ;;; ;;; === ;;; ;;; Another good thing to try would be to automate grabbing the source from ;;; the page automatically to compare what you just created with ediff or ;;; git diff --color-words. This is for edits. ;;; ;;; Also, export whole blog before each post for git. Requires post ;;; method maybe. How to do that? ;;; ;;; Also, check for fixmes. (Or org could check for fixmes before ;;; all export. Is there a hook?) ;;; ;;; Also, remind you to extract big chunks of comments for possible ohter ;;; blog entries. ;;; ;;; /Also, remind you to make sure all links work and review formatting/. ;;; ;;; === ;;; ;;; Is there HTML for a title? I will guess not. ;;say about to publish editing or about to publish post. with ;;mail2blogger or weblogger.el or atom, we can automate this and assume ;;publish. ;; ;;technically, this should be later in case you kill something inside the ;;note. for some reason org adds this to the post command hook instead of ;;just doing it at the time. need to get this to just do it. maybe ;;call-interactively will work? no, that does not fix it. ;; ;;(let ((k kill-ring)) ;;(let ((c (car kill-ring))) ;;(org-add-note) (save-excursion (save-window-excursion ;;i have an issue with "--", which is perfect for emdash in ascii, but ;;gets converted to endash in html. i'd like it to be emdash in html. ;;is there an option for that? ;;org converts headlines to html h numbers according to the level in ;;the org file, not the level in the region. i prefer the latter. ;; ;;here we kludge it to do it my way. ;; ;;top 1 means that the very top level in org is h1 (even if you don't ;;export it because you manually enter a title). it is large. the ;;second level in org is h2. ;; ;;blogger does not format h2 bold on firefox in the watermark ;;template. so h3 looks bigger than h2. removing the h2 css in edit ;;html seems to fix things. so all you have to do is make sure level ;;2 in org is a bit smaller than title. you can do that by making org ;;level 2 start with h3 or lower level to make org level 2 smaller. ;; ;;therefore, we start with h3. if we used the top level headline ;;(using the :title: tag), we could start with top 3. = h3. ;; ;;but usually we don't use the top level headline, so we use top 2 = ;;h2 (the one that doesn't work). thus the second level in org = h3 ;;which is just right. so, after all, we don't really need to fix h2 ;;in the template. (but fixing h2 in the template is possibly a good ;;idea because it seems to affect h3 somehow.) ;; ;;fixme test top semantics with title (let ((top 2)) (unless (org-region-active-p) (outline-mark-subtree)) (unless (member "title" (org-get-tags)) ;;remove title (forward-line 1) ;;might be nice to add hr here ;;we will start with the first headilne's title ;;(decf top)) ) (switch-to-buffer (let ((org-export-html-toplevel-hlevel (+ top -1 (- org-export-html-toplevel-hlevel (org-reduced-level (org-current-level))))) (org-export-headline-levels (+ top -1 (- org-export-headline-levels (org-reduced-level (org-current-level))))) org-export-with-tags org-export-with-todo-keywords org-export-with-timestamps ;;note: priority must be after todo kw for export ;;already nil org-export-with-priority ) (org-export-region-as-html (region-beginning) (region-end) t ;;seems to erase, which we want (get-buffer-create ;;this should work if it is a ;;*buffer* but some might prefer html ;;mode. this does not save to a file ;;unless you do. alpha-org-blog-html-buffer))) ;;one drawback is it leaves spaces around text. like "tag> text". ;;(hoka-unfill-region-special (point-min) (point-max)) ;;(goto-char (point-min)) ;;this does not work because it will join lines with no space in between; ;;we have to actually fill paragraphs. ;;; (while (search-forward "\n" nil t) ;;; (replace-match "")) ;;; (insert "\n") ;;unnec if blogger knows to treat whitespace as insignificant ;;; (goto-char (point-min)) ;;; (delete-matching-lines "^$") (kill-ring-save (point-min) (point-max)))) (setq header-line-format "html output") ;;return this for programmatic use (current-buffer))) ;;(setq deactivate-mark t) ) (defun alpha-org-wc () "Run wc(1) on the formatted subtree or active region. Because it is formatted using w3m, the word count is exact. Currently this will save in the kill ring also." (interactive) (save-excursion (save-window-excursion ;;need to make this not save in kill ring (switch-to-buffer (alpha-org-blog-subtree)) (w3m-region 1 (buffer-size)) (setq header-line-format "temporary formatted output for wc (not html)") ;;(call-interactively 'browse-url-of-buffer) ;;print (shell-command-on-region (point-min) (point-max) "wc") ;;now return the value itself (switch-to-buffer "*Shell Command Output*") (goto-char (point-min)) (forward-word 1) ;;mark-word ;;string-to-number (buffer-substring (region-beginning ... ;;(prog1 ... (bury-buffer) (read (current-buffer))))) -- The Kafka Pandemic: http://thekafkapandemic.blogspot.com I support the Whittemore-Peterson Institute (WPI) === Bigotry against people with serious diseases is still bigotry.