emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* LaTeX export filter
@ 2018-03-24 16:54 Vikas Rawal
  2018-03-24 18:05 ` Eric S Fraga
  0 siblings, 1 reply; 4+ messages in thread
From: Vikas Rawal @ 2018-03-24 16:54 UTC (permalink / raw)
  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 

\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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-28  0:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-24 16:54 LaTeX export filter Vikas Rawal
2018-03-24 18:05 ` 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

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).