// -------------------------------------------------------------------
// markItUp!
// -------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// -------------------------------------------------------------------
// MarkDown tags example
// http://en.wikipedia.org/wiki/Markdown
// http://daringfireball.net/projects/markdown/
// -------------------------------------------------------------------
// Feel free to add more tags
// -------------------------------------------------------------------
mySettings = {
    previewParserPath:	'',
    onShiftEnter:		{
        keepDefault:false,
        openWith:'\n\n'
    },
    markupSet: [
    {
        name:'Heading',
        key:'1',
        placeHolder:'Your title here...',
        closeWith:function(markItUp) {
            return markdownTitle(markItUp, '=')
        }
    },
    {
        separator:'---------------'
    },
    {
        name:'Bold',
        key:'B',
        openWith:'**',
        closeWith:'**'
    },
    {
        name:'Italic',
        key:'I',
        openWith:'_',
        closeWith:'_'
    },
    {
        separator:'---------------'
    },
    {
        name:'Bulleted List',
        openWith:'- '
    },
    {
        name:'Numeric List',
        openWith:function(markItUp) {
            return markItUp.line+'. ';
        }
    },
    {
        separator:'---------------'
    },
    {
        name:'Link',
        key:'L',
        openWith:'[',
        closeWith:']([![Url:!:http://]!] "[![Title]!]")',
        placeHolder:'Your text to link here...'
    },
    {
        separator:'---------------'
    },
    {
        name:'Quotes',
        openWith:'> '
    },
    {
        name:'Code Block / Code',
        openWith:'(!(\t|!|`)!)',
        closeWith:'(!(`)!)'
    }
    ]
}

function markdownTitle(markItUp, character) {
    heading = '';
    n = $.trim(markItUp.selection||markItUp.placeHolder).length;
    for(i = 0; i < n; i++) {
        heading += character;
    }
    return '\n'+heading;
}
