dnnlea
Last Updated: March 18, 2016
·
14.65K
· vumanhcuongit
D5c61e9157582db7e8900fb166b863b3

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)
Say Thanks
Respond