Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight a long text except first few words of text without splitting into different lines #20

Closed
yaminipreethi opened this issue Sep 24, 2021 · 1 comment

Comments

@yaminipreethi
Copy link

yaminipreethi commented Sep 24, 2021

Hi,

I am trying to highlight a long sentence (sentence greater than width parameter), except specific substring in the beginning of the text like below.

image

Code used:

answer = "As you can see, streamlit is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science."
context = "Streamlit is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science."

height = int(len(context)) * 0.3 + 30

annotated_text(answer.replace(context[0].lower() + context[1:], ""), (context[0].lower() + context[1:], "Longer", "#8cff66"))

As you see in the above image, the substring "As you can see" which I don't want to highlight is getting printed in a different line. This is happening because the sentence length is higher than the default line width of page.

But, the output I am expecting is something like this:

image

Conclusion:

I want to highlight a text longer than line width of page except the specific substring at the begin of the text. But I do not want that non-highlighted substring to be printed as a different line.

Is it possible to achieve this using st-annotated-text? Any help is appreciated.

@tvst

@tvst
Copy link
Owner

tvst commented Jan 23, 2022

Fixed in 3.0.0!

@tvst tvst closed this as completed Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants