Bug 144108 - Superscript cannot be used to start a label
Summary: Superscript cannot be used to start a label
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Unclassified
Component: general (show other bugs)
Version: 1.x
Platform: Fedora RPMs Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-12 01:12 UTC by Matthew Truch
Modified: 2007-04-13 01:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Proposed patch (1.16 KB, patch)
2007-04-12 23:47 UTC, Andrew Walker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2007-04-12 01:12:23 UTC
Version:           1.4.0 (using KDE KDE 3.5.5)
Installed from:    Fedora RPMs
OS:                Linux

You cannot use superscript at the start of a label; you have to have at least one character first.

Example:

Start kst
Use the label tool to make a label with the text "^3He Fridge"
Make another label with the text " ^3He Fridge" (note the space!)
The first doesn't use superscript and shows the carot; the second has superscript as appropriate on the three.
Comment 1 Duncan Hanson 2007-04-12 01:34:46 UTC
I think that this might be a "feature not a bug". Parsing of ^ should
try to associate the superscript with some block of previous text,
otherwise you couldn't do things like \[M\]_{H_2 0}. I guess an if
case could be made for the first element of a label... but it seems
like a very specific thing to do for such a small problem!

If you're concerned about the space you can use {}^3He.

By the way, I empathize about square brackets in labels. They catch me
all the time.

Duncan.

On 11 Apr 2007 23:12:24 -0000, Matthew Truch <matt@truch.net> wrote:
[bugs.kde.org quoted mail]
Comment 2 George Staikos 2007-04-12 05:43:09 UTC
I agree with Duncan.  This case was specifically excluded.  I don't  
think we should support it (and we should add a testcase to make it  
explicit).
--
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/
Comment 3 Matthew Truch 2007-04-12 05:52:55 UTC
I don't understand why it's specifically excluded.  It's not like subscript or superscript must be attached to their previous element (although that is the first case people see it).  ^ should mean 'make the following character (or characters in curly braces) smaller and higher than it currently is'.  
Comment 4 Netterfield 2007-04-12 16:56:22 UTC
I agree with Mat - there is no user-visible reason that "^3HE Fridge" 
shouldn't be an acceptable label.

So - perhaps the pre-parser should take Duncan's advice and prepend a {} to 
the label automagically if it starts with a ^ or _ (and the equation text 
method should remove it when).

cbn
Comment 5 George Staikos 2007-04-12 17:04:16 UTC
   If we're going to do it, let's just add support for ^ or _ at the  
beginning of the parser.

--
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/
Comment 6 Andrew Walker 2007-04-12 23:47:52 UTC
Created attachment 20256 [details]
Proposed patch
Comment 7 George Staikos 2007-04-13 00:56:40 UTC
Looks fine as long as all the regression tests pass.

--
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/
Comment 8 Andrew Walker 2007-04-13 01:53:43 UTC
Regression tests give:

40 testcases failed in testeqparser
6 testcases failed in testrvector

which, though disturbing, does not indicated any problem with testlabelparser.
Comment 9 Andrew Walker 2007-04-13 01:54:57 UTC
SVN commit 653245 by arwalker:

BUG:144108 handle superscript or subscript at start of label

 M  +8 -12     labelparser.cpp  


--- branches/work/kst/1.5/kst/src/libkstmath/labelparser.cpp #653244:653245
@@ -527,20 +527,16 @@
       case 0x5e:   // ^
         dir = Chunk::Up;
       case 0x5f:   // _
-        if (ctail->text.isEmpty() && !ctail->group) {
-          setNormalChar(c, &ctail);
-        } else {
-          if (ctail->vOffset != Chunk::None) {
-            if (ctail->vOffset != dir) {
-              ctail = new Chunk(ctail->prev, dir, false, true);
-            } else if (ctail->group) {
-              ctail = new Chunk(ctail, dir, false, true);
-            } else {
-              return 0L; // parse error - x^y^z etc
-            }
-          } else {
+        if (ctail->vOffset != Chunk::None) {
+          if (ctail->vOffset != dir) {
+            ctail = new Chunk(ctail->prev, dir, false, true);
+          } else if (ctail->group) {
             ctail = new Chunk(ctail, dir, false, true);
+          } else {
+            return 0L; // parse error - x^y^z etc
           }
+        } else {
+          ctail = new Chunk(ctail, dir, false, true);
         }
         break;
       case 0x7b:   // {