- s = regsub.gsub ('^%.*\n', '', s)
- s = regsub.gsub ('^showpage\n', '', s)
- s = regsub.gsub ('^', ' ', s)
- n = atoi (regsub.gsub ('.*\.', '', i))
+ s = re.sub ('%[^\n]*\n', '', s)
+
+ # if you want readable stuff, look at MP output.
+ s = re.sub ('[\n\t ]+', ' ', s)
+ s = re.sub ('showpage', '', s)
+
+ # MP's implementation of unfill confuses GS.
+ # Look for "Metapost & setgray" on deja.com
+ # we do some twiddling to use eofill i.s.o. fill
+ if re.search ('setgray',s ):
+ m = suspect_re.search (s)
+ while m:
+ fill = m.group (1)
+ path = m.group (2)
+
+ # be complicated, in case of gsave/grestore.
+ # vill as quick hack to avoid duple substitutions.
+ fill = re.sub ('fill', 'eovill', fill, count = 1)
+ s = re.sub (m.group (0), ' %s %s ' % (path, fill), s)
+ m = suspect_re.search (s)
+
+ s = re.sub ('eovill' , 'eofill', s)
+ s = re.sub ('0 setgray' ,'', s)
+
+
+ m = re.match ('.*\.([0-9]+)',i)
+ n = atoi (m.group (1))
+