ajaxorg/ace — pull request #1774 by kdmurthy (2014-01-19 05:47:43+00:00)
Title: Dynamic selection of embedded languages for markdown

Unlike PHP mode(depends on HTML) or HTML mode(depends on css and js), Markdown mode dependencies are not static in nature. Depending on the context, the user may want to select different languages to use in the Ace editor.

This patch supports dynamic mode dependencies for markdown. This is more like a hack, in the sense of getting it done. I do not know javascript well, let alone ace, requirejs etc. I am sure people with better knowledge can implement this better than me. Consider it as a POC ;-)

1. I left all my experiments in the commits ;-)
2. Need to ensure that the dependent modes are loaded before the markdown mode. A method preLoadMode in edit_session does this by creating a function. IMO, the best place for this code is in config module - may be it should support a variant of LoadModule that accepts dependencies.
3. Markdown mode already includes HTML and using a config.loadModule() was causing an issue. Kept a guard in markdown_highlight_rules.js to ensure it is not loaded again. I do not understand why it is throwing an exception.
4. Current Markdown mode support js/css/html/xml embeds. For this backward compatibility these defaults are added in edit_session.js - YUK.
5. Added an example editor-markdown.html - shows how embeds can be specified.

I appreciate any comments on my efforts.