diff --git a/Gemfile b/Gemfile index e75d1c5..0bdd2ab 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem "rqrcode" gem "nokogiri", "= 1.6.1" gem "htmlentities" -gem "rdiscount" +gem "commonmarker", "~> 0.14" gem "activerecord-typedstore" diff --git a/extras/markdowner.rb b/extras/markdowner.rb index 095238d..483bbd1 100644 --- a/extras/markdowner.rb +++ b/extras/markdowner.rb @@ -7,19 +7,19 @@ class Markdowner return "" end - args = [ :smart, :autolink, :safelink, :filter_styles, :filter_html, - :strict ] - if !opts[:allow_images] - args.push :no_image - end - - ng = Nokogiri::HTML(RDiscount.new(text.to_s, *args).to_html) + exts = [:tagfilter, :autolink] + root = CommonMarker.render_doc(text.to_s, [:SMART], exts) + ng = Nokogiri::HTML(root.to_html([:SAFE], exts)) # change

,

, etc. headings to just bold tags ng.css("h1, h2, h3, h4, h5, h6").each do |h| h.name = "strong" end + if !opts[:allow_images] + ng.css("img").remove + end + # make links have rel=nofollow ng.css("a").each do |h| h[:rel] = "nofollow"