1

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

Marius Pop
  • 1,431
  • 2
  • 19
  • 32

1 Answers1

2

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.

Marius Pop
  • 1,431
  • 2
  • 19
  • 32
  • Could you mark your own answer as 'accepted', if it is solved? It helps, when browsing ruby-related questions in search of unresolved cases :) – Eureka Sep 11 '12 at 14:30