From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: XOXO output (was Re: Other software development for Org-mode) Date: Mon, 3 Apr 2006 09:35:45 +0200 Message-ID: References: <043b729fad3b50297372c536319cc9c5@science.uva.nl> <87acbt5kcx.fsf@tapsellferrier.co.uk> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FQJbS-0005Y9-1O for emacs-orgmode@gnu.org; Mon, 03 Apr 2006 03:35:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FQJbL-0005TS-70 for emacs-orgmode@gnu.org; Mon, 03 Apr 2006 03:35:56 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FQJbK-0005T4-U9 for emacs-orgmode@gnu.org; Mon, 03 Apr 2006 03:35:50 -0400 Received: from [146.50.4.51] (helo=imap.science.uva.nl) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FQJeL-0000H7-BH for emacs-orgmode@gnu.org; Mon, 03 Apr 2006 03:38:57 -0400 In-Reply-To: <87acbt5kcx.fsf@tapsellferrier.co.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nic Cc: emacs-orgmode@gnu.org Nic, if it is OK, I am going to include the XOXO exporter in the next test release of Org-mode. Any objections or new versions? Anybody tried this and found problems with it? - Carsten On Mar 14, 2006, at 12:36, Nic wrote: > Carsten Dominik writes: > >> I know that a few people are developing add-on software for Org-mode. >> Maybe it is useful to make a list of these, to avoid duplicate work >> and >> allow for feedback. I myself am aware of the following efforts. >> >> >> XML export, for example XOXO or OPM or OPML. >> There is already a XOXO exporter by Nic Ferrier, he posted it on >> Usenet some time ago. > > I'm going to post it here because I want some feedback on it. > > At the moment it outputs a simple XOXO view of an outline. It does not > handle org-mode content when it breaks away from an outline. > > There's a reason for that: XOXO (and OPM and OPML) only specify the > outline format... nothing else. > > So the question is: what do people want the non-outline org-mode > content to look like in an XOXO view? > > - something like is already in org-mode's HTML output > > - simpler XHTML > > - something else entirely? > > > Btw... an XOXO exporter would be better than the current HTML exporter > because it would be more flexible. Using an XML transform (maybe XSLT, > maybe something else) on the exported XOXO could render the existing > HTML as well as any other HTML or XML. > > > Anyway... the source is at the bottom of this mail. > > > > Nic > > > > ;; An org mode extension > ;; Copyright (C) 2005 by Tapsell-Ferrier Limited > > ;; This program 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 2, or (at your option) > ;; any later version. > > ;; This program 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 this program; see the file COPYING. If not, write to the > ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, > ;; Boston, MA 02111-1307, USA. > > > (defun org-export-as-xoxo-insert-into (buffer &rest output) > (with-current-buffer buffer > (apply 'insert output))) > > (defun org-export-as-xoxo (&optional buffer) > "Export the org buffer as XOXO. > The XOXO buffer is named *xoxo-*" > (interactive (list (current-buffer))) > ;; A quickie abstraction > > ;; Output everything as XOXO > (with-current-buffer (get-buffer buffer) > (beginning-of-buffer) > (let ((out (get-buffer-create (concat "*xoxo-" (buffer-name > buffer) "*"))) > (last-level 1) > (hanging-li nil)) > ;; Check the output buffer is empty. > (with-current-buffer out > (delete-region (point-min) (point-max))) > ;; Kick off the output > (org-export-as-xoxo-insert-into out "
    \n") > (while (re-search-forward "^\\(\\*+\\) \\(.+\\)" (point-max) 't) > (let* ((hd (match-string-no-properties 1)) > (level (length hd)) > (text (concat > (match-string-no-properties 2) > (save-excursion > (goto-char (match-end 0)) > (let ((str "")) > (catch 'loop > (while 't > (forward-line) > (if (looking-at "^[ \t]\\(.*\\)") > (setq str (concat str > (match-string-no-properties 1))) > (throw 'loop str))))))))) > > ;; Handle level rendering > (cond > ((> level last-level) > (org-export-as-xoxo-insert-into out "\n
      \n")) > > ((< level last-level) > (dotimes (- (- last-level level) 1) > (if hanging-li > (org-export-as-xoxo-insert-into out "\n")) > (org-export-as-xoxo-insert-into out "
    \n")) > (when hanging-li > (org-export-as-xoxo-insert-into out "\n") > (setq hanging-li nil))) > > ((equal level last-level) > (if hanging-li > (org-export-as-xoxo-insert-into out "\n"))) > ) > > (setq last-level level) > > ;; And output the new li > (setq hanging-li 't) > (if (equal ?+ (elt text 0)) > (org-export-as-xoxo-insert-into out "
  1. ") > (org-export-as-xoxo-insert-into out "
  2. " text)))) > > ;; Finally finish off the ol > (dotimes (- last-level 1) > (if hanging-li > (org-export-as-xoxo-insert-into out "
  3. \n")) > (org-export-as-xoxo-insert-into out "
\n")) > > ;; Finish the buffer off and clean it up. > (switch-to-buffer out) > (xml-mode) > (indent-region (point-min) (point-max)) > ))) > > > > > > > _______________________________________________ > Emacs-orgmode mailing list > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > -- Carsten Dominik Sterrenkundig Instituut "Anton Pannekoek" Universiteit van Amsterdam Kruislaan 403 NL-1098SJ Amsterdam phone: +31 20 525 7477