asjqkkkk / markdown_widget

📖Rendering markdown by flutter!Welcome for pr and issue.
MIT License
321 stars 93 forks source link

Text wrapping on Custom Syntax #139

Closed Shreedhar73 closed 10 months ago

Shreedhar73 commented 10 months ago

Describe the bug I have custom syntax for a specific regex format . Every thing is working on part. For that custom syntax( tag), I have written a generator code , that returns a WidgetSpan. ( I need to use BlocBuilder within it so, cannot use TextSpan).

The problem I am facing is, the text is not wrapping properly. Even if the space is available. See the below, screenshot: Screen Shot 2023-11-28 at 17 31 40

Expected behavior On the above screenshot, the highlighted part ( ' History of the separation axioms) is due to the custom syntax I defined. It should continue after 'see', but it doesnt.

This is happening probably because, the whole of 'custom syntax' cannot fit on the black space, so it is going to new line , ( it is working perfectly fine , for smaller texts ).

So, is there any way I can fix this behaviour.

@asjqkkkk

asjqkkkk commented 10 months ago

Hi @Shreedhar73 ,In the logic of text rendering, this behavior is normal. You can think of the content within WidgetSpan as a single word. In plain text rendering, a very long word will break to a new line when there is not enough remaining space. Just like the example below, when I add a space, the remaining text is recognized as a long word and breaks to a new line.

image

image

Because RichText cannot recognize the content within WidgetSpan, it could be a piece of text, an image, or any unknown Widget. Therefore, if you want to address this issue, you might need to consider handling the relationship between data and the final text through alternative means.

Shreedhar73 commented 10 months ago

@asjqkkkk Thanks, I used the text span/'s,( only ), and opted to handle the relationship between text/data through alternative means and its working like an charm.

Thanks