mathtype
mathtype copied to clipboard
can not parse latex content
in `instantiate_choice': selection '102' does not exist in :choices for obj.equation[0].payload (IndexError)
Hi, sorry for the late reply.
This problem was already fixed with 2966316f .
If you still experience problems even with the latest gem-version from github, please provide the file which generates the error. I will happily investigate the case.
Hi, Thank you for your reply: i think the RECORD_NAMES future is ok, the problem is the recorded data it may be different lengths, I am not good at Ruby, here I use Python to express my logic.
// the first byte is the length of data, you can skip it read next record data_hex = wmf_stream.read(1) (following_size_hex,) = struct.unpack("c", data_hex) following_size = ord(following_size_hex)
// parse the data is_tex_input_language, size = self._read_until_null() // read a string until null is_match = is_tex_input_language.endswith('TeX Input Language') if is_match : """ in word use MathType(7.x ) trans latex to ole """ latex, size = self._read_until_null()
If you can provide me a file (bin/wmf/eps) which fails, I will investigate. From the present code I can see potential for error, but I'd like to have a testcase before changing something.
For now the gem reads, in order, the record-length and 2 NULL-terminated strings. As far as I know this worked for our incoming files.
Following the documentation, the code would have to actually calculate the amount of bytes to read, not work on strings.
I understand, it is my problem, but rigorously said that the judgment of the future record should be “>= 100“, instead of adding a record of type 102, I read the official document it have a clear explanation. https://docs.wiris.com/en/mathtype/mathtype_desktop/mathtype-sdk/mtef5#record_types
Thanks for opening the issue, @mastermissing! Could you provide a file that fails to convert, so that we can add it to the test fixtures?
@sbulka, have you encountered record type 102 in the wild? Would be good to add a test case for it! Can't seem to find any documentation on it.
Perhaps we can make >100 (with the exception of 102, if this one actually exist) all use record_future, but I haven't found a simple way to do that with BinData.
There is one testcase already. https://github.com/jure/mathtype/blob/master/spec/fixtures/expected/mathtype5/mtcomment.xml
It seems to be a feature of MathType 6.9 . I'm not sure if wiris will introduce new types in MTEF in the future. If they do, we need a fix for the future-records.
I guess the best solution would be to limit the Payload opt values to 100.
But until we have a file which fails, I would postpone any adjustment.
Hi, I work at WIRIS, makers of MathType. New mtef record types will not be introduced in the future. Record type 102 is used to store TeX source code inside mtef when the mtef is created from TeX. The new record types aren't documented in the SDK or on the WIRIS website. Very little documentation of the new record types exist at all. The lead developer of MathType said that new mtef records won't be introduced because the plan is to use mathml keeping backward compatibility with everything that uses mtef.
Record types >100 shouldn't be relied on, and it’s ok to ignore them. Record types >100 will be safely ignored by any version of MathType that is unaware of them. In particular a record type 102 will only be present if the equation has been sourced from TeX. As soon as the equation is being modified by MathType this record will be removed.