bootstrap-markdown icon indicating copy to clipboard operation
bootstrap-markdown copied to clipboard

Make the markdown lib dependencies as a default and editable option

Open emagnier opened this issue 11 years ago • 6 comments

This adds 2 additional options, that give the possibility to use any markdown library we want.

E.g.:

$("#target-editor").markdown({
  htmlToMarkdown: function(html) {
    return toMarkdown(html);
  },
  markdownToHtml: function(md) {
    return markdown.toHTML(md);
  }
})

By default these 2 options still use markdown-js or marked (so it's backward compatible with previous editor versions).

It should also fix https://github.com/toopay/bootstrap-markdown/issues/9.

emagnier avatar Mar 09 '14 19:03 emagnier

I have used bootstrap markdown with custom parser. This changes will make the editor library less extendable for non-markdown parser which undesired (from my perspective). Thanks for the effort thought.

toopay avatar Mar 12 '14 13:03 toopay

I'm not sure to understand well your point here. It keeps exactly the same behaviour as before (use of markdown-js and marked as fallback, and to-markdown), so by default it will not change anything.

I just moved the call of these hardcoded dependencies to the default options. So if needed, it just give an additional way to redefine our custom dependencies without have to define a markdown library in a global scope. I find it more elegant and makes possible for exemple to use easily two editors with different parsers in the same page.

I think it's going in the same direction that discussion: https://github.com/toopay/bootstrap-markdown/issues/9. But I'm surely missing something :)

emagnier avatar Mar 14 '14 02:03 emagnier

@toopay if you have time, could you reconsider my PR or give me some details how I can set a custom parser on a specific markdown-editor? And without have to modify directly bootstrap-markdown? Thanks for your help.

emagnier avatar May 14 '14 02:05 emagnier

@emagnier There are many changes already happens, so if you still interested to work on this patch, we will need to clean and rebase it with current head.

My previous point was, while this editor is intentionally build for markdown, but current design still allow this editor to be extended with any parser they wish. To keep this generic behaviour, lets not use markdownToHtml or htmlToMarkdown. Since both proposed methods are basically a hook, lets keep the api as generic as possible. Make sense?

toopay avatar Jan 15 '15 14:01 toopay

@toopay Sure thing! I may have some time to look at it during the weekend.

emagnier avatar Jan 15 '15 20:01 emagnier

@emagnier Great.

toopay avatar Jan 15 '15 20:01 toopay