/*global Markdown:true */ /** Contains methods to help us with markdown formatting. @class Markdown @namespace Discourse @module Discourse **/ Discourse.Markdown = { /** Convert a raw string to a cooked markdown string. @method cook @param {String} raw the raw string we want to apply markdown to @param {Object} opts the options for the rendering @return {String} the cooked markdown string **/ cook: function(raw, opts) { if (!opts) opts = {}; // Make sure we've got a string if (!raw) return ""; if (raw.length === 0) return ""; return this.markdownConverter(opts).makeHtml(raw); }, /** Creates a new pagedown markdown editor, supplying i18n translations. @method createEditor @param {Object} converterOptions custom options for our markdown converter @return {Markdown.Editor} the editor instance **/ createEditor: function(converterOptions) { if (!converterOptions) converterOptions = {}; // By default we always sanitize content in the editor converterOptions.sanitize = true; var markdownConverter = Discourse.Markdown.markdownConverter(converterOptions); var editorOptions = { strings: { bold: I18n.t("js.composer.bold_title") + " Ctrl+B", boldexample: I18n.t("js.composer.bold_text"), italic: I18n.t("js.composer.italic_title") + " Ctrl+I", italicexample: I18n.t("js.composer.italic_text"), link: I18n.t("js.composer.link_title") + " Ctrl+L", linkdescription: I18n.t("js.composer.link_description"), linkdialog: "

" + I18n.t("js.composer.link_dialog_title") + "

http://example.com/ \"" + I18n.t("js.composer.link_optional_text") + "\"

", quote: I18n.t("js.composer.quote_title") + "
Ctrl+Q", quoteexample: I18n.t("js.composer.quote_text"), code: I18n.t("js.composer.code_title") + "
 Ctrl+K",
        codeexample: I18n.t("js.composer.code_text"),

        image: I18n.t("js.composer.image_title") + "  Ctrl+G",
        imagedescription: I18n.t("js.composer.image_description"),
        imagedialog: "

" + I18n.t("js.composer.image_dialog_title") + "

http://example.com/images/diagram.jpg \"" + I18n.t("js.composer.image_optional_text") + "\"

" + I18n.t("js.composer.image_hosting_hint") + "

", olist: I18n.t("js.composer.olist_title") + "
    Ctrl+O", ulist: I18n.t("js.composer.ulist_title") + "