mikaelbr / marked-terminal

A Renderer for the marked project. Allowing you to render Markdown to print to your Terminal
MIT License
425 stars 57 forks source link

Use a more robust ANSI regex for text length calculation #305

Closed romannurik closed 3 months ago

romannurik commented 3 months ago

This fixes an issue where links inside list items rendered poorly.

Note that the new dependency (ansi-regex is tiny and also MIT-licensed)

Example markdown

Here are some space opera recommendations focused on exploring the galaxy and different cultures within it: 

1.  **[The Long Way to a Small, Angry Planet](https://play.google.com/store/books/details?id=dgFxCQAAQBAJ&source=gbs_api)** 
    ![The Long Way to a Small, Angry Planet](http://books.google.com/books/content?id=dgFxCQAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api)
    This book is a feel-good space opera that follows a crew on a spaceship as they build a hyperspace tunnel to a distant planet. It's full of interesting alien characters and touches on themes of identity, friendship, and belonging.

2.  **[Look to Windward](https://play.google.com/store/books/details?id=HovpJmfv4wAC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api)** 
    ![Look to Windward](http://books.google.com/books/content?id=HovpJmfv4wAC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api)
    This book is part of Iain M. Banks' Culture series, which is known for its focus on advanced technology and utopian societies. This book focuses on the Culture's interactions with other cultures and the potential conflicts that arise from their differing views. 

Before this PR:

Before

After this PR:

image