From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: using export filters to emulate multi-column table cells?
Date: Thu, 14 Feb 2013 18:42:52 +0100 [thread overview]
Message-ID: <874nhe94gz.fsf@gmail.com> (raw)
In-Reply-To: <87sj4zbhy5.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Thu, 14 Feb 2013 13:08:50 +0800")
Hello,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Is there any way to use the new exporter mechanisms to emulate table
> cells that span rows or columns on export? I'm envisioning something
> like this:
>
> | | <2col>Grains | |
> | Year | Oats | Wheat |
> | 2007 | 10lbs | 40lbs |
>
> Where an export filter would pick up on the <2col> cookie, replace it
> with something backend-specific like \multicolumn{2}{Grains}, and then
> somehow remove the following table field from export.
You can add a function to `org-export-filter-table-row-functions'. It
will be called with three arguments. The first one is the table row, as
a string in back-end syntax. If you recognize the pattern "<2col>", you
modify the string accordingly and return it as a replacement. E.g:
#+begin_src emacs-lisp
(defun my-multicolumn-filter (row backend info)
(when (and (org-export-derived-backend-p backend 'latex)
(string-match "<\\([0-9]+\\)col>" row))
(let ((columns (string-to-number (match-string 1 row)))
(start (match-end 0)))
(setq row (replace-match "" nil nil row))
(while (and (> columns 1) (string-match "&" row start))
(setq row (replace-match "" nil nil row))
(decf columns))
row)))
(add-to-list 'org-export-filter-table-row-functions 'my-multicolumn-filter)
#+end_src
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2013-02-14 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-14 5:08 using export filters to emulate multi-column table cells? Eric Abrahamsen
2013-02-14 17:42 ` Nicolas Goaziou [this message]
2013-02-15 2:53 ` Eric Abrahamsen
2013-02-15 13:07 ` Nicolas Goaziou
2013-02-15 13:51 ` Eric Abrahamsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874nhe94gz.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=eric@ericabrahamsen.net \
/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 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.