all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org for blogger
@ 2012-09-01  2:39 Rustom Mody
  2012-09-01  2:56 ` Samuel Wales
  2012-09-01  5:37 ` Puneeth Chaganti
  0 siblings, 2 replies; 14+ messages in thread
From: Rustom Mody @ 2012-09-01  2:39 UTC (permalink / raw)
  To: emacs-orgmode

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

What is the best way to use orgmode to prepare posts for blogger?

Sorry if this is a FAQ; I did google around and best I get is
http://orgmode.org/worg/org-blog-wiki.html which does not seem to have
something specifically for blogger.

Note I am asking about preparing the html so that it is blogger-friendly.
It can then be manually posted into the html tab.
Automatically posting/uploading etc is a second question but that is not my
primary focus as of now.

[-- Attachment #2: Type: text/html, Size: 541 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01  2:39 org for blogger Rustom Mody
@ 2012-09-01  2:56 ` Samuel Wales
  2012-09-01  4:14   ` Rustom Mody
  2012-09-01  5:37 ` Puneeth Chaganti
  1 sibling, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2012-09-01  2:56 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

On 8/31/12, Rustom Mody <rustompmody@gmail.com> wrote:
> Note I am asking about preparing the html so that it is blogger-friendly.
> It can then be manually posted into the html tab.

I have code for exactly this, but it is not packagized and not all of
it will work for you without tweaking.  It comes with explanation of
what Blogger needs.  I posted a working version long ago, and it has
been updated since, but now requires a few odds and ends from my
setup, so it is not self-contained.  It is slowly (years) being
packagized.

I will try to soon post the new code FWIW.  I run my blog with it.
The neatest feature is that you can diff an updated entry with the
live version.

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01  2:56 ` Samuel Wales
@ 2012-09-01  4:14   ` Rustom Mody
  2012-09-01 15:24     ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Rustom Mody @ 2012-09-01  4:14 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

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

On Sat, Sep 1, 2012 at 8:26 AM, Samuel Wales <samologist@gmail.com> wrote:

> On 8/31/12, Rustom Mody <rustompmody@gmail.com> wrote:
> > Note I am asking about preparing the html so that it is blogger-friendly.
> > It can then be manually posted into the html tab.
>
> I have code for exactly this, but it is not packagized and not all of
> it will work for you without tweaking.  It comes with explanation of
> what Blogger needs.  I posted a working version long ago, and it has
> been updated since, but now requires a few odds and ends from my
> setup, so it is not self-contained.  It is slowly (years) being
> packagized.
>
> I will try to soon post the new code FWIW.  I run my blog with it.
> The neatest feature is that you can diff an updated entry with the
> live version.
>
>
Great Samuel!
Anything I can do to help?
[I am more comfortable with emacs and elisp than html/css and all that
jazz. But Ive been known to learn... somethings... sometimes...  :-) ]

[-- Attachment #2: Type: text/html, Size: 1414 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01  2:39 org for blogger Rustom Mody
  2012-09-01  2:56 ` Samuel Wales
@ 2012-09-01  5:37 ` Puneeth Chaganti
  2012-09-01 11:04   ` Alexandre Russel
  1 sibling, 1 reply; 14+ messages in thread
From: Puneeth Chaganti @ 2012-09-01  5:37 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

On Sat, Sep 1, 2012 at 8:09 AM, Rustom Mody <rustompmody@gmail.com> wrote:
> What is the best way to use orgmode to prepare posts for blogger?
>
> Sorry if this is a FAQ; I did google around and best I get is
> http://orgmode.org/worg/org-blog-wiki.html which does not seem to have
> something specifically for blogger.

I haven't used it, but there's org2blog/atom by tehom --
http://repo.or.cz/r/org2blog.git/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01  5:37 ` Puneeth Chaganti
@ 2012-09-01 11:04   ` Alexandre Russel
  2012-09-01 11:15     ` Tongzhu Zhang
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Russel @ 2012-09-01 11:04 UTC (permalink / raw)
  To: Puneeth Chaganti; +Cc: Rustom Mody, emacs-orgmode

I've seen some code that would help but never found the use. I have my
blog in one org file with one entry per level. To create the blog, I:
1. C-C C-e (for export)
2. 1 (to switch from export buffer to export subtree)
3. H (export as html to temp buffer)
4. copy/paste the <div id="content">...</div> into blogger

What else do  you need ?

Alex

On Sat, Sep 1, 2012 at 7:37 AM, Puneeth Chaganti <punchagan@gmail.com> wrote:
> On Sat, Sep 1, 2012 at 8:09 AM, Rustom Mody <rustompmody@gmail.com> wrote:
>> What is the best way to use orgmode to prepare posts for blogger?
>>
>> Sorry if this is a FAQ; I did google around and best I get is
>> http://orgmode.org/worg/org-blog-wiki.html which does not seem to have
>> something specifically for blogger.
>
> I haven't used it, but there's org2blog/atom by tehom --
> http://repo.or.cz/r/org2blog.git/
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 11:04   ` Alexandre Russel
@ 2012-09-01 11:15     ` Tongzhu Zhang
  0 siblings, 0 replies; 14+ messages in thread
From: Tongzhu Zhang @ 2012-09-01 11:15 UTC (permalink / raw)
  To: Alexandre Russel; +Cc: emacs-orgmode, Rustom Mody

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

I wrote an exporter for Jekyll(based on o-blog), i use it for my blog , to
export post from a orgmode file  based on the DONE state and CLOSED
timestamp

https://github.com/eggcaker/jo-exporter

On Sat, Sep 1, 2012 at 7:04 PM, Alexandre Russel <alexandre@russel.fr>wrote:

> I've seen some code that would help but never found the use. I have my
> blog in one org file with one entry per level. To create the blog, I:
> 1. C-C C-e (for export)
> 2. 1 (to switch from export buffer to export subtree)
> 3. H (export as html to temp buffer)
> 4. copy/paste the <div id="content">...</div> into blogger
>
> What else do  you need ?
>
> Alex
>
> On Sat, Sep 1, 2012 at 7:37 AM, Puneeth Chaganti <punchagan@gmail.com>
> wrote:
> > On Sat, Sep 1, 2012 at 8:09 AM, Rustom Mody <rustompmody@gmail.com>
> wrote:
> >> What is the best way to use orgmode to prepare posts for blogger?
> >>
> >> Sorry if this is a FAQ; I did google around and best I get is
> >> http://orgmode.org/worg/org-blog-wiki.html which does not seem to have
> >> something specifically for blogger.
> >
> > I haven't used it, but there's org2blog/atom by tehom --
> > http://repo.or.cz/r/org2blog.git/
> >
>
>

[-- Attachment #2: Type: text/html, Size: 1931 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01  4:14   ` Rustom Mody
@ 2012-09-01 15:24     ` Samuel Wales
  2012-09-01 15:52       ` Rustom Mody
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2012-09-01 15:24 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

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

On 8/31/12, Rustom Mody <rustompmody@gmail.com> wrote:
> Great Samuel!
> Anything I can do to help?

Dunno.  :)

Here is the new code (with dependencies not included as
mentioned).  Most of it, including the command you asked for,
might work without them.  No guarantees.

An old version is in the thread "[O] exporting HTML
- content only", with Tamas Papp and others.

Alexandre, a few small things are needed to produce a blog
to my standards: H level fix, diff with live, footnote CSS
fix, exact and fast word count, emdash, section
separator, jump page marker, colored boxes with padding and
margin, Blogger editor settings, org-export-with-*, etc.

If the defaults work for you, there is no need to use
anything like this.

It was written over years a few minutes
at a time.  Again, it was written for me.

FWIW, HTH.

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

[-- Attachment #2: alpha-org-export.el --]
[-- Type: application/octet-stream, Size: 29280 bytes --]

;;;
;;;my /public/ code for org-mode export
;;;
;;;this is meant for myself and is in slow (years) transition to
;;;be useful for others.  please use what you like.  it might
;;;have dependencies, but some things might work without those.
;;;
;;;loading is intended to be mostly side-effect-free.  set
;;;alpha-alpha-p to non-nil before loading if you want to try all
;;;of my settings.
;;;
;;;load after loading org
;;;
;;;see alpha-org-export-map for some bindings
;;;
;;;contains various things, such as
;;;  an HTML subtree exporter
;;;    works with Blogger
;;;    with level adjustment
;;;    with Emacs and external previewers
;;;  diff HTML output with live version (<- neatest feature)
;;;  an exact word counter
;;;  my section separators and emdash
;;;

;;;
;;;Copyright (C) 2010-2012  Samuel Wales
;;;  with some code written earlier but not released
;;;
;;;This file is free software; you can redistribute it and/or
;;;modify it under the terms of the GNU General Public License as
;;;published by the Free Software Foundation; either version 3,
;;;or (at your option) any later version.
;;;
;;;This file is distributed in the hope that it will be useful,
;;;but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;GNU General Public License for more details.
;;;
;;;You should have received a copy of the GNU General Public
;;;License along with Emacs.  If not, see
;;;<http://www.gnu.org/licenses/>.
;;;

;;;for more source code see org and grep for begin_src emacs-lisp ka

;;;    ;; delete superfluous blank lines (is there a better way?)
;;;    (goto-char (point-min))
;;;    (while (re-search-forward "\n\n+" nil t)
;;;      (previous-line)
;;;      (delete-blank-lines))))

