From: Vikas Rawal <vikaslists@agrarianresearch.org>
To: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: LaTeX export filter
Date: Sat, 24 Mar 2018 22:24:59 +0530 [thread overview]
Message-ID: <218D99DB-E8AE-4968-98E8-7E35BE022E7E@agrarianresearch.org> (raw)
Let me start by confessing my limited knowledge of lisp.
I am trying to write a LaTeX export filter that should replace all table rows with cells having entries such as <3cid4> by \cmidrule{lr}{3-4}
The idea is to have a table row of this kind
| <2cid3> | <4cid5> | <6cid7> | | | | |
Which should be exported to
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
This is as far as I have gone.
------
(defun org-export-cmidrule-filter-latex (row backend info)
(while (string-match
"\\(<\\([0-9]+\\)cid\\([0-9]+\\)?>[[:blank:]]*\\([^&]+\\)\\)" row)
(let ((start (string-to-number (match-string 2 row)))
(end (or (match-string 3 row) "l")))
(setq row (replace-match
(format "\\\\cmidrule(lr){%s-%s}" start end)
nil nil row 1))
(while (string-match "& \\| \\\\\\\\" row 0)
(setq row (replace-match "" nil nil row))
(decf start))
)
)
row)
------
The above filter works if I have only one or two <[0-9]cid[0-9]> strings in a row. It does not pick up the third <[0-9]cid[0-9]> string.
I would greatly appreciate if anyone could help improve this filter.
Vikas
next reply other threads:[~2018-03-24 16:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-24 16:54 Vikas Rawal [this message]
2018-03-24 18:05 ` LaTeX export filter Eric S Fraga
[not found] ` <16672FA9-1C32-4E00-8358-59171E9CB658@agrarianresearch.org>
2018-03-28 0:51 ` Vikas Rawal
[not found] ` <433E2FC2-BAEE-444B-B6EC-09BF527D9F41@agrarianresearch.org>
2018-03-28 0:51 ` Vikas Rawal
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=218D99DB-E8AE-4968-98E8-7E35BE022E7E@agrarianresearch.org \
--to=vikaslists@agrarianresearch.org \
--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 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.