From 2815e98e6d98c54c60b797ff1917de16f001bf8d Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Mon, 31 Mar 2014 09:44:35 +0200 Subject: [PATCH] Make autohighighting for all Code-Blocks a SiteSetting --- app/assets/javascripts/discourse/lib/syntax_highlighting.js | 3 ++- config/locales/server.en.yml | 1 + config/site_settings.yml | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/syntax_highlighting.js b/app/assets/javascripts/discourse/lib/syntax_highlighting.js index 806b8aaa29b..794375a9a49 100644 --- a/app/assets/javascripts/discourse/lib/syntax_highlighting.js +++ b/app/assets/javascripts/discourse/lib/syntax_highlighting.js @@ -16,7 +16,8 @@ Discourse.SyntaxHighlighting = { @param {jQuery.selector} $elem The element we want to apply our highlighting to **/ apply: function($elem) { - $('pre code[class]', $elem).each(function(i, e) { + var selector = Discourse.SiteSettings.autohighlight_all_code ? 'pre code' : 'pre code[class]'; + $(selector, $elem).each(function(i, e) { return $LAB.script("/javascripts/highlight.pack.js").wait(function() { return hljs.highlightBlock(e); }); diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 35eadedd1d8..5c7f7ab1c18 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -856,6 +856,7 @@ en: short_progress_text_threshold: "After the number of posts in a topic goes above this number, the progress bar will only show the current post number. If you change the progress bar's width, you may need to change this value." default_code_lang: "Default programming language syntax highlighting applied to GitHub code blocks (lang-auto, ruby, python etc.)" warn_reviving_old_topic_age: "When someone starts replying to a topic older than this many days, a warning will be displayed to discourage the user from reviving an old discussion. Disable by setting to 0." + autohighlight_all_code: "Apply code highlighting to all preformatted code blocks even when the didn't specify the language" embeddable_host: "Host that can embed the comments from this Discourse forum" feed_polling_enabled: "Whether to import a RSS/ATOM feed as posts" diff --git a/config/site_settings.yml b/config/site_settings.yml index 7d047192a5b..c464b03eb3f 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -235,6 +235,9 @@ posting: client: true default: "lang-auto" warn_reviving_old_topic_age: 180 + autohighlight_all_code: + client: true + default: false email: email_time_window_mins: 10