(defvar alpha-org-export-map
  (make-sparse-keymap "alpha org export map"))
(define-key org-mode-map (kbd "C-c h") alpha-org-export-map)
(define-key alpha-org-export-map "a" 
  'alpha-org-export-as-ascii-to-buffer)
(define-key alpha-org-export-map "c" 'alpha-org-wc)
(define-key alpha-org-export-map "d" 'alpha-org-blog-diff)
(define-key alpha-org-export-map "e" 'alpha-org-blog-subtree-external)
(define-key alpha-org-export-map "h" 'alpha-org-blog-subtree)
(define-key alpha-org-export-map "w" 'alpha-org-blog-subtree-w3m)

(defconst alpha-org-blog-html-buffer "alpha-org-blog.html")
;;load this after loading org
(defun* alpha-org-blog-subtree (&key nocopy)
  "Copy the subtree, converted to HTML, for pasting into Blogger
as a blog post.  If there is an active region, use that instead.

This also works generically, because Blogger uses a subset of
HTML.  So it could really be called `alpha-org-export-subtree'.

No other software needs to be installed.  No temporary file is
created.  No 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 settings and in the new Blogger post editor (the old editors
do not have that option) and in the Blogger pages editor (if you
use pages).  This makes Blogger more compatible.  Extra blank
lines are normally ignored in HTML (w3m and Firefox on .html), so
it makes sense to make Blogger ignore them instead of converting
them.  Org sometimes leaves extra blank lines, so it makes a
difference.

The HTML code is left in a buffer that is one buffer away in the
buffer ring.  To display it in a browser, use M-x
browse-url-of-buffer or similar, but you can also use my wrappers
that do it directly for you.

===

The top level headline by default is not exported, because
Blogger already has a title.  For both posts and pages, Blogger's
title field forms the URL and is therefore manually entered.

===

Org variables:

You can control what gets exported with org-export-with-*.  For a
blog, you almost always want to set most of those variables to
nil.  But just in case you want to control export with them,
/this command will not make those choices for you/.  I also find
that (setf org-export-headline-levels 10) is useful.

===

Advanced:

With non-interactive keyword NOCOPY, don't save the output in
the kill ring.

===

I use Blogger.com for hosted blogging instead of Wordpress.com
because Google has a better attitude toward accessibility.
"
  (interactive)

;;; :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.  Only do this if you have a special reason.

;;; todo list
;;;   
;;; === mail2blogger ===
;;; 
;;; mail2blogger is an intriguing option.  Avoids the web entirely.
;;;
;;; 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.
;;; 
;;; Patch welcome.
;;; 
;;; ===
;;; 
;;; 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/.
;;;
  
  ;;say about to publish editing or about to publish post.  with
  ;;mail2blogger or weblogger.el or atom, we can automate this
  ;;and assume publish.
  
  (save-excursion
    (save-window-excursion
      ;;
      ;;headline levels:
      ;;
      ;;org converts headlines to html h numbers according to the
      ;;level in the org file, not the level in the region.
      ;;
      ;;here we do it my way.
      ;;
      ;;top 1 means that the very top level in your org subtree
      ;;is h1.  it is large.  the second level in org is h2 and
      ;;so on.  this is true whether you use the :title: tag or
      ;;not.  (i do not use it.)
      ;;
      ;;best to set top to be what the title is set to in
      ;;blogger (unless you want to skip an h level).
      ;;
      ;;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.
      ;;
      ;;fixing h2 in the template is still useful even if we
      ;;don't use it for headlines.  in the watermark template it
      ;;affects gadget title font, which is imo a bug in
      ;;watermark.  it might affect h3 somehow.
      ;;
      ;;footnote header in org also uses h2.  i think it is
      ;;hardcoded.  it would be better for our purposes if it
      ;;were configurable.  we want it to be the same level as
      ;;our non-title top level, which is h3 = second level in
      ;;org.  here we would set its h level to top + 1.  fixme
      ;;make a feature request.
      ;;
      ;;at top 2, you can simply use the org variable to set top
      ;;hlevel.  so top is a constant here and can be ignored or
      ;;hardcoded.
      (let ((top 2))
        (unless (org-region-active-p)
          (outline-mark-subtree))
        (unless (member "title" (org-get-tags))
          (forward-line 1))
        (switch-to-buffer
         (let ((org-export-html-toplevel-hlevel
                ;;adjust h level.  fixme we can hardcode top to 1
                ;;here.
                (+ top -1 (- org-export-html-toplevel-hlevel
                             (org-reduced-level (org-current-level)))))
               (org-export-headline-levels
                ;;adjust the point at which headlines become list
                ;;items.  org does this by file instead of
                ;;region.
                (+ -1
                   org-export-headline-levels
                   (org-reduced-level (org-current-level))))
               ;;
               ;;the user can set variables for the common case.
               ;;
               ;;to not export anything with a non-blank todo kw,
               ;;set org-export-with-tasks to nil.  i do this.
               ;;
               ;;note: priority must be after todo kw for export
               ;;already nil org-export-with-priority
               )
           
           ;;we do our own copying.  fixme however, we do not
           ;;currently wrap with anything that we want to copy,
           ;;so in principle we can decide to copy or not here,
           ;;and not do a copy below.
           ;;(let ((org-export-copy-to-kill-ring (not nocopy)))
           (let ((org-export-copy-to-kill-ring))
             (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.
                                         ;;
                                         ;;(or buf
                                         alpha-org-blog-html-buffer)))))
        
        ;;org doesn't seem to include a newline at the end.  this
        ;;is useful for diffing live with org cleanly.
        (goto-char (point-max))
        (insert "\n")
        
        ;;(message "kill ring %s" (length (first kill-ring)))
        
        (unless nocopy
          ;;(message "Copying to kill ring")
          (kill-ring-save (point-min) (point-max))))
      (setq header-line-format "html output")
      (goto-char (point-min))
      ;;return this for programmatic use
      (current-buffer)))
  ;;(setq deactivate-mark t)
  )

(defun alpha-org-blog-subtree-w3m ()
  (interactive)
  (let ((browse-url-browser-function 'alpha-w3m-browse-url))
    (browse-url-of-buffer (alpha-org-blog-subtree :nocopy t))))
  ;;w3m screws up buffer list ordering.  dunno how to fix that
  ;;except like this.
  ;;(save-window-excursion (switch-to-buffer b))))
(defconst alpha-org-blog-test-width "570px"
  "The width of your blog column for testing.")
;;(setf alpha-org-blog-test-width-style t)
;;(setf alpha-org-blog-test-width-style nil)
(defvar alpha-org-blog-test-width-style t)
(defun alpha-org-blog-subtree-external ()
  "Force external browser.

Set width to test a relatively narrow column.

Currently only works on OSX."
;;; This is so that you can test in a browser to emulate the
;;; column size you use in your blog.  It is not for export to
;;; your final product.
  (interactive)
  (save-window-excursion
    (switch-to-buffer (alpha-org-blog-subtree :nocopy t))
  
    ;;make a narrow column for testing
    (goto-char (point-min))
    (when alpha-org-blog-test-width-style
      ;;fix footnotes by adding a header or preamble or whatever.
      ;;we can move this head section to the blog export if we
      ;;want, just have to be careful as there might already be a
      ;;head section.  ok to do?
      ;;
      ;;but this specifically is a non-canonical copy for
      ;;testing.
      (insert "
<style type=\"text/css\">
<!--/*--><![CDATA[/*><!--*/
sup {
  font-size: 1ex;
  vertical-align: super;
  line-height: 0;
}
/*]]>*/-->
</style>
"
              ))
    ;;(insert (format "<div style=\"color: black; background-color: #ebdeb2; width: %s;\">\n\n"
    (insert (format "<div style=\"width: %s;\">\n\n"
                    alpha-org-blog-test-width))
    (goto-char (point-max))
    (insert "\n\n</div>\n")
    ;;does external (browse-url-of-buffer)
    (let ((browse-url-browser-function
           ;;'(("." . hoka-w3m-browse-url-new-tab-new-and-go))))
           ;;'(("." . alpha-w3m-browse-url))))
           '(("." . browse-url-default-macosx-browser))))
      (browse-url-of-buffer))))

;;; (defun alpha-test-overlay ()
;;;   (interactive)
;;;   (let ((o (make-overlay (point) (+ (point) 6))))
;;;     (overlay-put o 'display (propertize "test 1" 'face 'diff-added))
;;;     (push o alpha-test-overlays)))
;;; (defvar alpha-test-overlays ())

(defun alpha-org-wc ()
  "Run wc(1) on the formatted subtree or active region.  It is
formatted using w3m, so the word count is exact.

Horizontal rules are counted as words, because w3m + wc say they
are."
  (interactive)
  (save-excursion
    (save-window-excursion
      ;;:buf (get-buffer-create "*wc*")
      (switch-to-buffer (alpha-org-blog-subtree :nocopy t))
      (setq header-line-format
            "temporary formatted output for wc (not html)")
      (w3m-region 1 (buffer-size))
      ;;(call-interactively 'browse-url-of-buffer)
      (shell-command-on-region (point-min) (point-max) "wc")
      ;;for once we don't want to keep this around in the buffer
      ;;list, so we use 'norecord.
      (switch-to-buffer "*Shell Command Output*" 'norecord)
      (goto-char (point-min))
      ;;the url
      (forward-word 1)
      ;;mark-word
      ;;string-to-number (buffer-substring (region-beginning ...
      ;;(prog1 ... (bury-buffer)
      (read (current-buffer)))))

(defun alpha-org-blog-diff ()
  "Compare the current subtree to its live version.

This is for Blogger blogs, but with a modification to generalize
the extraction, it can work for any web page.

The trick is to extract the post from the live version.  This
might or might not work with your blog template.
"
  (interactive)
  (let* ((property "Live-URL")
         (url (or (alpha-org-entry-get property)
                  (let ((given (read-string "Live URL: ")))
                    (org-set-property property given)
                    given)))
         (live (save-excursion
                 ;;fixme
                 (alpha-url url)
                 ;;some issue with ebuffers, can't debug.  this
                 ;;shouldn't technically be necessary and is moot
                 ;;because alpha-diff-buffers is superior to
                 ;;ebuffers here anyway.
                 ;;(fundamental-mode)
                 
                 (goto-char (point-min))
                 ;;extract (actually narrow to) the post itself.
                 (narrow-to-region
                  (progn
                    (search-forward
                     "<div class='post-body entry-content'")
                    (forward-line 1)
                    (point))
                  (progn
                    (search-forward
                     ;;fixme this is too nonspecific.  is there a
                     ;;way to find the matching /div?
                     "<div style='clear: both;'></div>")
                    (beginning-of-line)
                    (point)))
                 
                 ;;there is a strange problem with ^M characters
                 ;;when you dl your blog sometimes.  i don't know
                 ;;why it inserts those.  shouldn't it do
                 ;;everything the unix way if you are using unix?
                 ;;
                 ;;alpha-cleandiff solves the problem, but it
                 ;;looks nicer in ediff to remove them
                 (goto-char (point-min))
                 (while (search-forward "\r" nil t)
                   (replace-match "" nil t))
                 (rename-buffer " live blog" t)))
         (org (save-excursion
                (switch-to-buffer (alpha-org-blog-subtree :nocopy t))
                ;;again with this
                ;;(fundamental-mode)
                (rename-buffer " org blog" t))))
    (alpha-diff-buffers live org)))

;;;
;;;this might be relevant to my :header-ignore: and
;;;:header-blank: idea, which lets you insert headers that don't
;;;export (but the body exports) (i also want hyphens in tags):
;;;
;;; from suvayu, but modified
;;; 
;;; (add-hook 'org-export-preprocess-hook 'my-org-export-preprocess-hook)
;;; (defun my-org-export-preprocess-hook ()
;;;  "My backend specific export preprocess hook."
;;;  (save-excursion
;;;    (if (eq org-export-current-backend 'latex)
;;;        (let* ((tag "ignoreheading"))         ; Thanks to Nick for this
;;;          (org-map-entries (lambda ()
;;;                             (delete-region (point-at-bol) (point-at-eol)))
;;;                           (concat ":" tag ":")))))

;;;for new exporter:
;;; #+BEGIN_SRC emacs-lisp
;;; (defun my-e-latex-headline (headline contents info)
;;;  (if (member "ignoreheading" (org-element-property :tags headline)) contents
;;;    (org-e-latex-headline headline contents info)))
;;; #+END_SRC
;;; 
;;; Then you can either install it in the current `e-latex' back-end:
;;; 
;;; #+BEGIN_SRC emacs-lisp
;;; (add-to-list 'org-e-latex-translate-table '(headline . my-e-latex-headline))
;;; #+END_SRC
;;; 
;;; Or you can define your own back-end for this purpose:
;;; 
;;; #+BEGIN_SRC emacs-lisp
;;; (org-export-define-derived-backend dissertation e-latex
;;;  :translate-alist ((template . my-e-latex-headline)))
;;; 
;;; (defun org-dissertation-export-to-pdf
;;;  (&optional subtreep visible-only body-only ext-plist pub-dir)
;;;  (interactive)
;;;  (org-e-latex-compile
;;;   (let ((outfile (org-export-output-file-name ".tex" subtreep pub-dir)))
;;;     (org-export-to-file
;;;      'dissertation outfile subtreep visible-only body-only ext-plist))))
;;; #+END_SRC
;;; --nic

(when (= emacs-major-version 22)
  ;;this is redefinition.  fixme.  it is for 22 backcompatibility
  ;;for export.
  (defcustom select-active-regions nil
    "If non-nil, an active region automatically becomes the window selection."
    :type 'boolean
    :group 'killing
    :version "23.1")

  (defun activate-mark ()
    "Activate the mark."
    (when (mark t)
      (setq mark-active t)
      (unless transient-mark-mode
        (setq transient-mark-mode 'lambda))
      (when (and select-active-regions
                 (display-selections-p))
        (x-set-selection 'PRIMARY (current-buffer))))))

(defun alpha-org-export-as-ascii-to-buffer ()
  "Fix a few things."
  (interactive)
  (org-mark-subtree)
  (org-export-as-ascii-to-buffer nil)
  ;;need to do this in the buffer (deactivate-mark)
  
  ;; (goto-char (point-min))
  ;; (insert "=== remember to check for comments")
  
  ;; or use the hook
  (alpha-replace-re "^  " "")
  ;;for proportional fonts
  (alpha-replace-re "^=====*$" "=====\n")
  ;;for monospace fonts
;;;   (alpha-replace-re "^=====*$" "\\&\n")
  (delete-other-windows))


;; from mailing list:
;; 
;; #+begin_src emacs-lisp
;; (defun my-flush-old-comment-syntax (backend)
;;   (while (re-search-forward "^#[^ \t+]" nil t)
;;     (when (memq (org-element-type (org-element-at-point))
;;                 '(paragraph verse-block))
;;       (delete-region (line-beginning-position)
;;                      (progn (forward-line) (point))))))
;; 
;; (add-hook 'org-export-before-parsing-hook 'my-flush-old-comment-syntax)
;; #+end_src
;; 
;; modified from mailing list
(defun my-old-comment-syntax-warning (&optional backend)
  (message "checking for old-style comments")
  (goto-char (point-min))
  (when (re-search-forward "^#[^ \t+]" nil t)
    (or (yes-or-no-p "Old-style comment syntax.  Still proceed? ")
        (error "Export aborted"))))

(defun alpha-org-export-settings--new-exporter ()
  ;;make new exporter available -- not currently using though
  ;;(require 'org-export)
  (eval-after-load 'org-export
    '(progn
      (add-hook 'org-export-before-parsing-hook 'my-old-comment-syntax-warning)
      
      ;;this fixes interpretation of ===, but will also unfortunately
      ;;change ~ emphasis to = -- could just do the string itself, but
      ;;then it would remove the equals signs.
      ;;
      ;;what i would like is for it to leave the equals signs in,
      ;;without changing ~
      (setf org-e-ascii-verbatim-format "=%s=")
;;; (defun org-e-ascii-verbatim (verbatim contents info)
;;;  "Return a VERBATIM object from Org to ASCII.
;;; CONTENTS is nil.  INFO is a plist holding contextual
;;; information."
;;;  (let ((marker (org-element-get-property :marker verbatim))
;;;        (value (org-element-get-property :value verbatim)))
;;;    (concat marker value marker)))
      (setf org-e-ascii-inner-margin 0)
      ;;(setf org-export-show-temporary-export-buffer nil)
      ;;(setf org-export-show-temporary-export-buffer t)
      ;;(setf org-e-ascii-quote-margin 4)
      ;;fill-column
      (setf org-e-ascii-text-width alpha-fill-column-letter)
;;; (setf org-e-ascii-text-width 99999)
      ;;supposedly this makes lists set off by 2 in new exporter
      (add-to-list 'org-export-filter-plain-list-functions
       (lambda (plain-list back-end)
         (if (not (eq back-end 'e-ascii))
             plain-list
             (replace-regexp-in-string "^" "  " plain-list)))))))
;;; You may want to test this advice, which will convert a table
;;; to tsv if "#+attr_ascii: tsv" is set above the table.  --
;;does not work -- infinite loop
;;; (defadvice org-e-ascii-table (around table-tsv)
;;;   (if (or (not (member "tsv"
;;;                        (org-element-get-property :attr_ascii table)))
;;;           (eq (org-element-get-property :type table) 'table.el))
;;;       ad-do-it
;;;     (setq ad-return-value
;;;           (orgtbl-to-tsv
;;;            (org-table-to-lisp
;;;             (org-element-get-property :raw-table table)) nil))))

(defun alpha-org-export-settings ()
  (add-hook 'org-export-preprocess-hook 'my-old-comment-syntax-warning)

  ;;(setq org-export-show-temporary-export-buffer nil)

  ;;does this need loading after org-exp?
  (setf org-export-initial-scope 'subtree)

  ;;
  ;;section separator and entities
  ;;

  ;;make changes that allow export to ascii and html from the same
  ;;document look good.
  ;;
  ;;this variable is only html so should be very limited to just
  ;;the stuff i need in ordinary ascii to become special in html.
  ;;fixme /if you use latex then fix it the same way/.  dunno what
  ;;variable.  have to ask on ml.  or maybe it reverse matches with
  ;;entities .
  ;;
  ;;the point is convenience -- not having to use \entity
  ;;(org-entities).  i don't know why this doesn't just translate
  ;;into entity instead.
  ;;
  ;;i think i want to turn off --- and remove duplicates here.
  ;;most things should be backend-independent \entities.
  ;;
  ;;e.g. just use \ndash for ascii and html and latex
  ;;
  ;;If you need such a symbol inside a word, terminate it like
  ;;this: `\Aacute{}stor'.  -- not my style but possible
  (setf org-export-html-special-string-regexps
        `(
          ;;remove this comment when fix macros.
          ;;
          ;;org removes the whole line as a comment if
          ;;#+alpha-image: -- which hook to use?  can it still be
          ;;done before macros if so?
          ;;
          ;;ideal here is $[image ...] but cannot really parse
          ;;
          ;;this should not be inside a paragraph ka.  will need to
          ;;use a hook instead ka.
          ;;
          ;;this actually fails.  because link expansion is done
          ;;somehow before this?  and is therefore no longer on the
          ;;line?  i guess i have to file bug report on macros and
          ;;use macros instead or do this in some hook.
;;;         ("^=== xyzzy image \\(.*\\)$" .
;;;          "
;;; <div \
;;; class=\"separator\" \
;;; style=\"width: 400px; clear: both; text-align: center;\">
;;; \\1
;;; </div> \
;;; ")
        
          ;;need --- before -- because else it will be interpreted
          ;;as --.
          ;;
          ;;likewise with ^----- if -- or --- allow newline.
          ;;
          ;;i might allow newline after -- or ---.
          ;;
          ;;if i do, it causes issues with ----- and obsolete ---
          ;;section separators, but does not allow --$ after a
          ;;quote (i.e. to quote you have to say who you are
          ;;quoting even if it is obvious).
          ;;
          ;;workaround is putting ----- here explicitly if allow
          ;;newline, and space at eol if not allow newline.
          ;;
          ;;fixme i might want to exclude - in front of these so
          ;;that long stretches of -- --- ---- ----- ------ do not
          ;;get translated.
          ;;
          ;;unlike org ^-----, this ends up surrounded with <p>
          ("^-----$" . "<hr/>")         ;see also === below
          ("---\\([^-]\\|$\\)" . "&mdash;\\1")
          ;;do i want non-greedy here?  if so ?  after the \\).
;;;        ("^\\(.+\\)---\\([^-]\\|$\\)" . "\\1&mdash;\\2")

          ;;alpha -- for mdash.  also i allow newline now
          ;;
          ;; /this will screw up some things (as will the default)/
          ;;for example, @<!-- more -->
          ("--\\([^-]\\|$\\)" . "&mdash;\\1")
          ;;alpha separator
          ;;
          ;;alternative: make a headline for every section and do
          ;;:headersection:
          ;;
          ;;fixme consider === or ~---~ which are ascii
          ;;=== is my trademark in ascii
          ;;\mdash\mdash\mdash is long and looks non-centered
          ("^===$" .
           ;;http://www.w3schools.com/tags/att_standard_style.asp
           ;;says ; is a separator but in css it is a terminator.
           ;;
           ;;i think no ; in the tag and no trailing ; in the style
           "<hr width=\"10%\" style=\"width:10%;color:#000;background-color:#000;height:1px;border:none\" />")
;;;          "<hr width=\"10%\"; style=\"width:10%;color:#000;background-color:#000;height:1px;border:none;\" />")
          ;;this can be div, p, or span.  the purpose is roughly
          ;;equidistant from all 3 concepts.  however, it isn't a
          ;;paragraph, so i strike p off.  it has no nearby text so
          ;;i strike span off.
          ;;
;;;          ;;fixme font-weight notwork
;;;          "<div font-weight:dim; align=\"center\">\\\\--\\\\--\\\\--</div>")
;;;          "<div font-weight:dim; align=\"center\">\\\\--\\\\--\\\\--</div>")
;;;         ("^===$" . "<div align=\"center\">---------</div>")
          ,@org-export-html-special-string-regexps))

  (setq org-export-email-info nil)
  (setq org-export-author-info nil)
  (setq org-export-creator-info nil)
  ;;fixme confirm that this does not work in blogger.  if it
  ;;does, then we can export a style, which is a huge win.  see
  ;;my mailing list messages on the topic.
  ;;
  ;;actually it does not export anyway unless you call using c-c
  ;;c-e H.  so if i want this i have to change export to not do
  ;;body only or something.
  ;;
  ;;but it does work in blogger seemingly at least for preview.
  ;;so i can use styles?  but it actually moves the title of the
  ;;whole blog over to the center.
  ;;
;;; (setq org-export-html-preamble t)
  (setq org-export-html-preamble nil)
  (setq org-export-html-postamble nil)

  (setf org-export-headline-levels 10)

  ;;i have not yet figured out how i want inline tasks to work
  (setf org-inlinetask-export nil)

  ;;btw it would be nice for blogs if we could put toc at the end
  ;;of the document
  ;;
  ;;fixme make this interactive
;;; (setf org-export-with-toc t)
  (setf org-export-with-toc nil)
  ;;if i do export toc and have ts in the headline, i want the ts
  (setf org-export-remove-timestamps-from-toc nil)
  ;;this looks interesting, but how do you tell the user how to
  ;;grab the anchor?  how do you even grab it yourself?
  ;;
  ;;toc is the only real way -- unless you make this additionally
  ;;turn headlines into links to themselves.  which would be
  ;;great.
  ;;
  ;;apparently this defaults to true.
  ;;
  ;;org-export-html-headline-anchor-format

  (setf org-export-with-tags nil)
  ;;i prefer this to the noexport tag because noexport sets other
  ;;trees to export by default with possibly confusing semantics.
  (setf org-export-with-tasks nil)      ;the entire subtree

  ;;stuff where the default is ok or in practice ok:
  ;;default (setf org-export-with-timestamps t)
  ;;(setf org-export-with-todo-keywords nil) ;moot if no tasks
  ;;default is wrong, does not seem to work in html, i do not need
  ;;it in html.  so it works fine.
  ;;
  ;;the reason it does not work is that it only works if you export
  ;;using c-c c-e A and similar.
  ;;org-export-with-section-numbers

  ;;try this both ways
  ;;(setf org-export-ascii-links-to-notes nil)

  ;;this is perhaps the most error-prone export feature.
  ;;underscores are common (but I always prefer hyphens)
  (setf org-export-with-sub-superscripts nil)

  ;;i don't use strike-through
  ;;where is remove-from-list?
  (setf org-emphasis-alist
        (remove* "+" org-emphasis-alist
                 :key #'car
                 :test #'equal)))

(when (bound-and-true-p alpha-alpha-p)
  (alpha-org-export-settings--new-exporter)
  (alpha-org-export-settings))


(provide 'alpha-org-export)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 15:24     ` Samuel Wales
@ 2012-09-01 15:52       ` Rustom Mody
  2012-09-01 16:00         ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Rustom Mody @ 2012-09-01 15:52 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

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

On Sat, Sep 1, 2012 at 8:54 PM, Samuel Wales <samologist@gmail.com> wrote:

> On 8/31/12, Rustom Mody <rustompmody@gmail.com> wrote:
> > Great Samuel!
> > Anything I can do to help?
>
> Dunno.  :)
>
> Here is the new code (with dependencies not included as
> mentioned).  Most of it, including the command you asked for,
> might work without them.  No guarantees.
>
> An old version is in the thread "[O] exporting HTML
> - content only", with Tamas Papp and others.
>
> Alexandre, a few small things are needed to produce a blog
> to my standards: H level fix, diff with live, footnote CSS
> fix, exact and fast word count, emdash, section
> separator, jump page marker, colored boxes with padding and
> margin, Blogger editor settings, org-export-with-*, etc.
>
> If the defaults work for you, there is no need to use
> anything like this.
>
> It was written over years a few minutes
> at a time.  Again, it was written for me.
>
> FWIW, HTH.
>
> Samuel
>

Looks neat Samuel Thanks!

I needed to put a (require 'cl) [for the defun*] and then evaling the file
went through.
After that I get (from *messages* buffer)

byte-code: Invalid function: (interblock (start end) (mapcar (lambda (pair)
(funcall (second pair) start end)) org-export-interblocks))

when trying to call alpha-org-blog-subtree.
Is that what I should call?

[-- Attachment #2: Type: text/html, Size: 1848 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 15:52       ` Rustom Mody
@ 2012-09-01 16:00         ` Samuel Wales
  2012-09-01 16:16           ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2012-09-01 16:00 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

On 9/1/12, Rustom Mody <rustompmody@gmail.com> wrote:
> I needed to put a (require 'cl) [for the defun*] and then evaling the file
> went through.

Fixed, thanks.

> byte-code: Invalid function: (interblock (start end) (mapcar (lambda (pair)
> (funcall (second pair) start end)) org-export-interblocks))

Is that in Org *.el?

> when trying to call alpha-org-blog-subtree.
> Is that what I should call?

Yes.

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 16:00         ` Samuel Wales
@ 2012-09-01 16:16           ` Samuel Wales
  2012-09-01 16:55             ` Rustom Mody
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2012-09-01 16:16 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

On 9/1/12, Samuel Wales <samologist@gmail.com> wrote:
>> byte-code: Invalid function: (interblock (start end) (mapcar (lambda
>> (pair)
>> (funcall (second pair) start end)) org-export-interblocks))

Did you try in a minimal installation?

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 16:16           ` Samuel Wales
@ 2012-09-01 16:55             ` Rustom Mody
  2012-09-01 17:02               ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Rustom Mody @ 2012-09-01 16:55 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

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

On Sat, Sep 1, 2012 at 9:46 PM, Samuel Wales <samologist@gmail.com> wrote:

> On 9/1/12, Samuel Wales <samologist@gmail.com> wrote:
> >> byte-code: Invalid function: (interblock (start end) (mapcar (lambda
> >> (pair)
> >> (funcall (second pair) start end)) org-export-interblocks))
>
> Did you try in a minimal installation?
>
> Samuel
>
> --
> The Kafka Pandemic: http://thekafkapandemic.blogspot.com
>

Seems to be working now.
Not sure what was wrong but it appears that I needed to do a make (have not
done it for org for some years) after that the error disappeared.

It seems I can only export one subtree on which point is.
How to export the whole file?

[-- Attachment #2: Type: text/html, Size: 1158 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 16:55             ` Rustom Mody
@ 2012-09-01 17:02               ` Samuel Wales
  2012-09-02  3:37                 ` Rustom Mody
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2012-09-01 17:02 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

On 9/1/12, Rustom Mody <rustompmody@gmail.com> wrote:
> Seems to be working now.
> Not sure what was wrong but it appears that I needed to do a make (have not
> done it for org for some years) after that the error disappeared.

Great.

> It seems I can only export one subtree on which point is.
> How to export the whole file?

Create a top level headline, or activate the region on the whole buffer.

I never do things at the file level in Org, because to me Org is
fundamentally an outline.

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-01 17:02               ` Samuel Wales
@ 2012-09-02  3:37                 ` Rustom Mody
  2012-09-02  5:24                   ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Rustom Mody @ 2012-09-02  3:37 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

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

On Sat, Sep 1, 2012 at 10:32 PM, Samuel Wales <samologist@gmail.com> wrote:

> On 9/1/12, Rustom Mody <rustompmody@gmail.com> wrote:
> > Seems to be working now.
> > Not sure what was wrong but it appears that I needed to do a make (have
> not
> > done it for org for some years) after that the error disappeared.
>
> Great.
>
> > It seems I can only export one subtree on which point is.
> > How to export the whole file?
>
> Create a top level headline, or activate the region on the whole buffer.
>
> I never do things at the file level in Org, because to me Org is
> fundamentally an outline.
>

Not sure how to interpret that operationally...
You keep all your blog-posts in one file with one top-level heading per
post?

[-- Attachment #2: Type: text/html, Size: 1152 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org for blogger
  2012-09-02  3:37                 ` Rustom Mody
@ 2012-09-02  5:24                   ` Samuel Wales
  0 siblings, 0 replies; 14+ messages in thread
From: Samuel Wales @ 2012-09-02  5:24 UTC (permalink / raw)
  To: Rustom Mody; +Cc: emacs-orgmode

On 9/1/12, Rustom Mody <rustompmody@gmail.com> wrote:
> You keep all your blog-posts in one file with one top-level heading per
> post?

Not top level, but my blog entries are in one file.

However, they don't have to be.  You can export anything from anywhere
with alpha-org-blog-subtree.  (It accepts an active region also, as
mentioned.)

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-09-02  5:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-01  2:39 org for blogger Rustom Mody
2012-09-01  2:56 ` Samuel Wales
2012-09-01  4:14   ` Rustom Mody
2012-09-01 15:24     ` Samuel Wales
2012-09-01 15:52       ` Rustom Mody
2012-09-01 16:00         ` Samuel Wales
2012-09-01 16:16           ` Samuel Wales
2012-09-01 16:55             ` Rustom Mody
2012-09-01 17:02               ` Samuel Wales
2012-09-02  3:37                 ` Rustom Mody
2012-09-02  5:24                   ` Samuel Wales
2012-09-01  5:37 ` Puneeth Chaganti
2012-09-01 11:04   ` Alexandre Russel
2012-09-01 11:15     ` Tongzhu Zhang

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.