Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2009-04-22 21:53:11 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2009-04-22 21:53:11 (GMT)
commit067ba4d139545d271beb255f8856219be33cbcd6 (patch)
tree213a3065baea8f7d246ecfe7be245ea6e98b10a6
parent9f8f48766fec028e012102d4fd97a1f173f5ac94 (diff)
Fix superscript display bug
-rw-r--r--calculate.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/calculate.py b/calculate.py
index d91eb7f..0462653 100644
--- a/calculate.py
+++ b/calculate.py
@@ -56,12 +56,12 @@ def findchar(text, chars, ofs=0):
level = 0
for i in range(ofs, len(text)):
- if text[i] == '(':
+ if text[i] in chars and level == 0:
+ return i
+ elif text[i] == '(':
level += 1
elif text[i] == ')':
level -= 1
- elif text[i] in chars and level == 0:
- return i
return -1
@@ -137,11 +137,15 @@ class Equation:
_logger.debug('font-size: %d', fontsize)
tagsuper = buf.create_tag(rise=fontsize/2)
+ ENDSET = list(AstParser.DIADIC_OPS)
+ ENDSET.extend((',', '(', ')'))
+
ofs = 0
while ofs <= len(text) and text.find('**', ofs) != -1:
nextofs = text.find('**', ofs)
buf.insert_with_tags(buf.get_end_iter(), text[ofs:nextofs], *tags)
- nextofs2 = findchar(text, ['+','-', '*', '/'], nextofs + 2)
+ nextofs2 = findchar(text, ENDSET, nextofs + 2)
+ _logger.debug('nextofs2: %d, char=%c', nextofs2, text[nextofs2])
if nextofs2 == -1:
nextofs2 = len(text)
buf.insert_with_tags(buf.get_end_iter(), text[nextofs+2:nextofs2],