From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Castellan Subject: Re: mlorg : yet another parser for org-mode (Written in OCaml) Date: Wed, 4 Jul 2012 20:18:21 +0200 Message-ID: <20120704181821.GA18083@ananas.iuwt.fr> References: <20120226164145.GA28270@ananas> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmU9q-0006rR-3x for emacs-orgmode@gnu.org; Wed, 04 Jul 2012 14:18:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmU9n-0002m5-Vx for emacs-orgmode@gnu.org; Wed, 04 Jul 2012 14:18:33 -0400 Received: from jabiru.ens-lyon.fr ([140.77.51.2]:54171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmU9n-0002la-Ls for emacs-orgmode@gnu.org; Wed, 04 Jul 2012 14:18:31 -0400 Content-Disposition: inline In-Reply-To: <20120226164145.GA28270@ananas> 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: emacs-orgmode@gnu.org Hello again, Four months have passed and a lot of progress have been made. First I suppressed the literate programming layer as it was getting too much in the way. Second, the support for the syntax has been greatly improved and supports almost all constructions mentioned in org-element.el. Fore most documents, it should be ok I guess -- but I don't know what org features are the most used. To debug, and to help mlorg to talk with other languages, I coded an XML backend which dumps the structure of the file as a XML tree. ---- What is more interesting to me =E2=80=94 and that's why I started mlorg i= n the first place =E2=80=94 is the quote backend. This backend allows you to pi= ck out a code block in your file (OCaml only for now) and feed it the whole document as a tree. Thus this code can extract the particuliar information you want. For instance, I have at the end of my contacts.org this little snippet that exports the contacts as mutt aliases (F stands for filter, D for document and |- is the composition of function as the code is written in point-free style -- the argument isn't explicitely mentionned) #+name:export #+begin_src ocaml let replace =3D Str.global_replace (Str.regexp " ") "_" in F.run (F.has_property (F.s "EMAIL")) |- List.map (fun d -> sprintf "alias %s %s\n" (D.name d |> replace) (D.prop_= val_ "EMAIL" d)) |- String.concat "" |- write #+end_src With this, I just need to do $ mlorg --filename contacts.org --backend quote to have my mutt aliases. With this quote feature I plan to let the user override the html/latex exporters through the means of inheritance. For instance, suppose the user has blocks like that in his document: #+begin_lemma Some lemma. #+end_lemma He wants to export it in a specific way in html, he can put at the end of= his document: #+name export #+begin_src ocaml let exporter =3D object(self) inherit htmlExporter as super method block =3D function | Custom ("lemma", name, contents) -> Xml.block "div" ~attr:["class", "lemma"] (Xml.data (name ^ " =E2=80=94 ") :: self#blocks contents | block -> super#block block end in exporter#document #+end_src (It doesn't work yet but soon will) --- I wrote a short README available here: http://kiwi.iuwt.fr/~asmanur/projets/mlorg/ (This shows that the html backend is pretty basic) This comments briefly every construction of the syntax I support. Performance-wise, it is not optimized at all and as such quite slow. To process this file http://doc.norang.ca/org-mode.org, on my computer the bytecode version is as fast as org-mode and the native version is about 5-6x faster. (tested quickly) -- What I plan to do next: - complete the syntax as much as possible - improve the html & latex backend - try to be a little faster - have a agenda backend as well. - implements other languages ? Simon.