Question

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...

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top