From 117d3366adeb2174db08d86a52fac90b92d171c0 Mon Sep 17 00:00:00 2001 From: Karol Date: Tue, 12 Mar 2024 23:48:05 +0100 Subject: [PATCH] fix kramdown using curved quotes and replace them with straight quotation marks --- app/assets/javascripts/pagedown/markdown.editor.js.erb | 2 +- app/helpers/application_helper.rb | 2 +- app/models/submission.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/pagedown/markdown.editor.js.erb b/app/assets/javascripts/pagedown/markdown.editor.js.erb index f9ffebd6..888b5860 100644 --- a/app/assets/javascripts/pagedown/markdown.editor.js.erb +++ b/app/assets/javascripts/pagedown/markdown.editor.js.erb @@ -835,7 +835,7 @@ var prevTime = new Date().getTime(); - text = converter.makeHtml(text); + text = converter.makeHtml(text).replaceAll(/“|”/g, '"'); // Calculate the processing time of the HTML creation. // It's used as the delay time in the event listener. diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index eece4aae..9aa67845 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -50,7 +50,7 @@ module ApplicationHelper end def render_markdown(markdown) - ActionController::Base.helpers.sanitize Kramdown::Document.new(markdown, input: 'GFM', hard_wrap: false).to_html.strip + ActionController::Base.helpers.sanitize Kramdown::Document.new(markdown, input: 'GFM', hard_wrap: false, smart_quotes: 'apos,apos,quot,quot').to_html.strip end def row(options = {}, &block) diff --git a/app/models/submission.rb b/app/models/submission.rb index 145ddf52..80c36ed7 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -314,7 +314,7 @@ class Submission < ApplicationRecord else # The render_markdown method from application_helper.rb is not available in model classes. ActionController::Base.helpers.sanitize( - Kramdown::Document.new(file.feedback_message).to_html, + Kramdown::Document.new(file.feedback_message, smart_quotes: 'apos,apos,quot,quot').to_html, tags: %w[strong], attributes: [] )