diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6 index 8da31e81a16..e714f7ed5f6 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6 @@ -133,7 +133,7 @@ export function setup(opts, siteSettings, state) { breaks: opts.discourse.features.newline, xhtmlOut: false, linkify: true, - typographer: false + typographer: siteSettings.enable_markdown_typographer }); setupHoister(opts.engine); diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 150f2bcf7c8..658f363262f 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1024,6 +1024,7 @@ en: flag_sockpuppets: "If a new user replies to a topic from the same IP address as the new user who started the topic, flag both of their posts as potential spam." traditional_markdown_linebreaks: "Use traditional linebreaks in Markdown, which require two trailing spaces for a linebreak." + enable_markdown_typographer: "Use basic typography rules to improve text readability of paragraphs of text, replaces (c) (tm) etc, with symbols, reduces number of question marks and so on" allow_html_tables: "Allow tables to be entered in Markdown using HTML tags. TABLE, THEAD, TD, TR, TH will be whitelisted (requires full rebake on all old posts containing tables)" post_undo_action_window_mins: "Number of minutes users are allowed to undo recent actions on a post (like, flag, etc)." must_approve_users: "Staff must approve all new user accounts before they are allowed to access the site. WARNING: enabling this for a live site will revoke access for existing non-staff users!" diff --git a/config/site_settings.yml b/config/site_settings.yml index a8acafc33d4..62473829b69 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -497,6 +497,9 @@ posting: traditional_markdown_linebreaks: client: true default: false + enable_markdown_typographer: + client: true + default: false allow_html_tables: client: true default: false diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index bcf62aa08e2..eddfecf94f2 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -615,6 +615,13 @@ HTML expect(PrettyText.cook("# banana")).to include("\u25a0\u25a0") end + it 'supports typographer' do + SiteSetting.enable_markdown_typographer = true + expect(PrettyText.cook('(tm)')).to eq('

') + SiteSetting.enable_markdown_typographer = false + expect(PrettyText.cook('(tm)')).to eq('

(tm)

') + end + it 'handles onebox correctly' do # we expect 2 oneboxes expect(PrettyText.cook("http://a.com\nhttp://b.com").split("onebox").length).to eq(3)