replace rdiscount gem with redcarpet

refs CCI-391

Test Plan:
1. Jenkins passes

flag = none

Change-Id: Id4d70067959daae86835ce78a2b38a31940b31f1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242166
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Butters <jbutters@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
QA-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
Aaron Ogata 2020-07-08 10:05:29 -07:00
parent 8fca06de74
commit bb8ea24ae2
5 changed files with 10 additions and 30 deletions

View File

@ -80,7 +80,7 @@ gem 'inst-jobs', '0.15.21'
gem 'inst-jobs-autoscaling', '1.0.5'
gem 'aws-sdk-autoscaling', '1.32.0', require: false
gem 'inst-jobs-statsd', '1.4.0'
gem 'json', '2.3.0'
gem 'json', '2.3.1'
gem 'json_schemer', '0.2.10'
gem 'json-jwt', '1.11.0', require: false
gem 'link_header', '0.0.8'
@ -103,7 +103,6 @@ gem 'rack-test', '1.1.0'
gem 'rake', '13.0.1'
gem 'rails-observers', '0.1.5'
gem 'ratom-nokogiri', '0.10.8', require: false
gem 'rdiscount', '2.2.0.1', require: false
gem 'redcarpet', '3.5.0', require: false
gem 'retriable', '1.4.1'
gem 'ritex', '1.0.1', require: false
@ -153,7 +152,6 @@ path 'gems' do
gem 'canvas_text_helper'
gem 'canvas_time'
gem 'canvas_unzip'
gem 'csv_diff'
gem 'diigo'
gem 'event_stream'
gem 'google_drive'
@ -171,3 +169,6 @@ path 'gems' do
gem 'utf8_cleaner'
gem 'workflow'
end
gem 'csv_diff', path: 'gems'
gem 'sqlite3', '1.4.2'

View File

@ -1,20 +0,0 @@
#
# Copyright (C) 2014 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
group :sqlite do
gem 'sqlite3', '1.4.2'
end

View File

@ -26,7 +26,7 @@ group :test do
gem 'simplecov', '0.15.1', require: false
gem 'docile', '1.1.5', require: false
gem 'simplecov-rcov', '0.2.3', require: false
gem 'puma', '4.3.3'
gem 'puma', '4.3.3', require: false
gem 'rspec', '3.9.0'
gem 'rspec_around_all', '0.2.0'
@ -45,7 +45,7 @@ group :test do
gem 'once-ler', '0.1.4'
gem 'sauce_whisk', '0.2.2'
gem 'selenium-webdriver', '3.142.7'
gem 'selenium-webdriver', '3.142.7', require: false
gem 'childprocess', '3.0.0', require: false
gem 'webdrivers', '4.2.0', require: false
gem 'test-queue', github: 'instructure/test-queue', ref: 'd35166408df3a5396cd809e85dcba175136a69ba', require: false
@ -58,7 +58,7 @@ group :test do
gem 'headless', '2.3.1', require: false
gem 'escape_code', '0.2', require: false
gem 'luminosity_contrast', '0.2.1'
gem 'pact', '1.49.0'
gem 'pact', '1.49.0', require: false
gem 'pact-mock_service', '3.5.0', require: false
gem 'pact-messages', '0.2.0'
gem 'pact_broker-client', '1.25.0'

View File

@ -1,4 +1,3 @@
# encoding: UTF-8
#
# Copyright (C) 2011 - present Instructure, Inc.
#
@ -17,7 +16,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
require 'nokogiri'
require 'rdiscount'
require 'redcarpet'
module TextHelper
def force_zone(time)
@ -239,7 +238,7 @@ module TextHelper
def markdown(string, inlinify = :auto)
string = ERB::Util.h(string) unless string.html_safe?
result = RDiscount.new(string).to_html.strip
result = Redcarpet::Markdown.new(Redcarpet::Render::XHTML.new).render(string).strip
# Strip wrapping <p></p> if inlinify == :auto && they completely wrap the result && there are not multiple <p>'s
result.gsub!(/<\/?p>/, '') if inlinify == :auto && result =~ /\A<p>.*<\/p>\z/m && !(result =~ /.*<p>.*<p>.*/m)
result.strip.html_safe

View File

@ -158,7 +158,7 @@ describe TextHelper do
it "should not escape MarkdownSafeBuffers" do
expect(th.mt(:foo, "We **do** trust the following input: %{input}", :input => th.markdown_safe("`a` **b** _c_ ![d](e)\n# f\n + g\n - h"))).
to eq <<-HTML.strip
<p>We <strong>do</strong> trust the following input: <code>a</code> <strong>b</strong> <em>c</em> <img src="e" alt="d" /></p>
<p>We <strong>do</strong> trust the following input: <code>a</code> <strong>b</strong> <em>c</em> <img src="e" alt="d"/></p>
<h1>f</h1>