emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] publish regression: body-only (with patch)


From: Eric Schulte
Subject: Re: [Orgmode] publish regression: body-only (with patch)
Date: Sun, 24 May 2009 16:05:37 -0700
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.92 (darwin)

Richard KLINDA <address@hidden> writes:

>>>>>> Regarding 'Re: [Orgmode] publish regression: body-only (with patch)'; 
>>>>>> Carsten Dominik adds:
>
>
>   > Hi Richard, this feature has never existed as something usable from
>   > publishing.  Can you provide a realistic case when something like
>   > this would be useful?
>
> Oh, then my patch did not make it into org back then.:) I am going to
> use org just to render the "content" part of my site, the menus, comment
> section, tag cloud, interlinking (by date, topic etc) will be generated
> by a CMS.
>
> As I think about it, it seems fairly trivial just to rip out the
> <body>(...)</body> part of the generated HTML, so I'm ready to accept if
> you don't want this into org.

I also find the need to extract just the body portion of exported html
pages.  This is done in blorgit[1], if you don't mind using ruby for
your extraction the following may prove useful (extracts body optionally
including the title and postamble).

#+begin_src ruby 
def to_html(h_path, options = {})
  html = File.read(h_path)
  return html if options[:full_html]
  # extract the body portion
  start_body = (html =~ /<body>/) + 6
  end_body = (html =~ /<\/body>/) - 1
  body = html[(start_body..end_body)]
  body = options[:postamble] ? body : body[(0..(body.index("<div 
id=\"postamble\">") - 1))]
  options[:title] ? body : body.sub(/<h1.*\/h1>/i,'')
end
#+end_src

Cheers -- Eric

[1] http://orgmode.org/worg/blorgit.php




reply via email to

[Prev in Thread] Current Thread [Next in Thread]