Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > how to extract LaTeX macro arguments?

Reply
Thread Tools

how to extract LaTeX macro arguments?

 
 
ivo welch
Guest
Posts: n/a
 
      12-23-2003
I know regex can't do this, so may I ask what the recommended
procedure is for extracting a bracketed TeX argument, which itself can
contain other bracketed TeX arguments?

$string = " text \sometexmacro{arg1}{this is a second {\bf arg}
argument} more text";

and file.pm has a sub that makes it easy to describe all the arguments
to sometexmacro


\sometexmacro
arg1: 'arg1'
arg2: 'this is a second {\bf arg} argument'

if it were even smarter, it could also handle TeX comments and
escapes, such as

file.tex: \sometexmacro{arg1}{this is a second %}
{\bf arg} argument, which handles \} correctly }

Life would be heaven if regex's could do this, because I could then
automatically replace the second argument with what I want it to be.
Alas, they cannot. will they be able to do this in perl6?
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      12-23-2003
ivo welch wrote:
> I know regex can't do this,


Do you? Please show us the code that made you jump at that incorrect
conclusion. Preferrably a small program that people can run.

> so may I ask what the recommended procedure is for extracting a
> bracketed TeX argument, which itself can contain other bracketed
> TeX arguments?


I'd say that a Perl regular expression would be fine.

<random code fragments snipped>

> Life would be heaven if regex's could do this,


Then life _is_ heaven! Isn't that wonderful?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
 
 
 
ivo welch
Guest
Posts: n/a
 
      12-25-2003
how about an example (if this is possible) then?
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      12-25-2003
ivo welch wrote:
> how about an example (if this is possible) then?


Nope. I think people should give it a serious try to solve their
problems themselves before asking for help in this and similar groups,
and you have in no way indicated that you have tried yourself. On the
contrary, considering the way you asked, I'd bet that you are just
trying to have other people do the job for you.

You know, this is not a "we write your code for free" service. It's a
Usenet group for discussing the Perl programming language. Maybe I
should add: This group is defunct, and replaced by comp.lang.perl.misc.

If I was wrong above, and if you want to ask for help there, I do
recommend that you reconsider your posting style.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


 
Reply With Quote
 
ivo welch
Guest
Posts: n/a
 
      12-26-2003
Thanks for the hint. I had looked at the perlfaq6,

Can I use Perl regular expressions to match balanced text?

Although Perl regular expressions are more powerful than
"mathematical" regular expressions, because they feature conveniences
like backreferences (\1 and its ilk), they still aren't powerful
enough -- with the possible exception of bizarre and experimental
features in the development-track releases of Perl. You still need to
use non-regex techniques to parse balanced text, such as the text
enclosed between matching parentheses or braces, for example.


and I had tried to play with the feature, but I could not figure it
out. I think short one-liner examples fall well within the "please
help" category and not just into the "do the programming for me"
category.

regards, /iaw


Gunnar Hjalmarsson <> wrote in message news:<xuJGb.43658$>...
> ivo welch wrote:
> > how about an example (if this is possible) then?

>
> Nope. I think people should give it a serious try to solve their
> problems themselves before asking for help in this and similar groups,
> and you have in no way indicated that you have tried yourself. On the
> contrary, considering the way you asked, I'd bet that you are just
> trying to have other people do the job for you.
>
> You know, this is not a "we write your code for free" service. It's a
> Usenet group for discussing the Perl programming language. Maybe I
> should add: This group is defunct, and replaced by comp.lang.perl.misc.
>
> If I was wrong above, and if you want to ask for help there, I do
> recommend that you reconsider your posting style.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i extract vidios when winrar wont extract them??? help plzzzzzzzz smuttdog@sc.rr.com Computer Support 2 12-23-2007 07:03 AM
Macro lens on a camera with a macro setting??? mitchell.chris@gmail.com Digital Photography 2 09-28-2005 07:55 AM
in S.E. Asia : Canon EOS 300d with 100 macro ED vs. Nikon D70 with Nikon 105 macro ? J. Cod Digital Photography 0 09-29-2004 05:46 AM
#define macro to enclose an older macro with strings Dead RAM C++ 20 07-14-2004 10:58 AM
macro name from macro? D Senthil Kumar C Programming 1 09-21-2003 07:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57