[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] preview-latex, dvipng, and LyX
From: |
Jan-Åke Larsson |
Subject: |
Re: [AUCTeX-devel] preview-latex, dvipng, and LyX |
Date: |
Wed, 11 Jan 2006 11:43:53 +0100 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Windows/20050716) |
Jan-Åke Larsson wrote:
> What about the following patch?
--- lyxpreview2bitmap.py.old Wed Jan 11 10:28:49 2006
+++ lyxpreview2bitmap.py Wed Jan 11 11:03:25 2006
@@ -78,11 +78,21 @@
def extract_metrics_info(dvipng_stdout, metrics_file):
metrics = open(metrics_file, 'w')
- metrics_re = re.compile("\[([0-9]+) depth=(-?[0-9]+) height=(-?[0-9]+)")
+# "\[[0-9]+" can match two kinds of numbers: page numbers from dvipng
+# and glyph numbers from mktexpk. The glyph numbers always match
+# "\[[0-9]+\]" while the page number never is followed by "\]". Thus:
+ page_re = re.compile("\[([0-9]+)[^]]");
+ metrics_re = re.compile("depth=(-?[0-9]+) height=(-?[0-9]+)")
success = 0
+ page = ""
pos = 0
while 1:
+ match = page_re.search(dvipng_stdout, pos)
+ if match == None:
+ break
+ page = match.group(1)
+ pos = match.end()+1
match = metrics_re.search(dvipng_stdout, pos)
if match == None:
break
@@ -89,8 +99,8 @@
success = 1
# Calculate the 'ascent fraction'.
- descent = string.atof(match.group(2))
- ascent = string.atof(match.group(3))
+ descent = string.atof(match.group(1))
+ ascent = string.atof(match.group(2))
frac = 0.5
if ascent > 0 and descent > 0:
@@ -101,8 +111,8 @@
if frac < 0 or frac > 1:
frac = 0.5
- metrics.write("Snippet %s %f\n" % (match.group(1), frac))
- pos = match.end(3) + 2
+ metrics.write("Snippet %s %f\n" % (page, frac))
+ pos = match.end() + 2
return success
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, (continued)
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, David Kastrup, 2006/01/06
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Angus Leeming, 2006/01/06
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Angus Leeming, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Angus Leeming, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/11
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/11
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX,
Jan-Åke Larsson <=
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Angus Leeming, 2006/01/11
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Angus Leeming, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, David Kastrup, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Enrico Forestieri, 2006/01/09
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Jan-Åke Larsson, 2006/01/11
- Re: [AUCTeX-devel] preview-latex, dvipng, and LyX, Enrico Forestieri, 2006/01/10