crimson icon indicating copy to clipboard operation
crimson copied to clipboard

Illegal characters appear when saving long markdown strings.

Open acking-you opened this issue 2 years ago • 2 comments

I want to save markdown text as json file, I first encode the text by base64 and then convert it to json string by this library. But I found that if the markdown file is a little bit more complex, it produces the effect in the picture below. image Even so, the library can still parse the data correctly, I'm not sure if this is a bug or not.

Here is my class code:

@json
class Content {
  @jsonIgnore
  Id id = Isar.autoIncrement;
  String title = "";
  Category category = Category();
  Book book = Book();
  String? detail;
}

Here is the code I used for serialization:

...
final writer = CrimsonWriter();
final contents = await Content.allContent();
ContentBase64Encode(contents);
writer.writeContentOrNullList(contents);
...

Here is the code I used for deserialization:

...
final crimson = Crimson(await file.readAsBytes());
final contents = crimson.readContentOrNullList();
ContentBase64Decode(contents);
...

acking-you avatar Mar 26 '23 11:03 acking-you

That's very weird. I use Crimson a lot myself and never seen something like that.

Is it possible to provide a small runnable example?

simc avatar Mar 26 '23 11:03 simc

That's very weird. I use Crimson a lot myself and never seen something like that.

Is it possible to provide a small runnable example?

I created a repository reproduction and wrote a simple example code. github.com/ACking-you/example_code

descript

When I save more complex markdown text, it will trigger the following bug:

uTools_1679837416719 At this point in time the editor will think it is a binary file, the above image is forced to show the appearance of the text.

environment

Compiled environment for the demo:Windows 11

acking-you avatar Mar 26 '23 13:03 acking-you