Closed ChristopherChudzicki closed 6 years ago
That looks reasonable to me. I have no idea how edX will display something like abcstuff{ijk}, but we can certainly allow it in the parsing. Thanks for getting to this - it's been sitting on my todo list for a while...
Glad it seems reasonable. I think that using abc_stuff_{ijk}
is probably not a good idea, but allowing it in the parser seems natural and seems to make the logic simpler: now tensor notation is a strictly "extra stuff" added to end of original edX variable name.
I'm currently happy with the implementation, but I'd like to write some more tests before merging.
Indeed. Please include tests like a2bc_d3e__4fg_{ijk}
!
@jolyonb
Indeed. Please include tests like a2bc_d3e_4fg{ijk}!
Maybe you realized that wouldn't work :)
I had trouble implementing normal subscripts and tensor lower_indices simultaneously for the same variable. Since I don't think they would display well anyway, I don't want to worry about it.
I've updated the PR description. The parsing is now, I believe, what you originally envisioned and is fairly clean. So, please review and merge if no issues.
This is a rewrite of the variable name parsing to address #25
One of two forms is acceptable:
is allowed, where:
front
(required): Alphabetical followed by alphanumeric, e.g.,Xab
subscripts
(optional): Alphanumeric and underscores, e.g.,_cd___2_3
lower_indices
(optional): Like_{12xy3}
upper_indices
(optional): Like^{4abc}
tail
(optional): Any number of primes.So for example:
XY__ab__c_
is allowed (front + subscripts) andST_{ij34}^{bc}
is allowed (front+lower_indices+upper_indices) butT_ijk^{123}
is not allowed (front+subscriots+upper_indiices).Using the language above, edX original is
front+subscripts