From 1b4f6262cb361cffbea856a4d8a7b4666d0e5eed Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 4 Nov 2015 10:46:16 -0800 Subject: [PATCH] Exclude non-selected code language documentation blocks from level guides --- app/views/play/menu/GuideView.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/play/menu/GuideView.coffee b/app/views/play/menu/GuideView.coffee index 05c59afe3..606c586b4 100644 --- a/app/views/play/menu/GuideView.coffee +++ b/app/views/play/menu/GuideView.coffee @@ -41,7 +41,7 @@ module.exports = class LevelGuideView extends CocoView @docs = specific.concat(general) @docs = $.extend(true, [], @docs) @docs = [@docs[0]] if @firstOnly and @docs[0] - doc.html = marked(utils.i18n doc, 'body') for doc in @docs + doc.html = marked(@filterCodeLanguages(utils.i18n(doc, 'body'))) for doc in @docs doc.name = (utils.i18n doc, 'name') for doc in @docs doc.slug = _.string.slugify(doc.name) for doc in @docs super() @@ -72,6 +72,12 @@ module.exports = class LevelGuideView extends CocoView @$el.find('.nav-tabs a').click(@clickTab) @playSound 'guide-open' + filterCodeLanguages: (text) -> + currentLanguage = me.get('aceConfig')?.language or 'python' + excludedLanguages = _.without ['javascript', 'python', 'coffeescript', 'clojure', 'lua', 'io'], currentLanguage + exclusionRegex = new RegExp "```(#{excludedLanguages.join('|')})\n[^`]+```\n?", 'gm' + text.replace exclusionRegex, '' + clickSubscribe: (e) -> level = @levelSlug # Save ref to level slug @openModalView new SubscribeModal()