* 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
* Re: LaTeX export filter
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>
0 siblings, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2018-03-24 18:05 UTC (permalink / raw)
To: Vikas Rawal; +Cc: org-mode mailing list
[-- Attachment #1: Type: text/plain, Size: 476 bytes --]
On Saturday, 24 Mar 2018 at 22:24, Vikas Rawal wrote:
> 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}
[...]
> (while (string-match
> "\\(<\\([0-9]+\\)cid\\([0-9]+\\)?>[[:blank:]]*\\([^&]+\\)\\)" row)
Could it be that you need to change the last + to *?
Haven't tried it, mind you.
--
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-341-g3a4fd3
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: LaTeX export filter
[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>
1 sibling, 0 replies; 4+ messages in thread
From: Vikas Rawal @ 2018-03-28 0:51 UTC (permalink / raw)
To: org-mode mailing list
>
>
>
>>
>>> (while (string-match
>>> "\\(<\\([0-9]+\\)cid\\([0-9]+\\)?>[[:blank:]]*\\([^&]+\\)\\)" row)
>>
>> Could it be that you need to change the last + to *?
>> Haven't tried it, mind you.
>> --
>
> That does not change the result. Still pick only two.
>
> Vikas
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: LaTeX export filter
[not found] ` <433E2FC2-BAEE-444B-B6EC-09BF527D9F41@agrarianresearch.org>
@ 2018-03-28 0:51 ` Vikas Rawal
0 siblings, 0 replies; 4+ messages in thread
From: Vikas Rawal @ 2018-03-28 0:51 UTC (permalink / raw)
To: org-mode mailing list
>
>>
>>
>>>
>>>> (while (string-match
>>>> "\\(<\\([0-9]+\\)cid\\([0-9]+\\)?>[[:blank:]]*\\([^&]+\\)\\)" row)
>>>
>>> Could it be that you need to change the last + to *?
>>> Haven't tried it, mind you.
>>> --
>>
>
> The problem is in this part of the code:
>
> (while (string-match "& \\| \\\\\\\\" row 0)
> (setq row (replace-match "" nil nil row))
> (decf start))
>
> If I comment it, I get three \cmidrule latex commands, but with &s and \\
>
> Somehow, the above lines replace more than just &s and \\.
>
> 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 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.