diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index ef38d352d..19f6aa850 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -7,7 +7,9 @@ require 'lib/diaspora/markdownify' module MarkdownifyHelper def markdownify(message, render_options={}) markdown_options = { - :autolink => true, + :autolink => true, + :fenced_code_blocks => true, + :space_after_headers => true } render_options[:filter_html] = true diff --git a/app/views/status_messages/_status_message.haml b/app/views/status_messages/_status_message.haml index 133cde0b5..c3be5bad9 100644 --- a/app/views/status_messages/_status_message.haml +++ b/app/views/status_messages/_status_message.haml @@ -16,4 +16,4 @@ = link_to (image_tag photo.url(:thumb_small), :class => 'stream-photo thumb_small', 'data-small-photo' => photo.url(:thumb_medium), 'data-full-photo' => photo.url), photo_path(photo), :class => 'stream-photo-link' %p{:class => direction_for(post.text)} - = markdownify(post.text, :youtube_maps => post[:youtube_titles]) + != markdownify(post.text, :youtube_maps => post[:youtube_titles]) diff --git a/lib/diaspora/markdownify.rb b/lib/diaspora/markdownify.rb index 734e34f01..49c7665f1 100644 --- a/lib/diaspora/markdownify.rb +++ b/lib/diaspora/markdownify.rb @@ -1,3 +1,4 @@ +require 'erb' require 'uri' module Diaspora @@ -36,13 +37,14 @@ module Diaspora if link =~ regex video_id = $1 if @vimeo_maps[video_id] - title = h(CGI::unescape(@vimeo_maps[video_id])) + title = ERB::Util.h(CGI::unescape(@vimeo_maps[video_id])) else title = I18n.t 'application.helper.video_title.unknown' end return ' Vimeo: ' + title + '' end + return end def autolink_youtube(link) @@ -51,7 +53,7 @@ module Diaspora anchor = $2 || '' if @youtube_maps[video_id] - title = h(CGI::unescape(@youtube_maps[video_id])) + title = ERB::Util.h(CGI::unescape(@youtube_maps[video_id])) else title = I18n.t 'application.helper.video_title.unknown' end @@ -59,6 +61,11 @@ module Diaspora video_id + '" data-anchor="' + anchor + '" href="'+ link + '" target="_blank">Youtube: ' + title + '' end + return + end + + def block_code(text, language) + "
\n#{text}"
end
def double_emphasis(text)
@@ -95,10 +102,19 @@ module Diaspora
text = Diaspora::Taggable.format_tags(text, :no_escape => true)
end
+ if @newlines
+ br = linebreak
+
+ # in very clear cases, let newlines become #{text}
" end - def preprocess(full_document) if @specialchars full_document = specialchars(full_document) @@ -123,17 +139,11 @@ module Diaspora %Q{[#{content}](#{link}#{title_chunk})} end - if @newlines - # in very clear cases, let newlines becomeputs "Hello"
\nA\nB\n}
+ end
+
it "doesn't double parse video links" do
message = "http://www.vimeo.com/17449557
http://www.youtube.com/watch?v=0x__dDWdf23&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1