Easy way to find set of quotes
Jeff Shipman
shippy at nmt.edu
Tue Apr 24 11:54:36 EDT 2001
Not sure how well this subject is, but here
is my situation:
I'm reading a file that has a kind of mark-up
language, and I'm supposed to convert it all
to HTML. No problem, really, it's no that
hard of a mark-up language, but there are a
couple things for which I'm sure python has
some tricks that would make life easier which
I don't know about.
Inside the text, wherever I find double
single-quotes (''mytext''), I'm supposed to
output <EM>mytext</EM>. Wherever I find
triple single-quotes ('''mytext''') I'm supposed
to output <STRONG>mytext</STRONG>. Finally, whenever
I find double double-quotes (""mytext""), I'm supposed to
output <BLOCKQUOTE>mytext</BLOCKQUOTE>. There may
me one or more of each of these on a single line,
and they may span multiple lines.
My question is: is there an easy way to find all
of these different patters and surround the proper
text? Note that things inside quotes are not
touched. So, if I had ""my '''text'''"", that
would output <BLOCKQUOTE>my '''text'''</BLOCKQUOTE>.
I know that python must have something handy for
this besides going through character-by-character
and keeping track of my current location. Unfortunately,
I'm not allowed to use regular expressions.
I would appreciate any advice anyone can give.
Thanks in advance!
--
Jeff "Shippy" Shipman E-Mail: shippy at nmt.edu
Computer Science Major ICQ: 1786493
New Mexico Institute of Mining and Technology
Homepage: http://www.nmt.edu/~shippy
More information about the Python-list
mailing list