| Summary: | Superscript cannot be used to start a label | ||
|---|---|---|---|
| Product: | [Applications] kst | Reporter: | Matthew Truch <matt> |
| Component: | general | Assignee: | kst |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 1.x | ||
| Target Milestone: | --- | ||
| Platform: | Fedora RPMs | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Proposed patch | ||
|
Description
Matthew Truch
2007-04-12 01:12:23 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]
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/ 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'. 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
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/ Created attachment 20256 [details]
Proposed patch
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/ Regression tests give: 40 testcases failed in testeqparser 6 testcases failed in testrvector which, though disturbing, does not indicated any problem with testlabelparser. 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: // {
|