From: Jambunathan K <kjambunathan@gmail.com>
To: Nicolas <n.goaziou@gmail.com>
Cc: Bastien <bzg@altern.org>, nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: unnumbered subsections in latex export
Date: Fri, 01 Apr 2011 13:09:21 +0530 [thread overview]
Message-ID: <81mxka774m.fsf@gmail.com> (raw)
In-Reply-To: <87tyejymto.fsf@gmail.com> (Nicolas's message of "Thu, 31 Mar 2011 23:58:11 +0200")
> I'll show two examples to illustrate my point: lists and tables. Taken
> from a docstring,
>
> 1. first item
> + sub-item one
> + [X] sub-item two
> more text in first item
> 2. [@3] last item
>
> will be parsed as:
>
> (ordered (nil \"first item\"
> (unordered (nil "sub-item one")
> (nil "[CBON] sub-item two"))
> "more text in first item"")
> (3 "last item"))
>
> This allows to easily (see org-list-to-latex, org-list-to-html,
> org-list-to-texinfo, and so on) transform an Org list in many different
> formats. Alas, it cannot be used in org-html.el and org-docbook.el, as
> those, again, parse buffer line-wise.
>
> The same could be said about tables:
>
> | Row 1 | 1 | 2 |
> |-------+---+---|
> | Row 2 | 3 | 4 |
>
> can be parsed as:
>
> (("Row 1" "1" "2")
> 'hline
> ("Row 2" "3" "4"))
>
> and from that, such functions as orgtbl-to-html, or orgtbl-to-latex were
> easy to create.
>
> So, basically, what I suggest here is:
>
> 1. list all possible environments and objects offered by the Org format
> (table, lists, inlinetasks, center, verbatim, paragraph, headlines,
> time-stamps, LaTeX snippets, footnotes, links, source);
> 2. define an explicit export format for each of them;
> 3. determine options that should be know by org-exp, by the backend;
> 4. create a parser, in org-exp, that will output Org buffer in the
> chosen format;
> 5. create (many are readily available) functions for each backend to
> interpret them.
>
>
> Now about that explicit format. Taking this buffer,
>
> #+title: Example buffer
>
> Some text before first headline.
>
> * First section
>
> First paragraph $\alpha = 1$.
>
> Second paragraph.
>
> - item 1
> - item 2
> #+begin_center
> Text
> #+end_center
>
> | Row 1 | 1 | 2 |
> | Row 2 | 3 | 4 |
>
> * Second section
>
> Text with footnote[fn:1].
> *************** Inline task
> Some text and
> a [[http://www.gnu.org/software/emacs/][link]]
> :DRAWER:
> - I like
> - lists.
> :END:
> *************** END
>
> * Footnotes
> [fn:1] Footnote definition.
>
> It could be parsed as the following:
>
> '((:title "Example buffer")
> (paragraph "Some text before first headline.")
> (headline "First section"
> (paragraph "First paragraph "
> (latex "$\alpha = 1")
> ".")
> (paragraph "Second paragraph")
> (list unordered (nil "item 1")
> (nil "item 2")
> (center (paragraph "Text")))
> (table ("Row 1" "1" "2")
> hline
> ("Row 2" "3" "4")))
> (headline "Second section"
> (paragraph "Text with footnote"
> (footnote "Footnote definition")
> ".")
> (inlinetask "Inline task"
> (paragraph "Some text and\na "
> (link "link" "http://www.gnu.org/"))
> (drawer (list unordered (nil "I like")
> (nil "lists."))))))
>
> Note that such a parsing will need a decent forward-paragraph function.
> It's also a very simplified example: headlines would need more than the
> title string (todo keyword, priority, tags) before starting the body.
>
> I have no code to offer at the moment, and, as we all know, Devil is in
> the details. But if the output from org-exp.el is clear, exporters will
> be more coherent. It is even provide tools to help exporters doing their
> task (a function to extract footnotes from the output, for example).
>
> Again, it may be a big task to undertake, but I think it will be
> necessary at some point.
Such an exporter (or similar in spirit to what you say) exists already.
For the sake of record, I am copying Bastien's notes on his
./EXPERIMENTAL/org-export.el (with some non-relevant content stripped)
Jambunathan K.
Attachment:
From: Bastien <bastien.guerry@wikimedia.fr>
Subject: Re: OpenDocumentText/OpenOffice exporter
To: Lennart Borgman <lennart.borgman@gmail.com>
Cc: Jambunathan K <kjambunathan@gmail.com>, Carsten Dominik <carsten.dominik@gmail.com>
Date: Sun, 13 Feb 2011 11:00:34 +0100 (6 weeks, 4 days, 21 hours ago)
Message-ID: <87tyg8ntj1.fsf@gnu.org>
Hi Lennart,
Lennart Borgman <lennart.borgman@gmail.com> writes:
> Perhaps we have done something very similar then, I do not know.
My bad. I should have advertize EXPERIMENTAL/org-export.el sooner.
> So maybe your approach of parsing the org buffer to a list makes
> things more easy to handle. On what level is the list? (From your
> description I guess it is a "parse tree" or whatever it is called. Not
> a list of tokens.)
It's a parse tree.
See attached example of a test.org file and the result of the function
(org-export-parse) : this list will go through the exporter, which takes
care of every subtree recursively.
Of course, having such a parse tree does not solve everything, and the
content of :content remains to be handled... but at least it makes
things quite clear.
[2. text/x-org; test.org]
#+TITLE: Test parse file
#+AUTHOR: Bastien
* A first heading
Some text here.
* WAITING A heading with metadata :Write:
The parse tree contains information about the current subtree.
** A subtree
Hello.
[3. text/plain; test_parsed.txt]
((:level 1 :heading
#("A first heading" 0 15
(fontified t font-lock-fontified t face org-level-1))
:properties
(("FILE" . "/home/guerry/test.org")
("BLOCKED" . "")
("CATEGORY" . "test"))
:content
#("\nSome text here.\n\n" 0 1
(fontified t font-lock-fontified t org-category "test")
1 17
(fontified t font-lock-fontified t org-category "test")
17 18
(fontified t font-lock-fontified t org-category "test"))
:subtree nil)
(:level 1 :heading
#("A heading with metadata" 0 23
(fontified t font-lock-fontified t org-todo-head "NEXT" face org-level-1 org-category "test"))
:properties
(("TODO" . "WAITING")
("FILE" . "/home/guerry/test.org")
("TAGS" . ":Write:")
("ALLTAGS" . ":Write:")
("BLOCKED" . "")
("CATEGORY" . "test"))
:content
#("\nThe parse tree contains information about the current subtree.\n\n" 0 1
(org-todo-head "NEXT" fontified t org-category "test")
1 64
(org-todo-head "NEXT" fontified t org-category "test")
64 65
(org-todo-head "NEXT" fontified t org-category "test"))
:subtree
((:level 2 :heading
#("A subtree" 0 9
(org-todo-head "NEXT" fontified t face org-level-2 org-category "test"))
:properties
(("FILE" . "/home/guerry/test.org")
("ALLTAGS" .
#(":Write:" 1 6
(inherited t)))
("BLOCKED" . "")
("CATEGORY" . "test"))
:content
#("\nHello.\n" 0 1
(org-todo-head "NEXT" fontified t org-category "test")
1 7
(org-todo-head "NEXT" fontified t org-category "test")
7 8
(fontified t font-lock-fontified t org-category "test"))
:subtree nil))))
next prev parent reply other threads:[~2011-04-01 7:39 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-22 12:10 unnumbered subsections in latex export Suvayu Ali
2011-03-22 12:20 ` Sébastien Vauban
2011-03-22 12:31 ` Suvayu Ali
2011-03-22 12:56 ` Sébastien Vauban
2011-03-22 14:26 ` [PATCH] Allow mixed export of numbered and unnumbered sections in LaTeX Lawrence Mitchell
2011-03-22 22:52 ` Suvayu Ali
2011-03-23 14:04 ` [Accepted] " Bastien Guerry
2011-03-23 14:17 ` [PATCH] " Bastien
2011-03-22 14:35 ` Re: unnumbered subsections in latex export Nick Dokos
2011-03-22 23:08 ` Suvayu Ali
2011-03-22 23:21 ` Nick Dokos
2011-03-23 9:38 ` [PATCH] Allow mixed export of numbered and unnumbered sections in HTML Lawrence Mitchell
2011-03-23 14:05 ` [Accepted] " Bastien Guerry
2011-03-23 14:57 ` Nick Dokos
2011-03-23 15:50 ` Suvayu Ali
2011-03-23 14:18 ` Re: unnumbered subsections in latex export Bastien
2011-03-23 15:02 ` Nick Dokos
2011-03-23 16:25 ` Lawrence Mitchell
2011-03-23 16:42 ` Nick Dokos
2011-03-23 18:17 ` Jambunathan K
2011-03-23 19:00 ` Nick Dokos
2011-03-23 19:18 ` Jambunathan K
2011-03-23 16:29 ` Thomas S. Dye
2011-03-23 17:42 ` Jambunathan K
2011-03-24 7:59 ` Bastien
2011-03-24 18:27 ` Achim Gratz
2011-03-24 19:25 ` Nick Dokos
2011-03-25 1:06 ` Suvayu Ali
2011-04-04 14:39 ` Sébastien Vauban
2011-04-04 17:04 ` Nick Dokos
2011-04-04 20:32 ` Aankhen
2011-04-05 10:16 ` Sébastien Vauban
2011-04-05 19:07 ` Aankhen
2011-04-05 19:27 ` Eric S Fraga
2011-04-05 21:25 ` New features for the exporters? Sébastien Vauban
2011-04-05 21:45 ` Re: unnumbered subsections in latex export Aankhen
2011-04-06 18:49 ` Matt Lundin
2011-04-06 20:19 ` Sébastien Vauban
2011-03-27 11:16 ` Jambunathan K
2011-03-27 11:40 ` Bastien
2011-03-31 21:58 ` Nicolas
2011-04-01 4:34 ` Jambunathan K
2011-04-01 4:41 ` Jambunathan K
2011-04-01 6:29 ` Nick Dokos
2011-04-01 15:41 ` Eric S Fraga
2011-04-04 14:00 ` Matt Lundin
2011-04-04 14:12 ` Jambunathan K
2011-04-04 16:36 ` Matt Lundin
2011-04-04 17:09 ` Nick Dokos
2011-04-01 7:39 ` Jambunathan K [this message]
2011-04-01 18:25 ` Achim Gratz
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=81mxka774m.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--cc=bzg@altern.org \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
--cc=nicholas.dokos@hp.com \
/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).