MathView icon indicating copy to clipboard operation
MathView copied to clipboard

Mathview setText causing java.lang.StringIndexOutOfBoundsException

Open donpeter06 opened this issue 8 years ago • 6 comments

This is the value that i try to set in mathview

(\ N_{0}/2 ) atoms of X(g) are converted into (\ X^{+}(g) ) by energy (\ E_{1} ). (\ N_{0}/2 ) atoms of X(g) are converted into (\ X^{-}(g) ) by energy (\ E_{2} ). Hence, ionisation potential and electron affinity of X (g) are

This causes an exception

java.lang.StringIndexOutOfBoundsException: length=0; index=0 at java.lang.String.charAt(Native Method) at com.x5.template.providers.TemplateProvider.parseEmbeddedExtension(TemplateProvider.java:117) at com.x5.template.providers.TemplateProvider.resourceName(TemplateProvider.java:91) at com.x5.template.providers.TemplateProvider.loadItemDoc(TemplateProvider.java:80) at com.x5.template.providers.TemplateProvider.getSnippet(TemplateProvider.java:43) at com.x5.template.providers.TemplateProvider.provides(TemplateProvider.java:29) at com.x5.template.Theme.getSnippet(Theme.java:194) at com.x5.template.Chunk.altFetch(Chunk.java:955) at com.x5.template.Chunk.altFetch(Chunk.java:858) at com.x5.template.Chunk._resolveTagValue(Chunk.java:1038) at com.x5.template.Chunk.resolveTagValue(Chunk.java:1009) at com.x5.template.SnippetTag.render(SnippetTag.java:43) at com.x5.template.Snippet.render(Snippet.java:843) at com.x5.template.SnippetTag.render(SnippetTag.java:50) at com.x5.template.Snippet.render(Snippet.java:843) at com.x5.template.Chunk.explodeToPrinter(Chunk.java:728) at com.x5.template.Chunk.renderForParentToPrinter(Chunk.java:689) at com.x5.template.Chunk.explodeForParentToPrinter(Chunk.java:681) at com.x5.template.Chunk.render(Chunk.java:643) at com.x5.template.Chunk.toString(Chunk.java:612) at io.github.kexanie.library.MathView.setText(MathView.java:69)

donpeter06 avatar Mar 27 '17 11:03 donpeter06

Looks like MathView is not capable of parsing X^{+}. this part is actually causing the crash

donpeter06 avatar Mar 27 '17 12:03 donpeter06

@donpeter06 I got the same issue and your diagnosis was spot on. I have expression \(Li^{+}\) which was causing the above exception. My question is - did you resolve this issue? How do I change my expression so that I do not get this exception while keeping the rendered expression as much similar as the original one.

yaxhpal avatar Jun 06 '18 12:06 yaxhpal

@yaxhpal Nope. I ditched the native development for webview based display.

finotes avatar Jun 06 '18 13:06 finotes

@finotes That's okay. The workaround which worked for me is - I have removed the braces for single plus sign i.e., ^{+} --> ^+. Other cases like ^{+1} or ^{+x} work fine without modification.

yaxhpal avatar Jun 19 '18 09:06 yaxhpal

try to replace "^" , "-", "+" with ascii codes like hat,45,43 image after that its work in MathView image

techbhaskar avatar Mar 21 '19 17:03 techbhaskar

Looks like MathView is not capable of parsing X^{+}. this part is actually causing the crash

You saved alot of time for me , Thank u so much

techbhaskar avatar Mar 21 '19 17:03 techbhaskar