// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
mySettings = {
    nameSpace:          'markdown', // Useful to prevent multi-instances CSS conflict
    onEnter:       {keepDefault:false, openWith:'  \n'},
    markupSet: [
        {name:'Bold Text', key:"B", openWith:'**', closeWith:'**', placeHolder:'Bold text'},
        {name:'Italic Text', key:"I", openWith:'*', closeWith:'*', placeHolder:'Italic text'},
        {separator:'---------------' },
        {name:'Link', key:"L", openWith:'[', closeWith:']([![Url:!:http://]!])', placeHolder:'enter link text here' },
        {name:'Quotes', openWith:'> ', placeHolder:'enter quote here'},
        {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)', placeHolder:'enter code here'},
        {name:'Image', key:"G", replaceWith:'![[![Describe the image]!]]([![Image Location(URL):!:http://]!])'},
        {separator:'---------------' },
        {name:'Numbered List', key:"O", openWith:function(markItUp) {
            return markItUp.line+'. ';
        }},
        {name:'Bulleted List', key:"U", openWith:'- ' },
	    {name:'Heading', key:"H", placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
        {name:'Horizontal Rule', key:"R", replaceWith:"\n__________\n"},
    ]
}

// mIu nameSpace to avoid conflict.
miu = {
    markdownTitle: function(markItUp, char) {
        heading = '';
        n = $.trim(markItUp.selection||markItUp.placeHolder).length;
        for(i = 0; i < n; i++) {
            heading += char;
        }
        return '\n'+heading+'\n';
    }
}
