문제

I have some text that I would like to output using RedCloth. I am trying to figure out how this works and I can't get the result that I would like.

Used Code:

truncate(sanitize(RedCloth.new("*some* interesting text")).to_html, length: 6)

Result:

*some*

Expected Result:

some i...

도움이 되었습니까?

해결책

I just realized what the problem was. I did not pay attention to my code. I need to reverse truncate with sanitize :) Wops!

sanitize(truncate(RedCloth.new("*some* interesting text").to_html, length: 6, separator: " "))

This gives me the result that I needed. You have to use separator: " " as well to make it look clean.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top