diff --git a/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js b/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js index 923a5458..0e1c24f9 100644 --- a/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js +++ b/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js @@ -44,11 +44,22 @@ var MarkDown = { search: /(.+)([\n]?)/g, replace: "* $1$2" }, - - /* This looks silly but is completely valid Markdown */ + /* based on rdoc.js */ 'function-ol' : { - search: /(.+)([\n]?)/g, - replace: "1. $1$2" + exec: function( txt, selText, $field ) { + var count = 1; + // split into lines + var repText = ''; + var lines = selText.split("\n"); + var hasContent = /[\w]+/; + for ( var i = 0; i < lines.length; i++ ) { + if ( hasContent.test(lines[i]) ) { + repText += (i + 1).toString() + '. ' + + lines[i] + "\n"; + } + } + $.GollumEditor.replaceSelection( repText ); + } }, 'function-blockquote' : {