allow embedded images in story text, but still not in comments
This commit is contained in:
parent
cb5e05c461
commit
b7e5447c1d
|
@ -251,7 +251,7 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def generated_markeddown_description
|
||||
Markdowner.to_html(self.description)
|
||||
Markdowner.to_html(self.description, allow_images = true)
|
||||
end
|
||||
|
||||
def description=(desc)
|
||||
|
|
|
@ -27,5 +27,14 @@
|
|||
text</pre></td>
|
||||
<td>prefix text with at least <tt> 3 spaces</tt></td>
|
||||
</tr>
|
||||
|
||||
<% if defined?(allow_images) && allow_images %>
|
||||
<tr>
|
||||
<td>(inline image)</td>
|
||||
<td><tt>![alt text](http://example.com/image.jpg)</tt> (only allowed in
|
||||
story text</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<%= render :partial => "global/markdownhelp" %>
|
||||
<%= render :partial => "global/markdownhelp",
|
||||
:locals => { :allow_images => true } %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -85,7 +85,8 @@
|
|||
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<%= render :partial => "global/markdownhelp" %>
|
||||
<%= render :partial => "global/markdownhelp",
|
||||
:locals => { :allow_images => true } %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
class Markdowner
|
||||
def self.to_html(text)
|
||||
def self.to_html(text, allow_images = false)
|
||||
if text.blank?
|
||||
return ""
|
||||
else
|
||||
html = RDiscount.new(text.to_s, :smart, :autolink, :safelink,
|
||||
:filter_styles, :filter_html, :no_image).to_html
|
||||
html = RDiscount.new(text.to_s, *[ :smart, :autolink, :safelink,
|
||||
:filter_styles, :filter_html ] + (allow_images ? [] : [ :no_image ])).
|
||||
to_html
|
||||
|
||||
# change <h1> headings to just emphasis tags
|
||||
html.gsub!(/<(\/)?h(\d)>/) {|_| "<#{$1}strong>" }
|
||||
|
|
Loading…
Reference in a new issue