Fix #3427: allow language-specific images in Markdown articles

This commit is contained in:
Nick Winter 2016-05-31 10:48:16 -07:00
parent fd8f65cadc
commit 5ff1c4b700

View file

@ -259,8 +259,11 @@ module.exports.filterMarkdownCodeLanguages = (text, language) ->
return '' unless text return '' unless text
currentLanguage = language or me.get('aceConfig')?.language or 'python' currentLanguage = language or me.get('aceConfig')?.language or 'python'
excludedLanguages = _.without ['javascript', 'python', 'coffeescript', 'clojure', 'lua', 'java', 'io'], currentLanguage excludedLanguages = _.without ['javascript', 'python', 'coffeescript', 'clojure', 'lua', 'java', 'io'], currentLanguage
exclusionRegex = new RegExp "```(#{excludedLanguages.join('|')})\n[^`]+```\n?", 'gm' # Exclude language-specific code blocks like ```python (... code ...)``` for each non-target language.
text.replace exclusionRegex, '' codeBlockExclusionRegex = new RegExp "```(#{excludedLanguages.join('|')})\n[^`]+```\n?", 'gm'
# Exclude language-specific images like ![python - image description](image url) for each non-target language.
imageExclusionRegex = new RegExp "!\\[(#{excludedLanguages.join('|')}) - .+?\\]\\(.+?\\)\n?", 'gm'
return text.replace(codeBlockExclusionRegex, '').replace(imageExclusionRegex, '')
module.exports.aceEditModes = aceEditModes = module.exports.aceEditModes = aceEditModes =
'javascript': 'ace/mode/javascript' 'javascript': 'ace/mode/javascript'