From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vikas Rawal Subject: LaTeX export filter Date: Sat, 24 Mar 2018 22:24:59 +0530 Message-ID: <218D99DB-E8AE-4968-98E8-7E35BE022E7E@agrarianresearch.org> Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezmSh-00031f-9s for emacs-orgmode@gnu.org; Sat, 24 Mar 2018 12:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ezmRd-00077V-CC for emacs-orgmode@gnu.org; Sat, 24 Mar 2018 12:56:11 -0400 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:37640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ezmRd-00076f-4w for emacs-orgmode@gnu.org; Sat, 24 Mar 2018 12:55:05 -0400 Received: by mail-pf0-x235.google.com with SMTP id t16so1681775pfh.4 for ; Sat, 24 Mar 2018 09:55:04 -0700 (PDT) Received: from [192.168.43.188] ([223.225.21.29]) by smtp.gmail.com with ESMTPSA id j125sm26517343pfg.188.2018.03.24.09.55.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Mar 2018 09:55:02 -0700 (PDT) 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" To: org-mode mailing list 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=20 \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