emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Simon Castellan <simon.castellan@iuwt.fr>
To: emacs-orgmode@gnu.org
Subject: Re: mlorg : yet another parser for org-mode (Written in OCaml)
Date: Wed, 4 Jul 2012 20:18:21 +0200	[thread overview]
Message-ID: <20120704181821.GA18083@ananas.iuwt.fr> (raw)
In-Reply-To: <20120226164145.GA28270@ananas>

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 — and that's why I started mlorg in the
first place — is the quote backend. This backend allows you to pick 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 = 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 = object(self)
  inherit htmlExporter as super
  method block = function
   | Custom ("lemma", name, contents) ->
     Xml.block "div" ~attr:["class", "lemma"]
       (Xml.data (name ^ " — ") ::
        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.

      parent reply	other threads:[~2012-07-04 18:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-26 16:41 mlorg : yet another parser for org-mode (Written in OCaml contained in org-mode files) Simon Castellan
2012-02-27 14:27 ` Alan Schmitt
2012-02-27 17:06   ` Simon Castellan
2012-02-27 16:52     ` Eric Schulte
2010-08-01 23:37       ` Simon Castellan
2012-03-01 13:20         ` Nicolas Goaziou
2012-03-01 15:44           ` Simon Castellan
2012-03-01 19:18             ` Nicolas Goaziou
2012-07-04 18:18 ` Simon Castellan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120704181821.GA18083@ananas.iuwt.fr \
    --to=simon.castellan@iuwt.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).