jgarber / redcloth

RedCloth is a Ruby library for converting Textile into HTML.
Other
441 stars 113 forks source link

HTML Template Engine codes are converted to html #60

Open Ramesh-Veeriaperumal opened 4 years ago

Ramesh-Veeriaperumal commented 4 years ago

In our application we accept HTML template codes in Email templates, when we try to convert them to html using RedCloth, It converts HTML template code open close % symbol to <span> due to this our Email client throws error while processing the if else block. Example: template

<p dir=\"ltr\">{% if some_condition %}</p><ul dir=\"ltr\"><li dir=\"ltr\">Unordered list element1</li></ul><p dir=\"ltr\">{% else %}</p><ul dir=\"ltr\"><li dir=\"ltr\">Unordered list element2</li></ul><p dir=\"ltr\">{% endif %}</p><p dir=\"ltr\"><br></p>

Converting this to html using RedCloth results below content (Else and Endif blocks are converted to <span>)

2.2.5 :053 >   RedCloth.new( content ).to_html
 => "<p dir=\"ltr\">{% if some_condition %}</p><ul dir=\"ltr\"><li dir=\"ltr\">Unordered list element1</li><p></ul><p dir=\"ltr\">{% else <span>}</p><ul dir=\"ltr\"><li dir=\"ltr\">Unordered list element2</li></ul><p dir=\"ltr\">{</span> endif %}</p><p dir=\"ltr\"><br></p></p>" 

I doubt this might be bug, so raising one here. Can someone please suggest any work around for this issue. Because it is affecting our Email trigger workflow

GregThoma commented 1 month ago

p>The sun is reportedly hot,1 just like freshly baked potatoes.1 Ice is cold.2

  1. a b Ouch.
  2. a Brrr.

RedCloth 4.3.4