Render descriptions as Markdown
This commit is contained in:
parent
4593bf2b2a
commit
fa1a58bea2
10 changed files with 41 additions and 12 deletions
18
vedia.rb
18
vedia.rb
|
|
@ -6,6 +6,7 @@ require 'securerandom'
|
|||
require 'chartkick'
|
||||
require 'mail'
|
||||
require 'tzinfo'
|
||||
require 'redcarpet'
|
||||
|
||||
include GetText
|
||||
|
||||
|
|
@ -479,4 +480,21 @@ helpers do
|
|||
def format_date_and_time(timestamp)
|
||||
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F %R')} (#{session[:timezone].gsub('_', ' ')})"
|
||||
end
|
||||
|
||||
def markdown(markdown)
|
||||
renderer = Redcarpet::Render::HTML.new(filter_html: true,
|
||||
no_styles: true,
|
||||
safe_links_only: true)
|
||||
parser = Redcarpet::Markdown.new(renderer, tables: true,
|
||||
autolink: true,
|
||||
strikethrough: true,
|
||||
space_after_headers: true,
|
||||
superscript: true,
|
||||
underline: true,
|
||||
highlight: true,
|
||||
quote: true,
|
||||
footnotes: true)
|
||||
parser.render(markdown)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue