How to truncate a string that's Markdown format
Regarding this Markdown tip. Today, I got a trouble about truncating string written in Markdown format.
Firstly, I just used truncate(markdown(text), length: 100)
but it doesn't work well.
<h1>An h1 header</h1> <p>Paragraphs are separated by a blank line.</p> <p>2nd paragraph. <em>It...
Finally, I tried this one and it works :)
truncate(markdown(item.description), length: 100, escape: false)
Written by Vu Manh Cuong
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#