ricklupton / rmc

Convert to/from v6 .rm files from the reMarkable tablet
MIT License
57 stars 14 forks source link

Problems with empty ItalicSpan #6

Closed jamespitt closed 1 year ago

jamespitt commented 1 year ago

I've found this error:

WARNING:rmscene.tagged_block_reader:Some data has not been read. The data may have been written using a newer format than this reader supports. ERROR:rmscene.text:Unbalanced stack! [(None, [CrdtStr(s='Blog: ', i=[CrdtId(1, 346), CrdtId(1, 347), CrdtId(1, 348), CrdtId(1, 349), CrdtId(1, 350), CrdtId(1, 351)])]), (<class 'rmscene.text.ItalicSpan'>, [])] ERROR:rmscene.text:Unexpected end of span at CrdtId(1, 3051): got <class 'rmscene.text.ItalicSpan'>, expected None

this then gives a

IndexError: list index out of range on the line 170 in text.py: _, contents = stack[-1]

I've put a fix in my local version to do this:

        if len(stack) > 1:
            _logger.error("Unbalanced stack! %s", stack)
        elif len(stack) == 0:
            _logger.error("Empty stack! %s", stack)
            contents = ""
        else:
            _, contents = stack[-1]
        return contents

Let me know if want a PR for this or some other way of fixing it.

jamespitt commented 1 year ago

I think this is the wrong place for this issue - going to re-open it in the https://github.com/ricklupton/rmscene repo.