* Re: exporting HTML - content only
2011-06-27 14:18 exporting HTML - content only Tamas K Papp
@ 2011-06-27 15:40 ` Ian Barton
2011-06-27 16:00 ` Pierre de Buyl
2011-06-27 16:54 ` Christian Moe
2011-06-27 18:56 ` Samuel Wales
2 siblings, 1 reply; 5+ messages in thread
From: Ian Barton @ 2011-06-27 15:40 UTC (permalink / raw)
To: emacs-orgmode
On 27/06/11 15:18, Tamas K Papp wrote:
> Hi,
>
> I started using org-mode to write blog posts for posting on
> blogger.com. I am aware of org-googlecl, but I am looking for a more
> lightweight solution to the following problem:
>
> How can I export only the _content_ of a page as HTML into a buffer?
>
> Specifically,
>
> 1. I only want the stuff inside the<div id="content"> ...</div>,
> 2. Disabling the generation of a H1 heading from the title,
> 3. no postamble/preamble.
>
> I would like to give the appropriate options at the beginning of the
> file to achieve this and just do C-c C-e H or something similar, but I
> don't know what options to use.
>
> I can do all of this manually, but automating it would be easier.
>
Have a look at
http://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html.
Specifically you need to set :body-only t in your
org-publish-project-alist. However, I am not sure how you can set up
publishing to a buffer, rather than a file.
Ian.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: exporting HTML - content only
2011-06-27 14:18 exporting HTML - content only Tamas K Papp
2011-06-27 15:40 ` Ian Barton
@ 2011-06-27 16:54 ` Christian Moe
2011-06-27 18:56 ` Samuel Wales
2 siblings, 0 replies; 5+ messages in thread
From: Christian Moe @ 2011-06-27 16:54 UTC (permalink / raw)
To: Tamas K Papp; +Cc: emacs-orgmode
Hi,
try all or part of this:
- select a region to export
- do C-u C-c C-e R
(C-u prefix: body only, R: region only)
Yours,
Christian
On 6/27/11 4:18 PM, Tamas K Papp wrote:
> Hi,
>
> I started using org-mode to write blog posts for posting on
> blogger.com. I am aware of org-googlecl, but I am looking for a more
> lightweight solution to the following problem:
>
> How can I export only the _content_ of a page as HTML into a buffer?
>
> Specifically,
>
> 1. I only want the stuff inside the<div id="content"> ...</div>,
> 2. Disabling the generation of a H1 heading from the title,
> 3. no postamble/preamble.
>
> I would like to give the appropriate options at the beginning of the
> file to achieve this and just do C-c C-e H or something similar, but I
> don't know what options to use.
>
> I can do all of this manually, but automating it would be easier.
>
> Thanks,
>
> Tamas
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: exporting HTML - content only
2011-06-27 14:18 exporting HTML - content only Tamas K Papp
2011-06-27 15:40 ` Ian Barton
2011-06-27 16:54 ` Christian Moe
@ 2011-06-27 18:56 ` Samuel Wales
2 siblings, 0 replies; 5+ messages in thread
From: Samuel Wales @ 2011-06-27 18:56 UTC (permalink / raw)
To: Tamas K Papp; +Cc: emacs-orgmode
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.
^ permalink raw reply [flat|nested] 5+ messages in thread