refactory-id / bootstrap-markdown

Bootstrap plugin for markdown editing
Apache License 2.0
1.99k stars 371 forks source link

How could i render markdown content #145

Closed Thasthagir closed 9 years ago

toopay commented 9 years ago

@Thasthagir Could you elaborate? Some use case maybe. Or some jsfiddle.

admosity commented 9 years ago

I actually have the same problem and I'm trying to integrate this with angular as a directive. The markup I have is:

<textarea markdown-editor name="" id="" cols="30" rows="10"></textarea>

and I have some code that looks like this:

  ngModule.directive('markdownEditor', ['CssLoader', function(CssLoader) {
    CssLoader.load('BASE_URL/core/styles/bootstrap-markdown.min.css');
    return {
      scope: {

      },
      link: function(scope, elem, attrs) {
        $(elem).markdown({
          savable:true,
        });
      }
    };
  }]);

Basically this:

        $(elem).markdown({
          savable:true,
        });

Which renders: screen shot 2015-01-20 at 11 39 08 am

But when I hit the preview button, I get: screen shot 2015-01-20 at 11 40 46 am

Any idea why this may be happening? Am I missing a step?

admosity commented 9 years ago

I figured out my problem at least. The library requires the markdown-js library to be included before this one in order for parseContent() to render the content to html. No mention in the docs (unless I'm blind).

toopay commented 9 years ago

@admosity There is actually a "NOTE" section in the very bottom of the doc.

Anyhow, i'll close this issue until there is more info.

admosity commented 9 years ago

Ah yeah, missed that one. I think it should be more clearly stated/visible in the docs since most people will attempt dropping in the demo code on the page and just expect it to work. Something like... The following demos have markdown-js included for rendering.

toopay commented 9 years ago

Ah yeah, missed that one. I think it should be more clearly stated/visible in the docs since most people will attempt dropping in the demo code on the page and just expect it to work.

Then those people should just use CKEditor or other plug-and-play - but mostly bloated - plugin. I intentionally put it on the bottom, so user can first get a sense of the flexibility of this plugin via available hooks and methods. Even if they doesn't include markdown-js, this plugin would still behave as it should (in terms of changing and triggering state properly)

Thats the rationale, if you want full disclosure :)

admosity commented 9 years ago

I completely agree with you on the bloated part and I'm not saying to directly include the library within the code. I myself am using a requirejs/bower setup, so it's perfect for me. I'm just saying the way the demos were advertised without a clear (visible) disclaimer makes it seem that the markdown to html preview was out of the box functionality. I doubt many users (like myself) would make it to the note at the bottom before cherry picking a nice demo off the page and then scratch their heads when it's not rendering the preview.

Nevertheless, wonderful plugin!

MarkLeMerise commented 9 years ago

Not to beat a dead horse, but I agree with @admosity that keeping that note at the bottom of the doc will certainly lead to some confusion in the majority of use cases. It's an awesome plugin and I would hate to see users dismiss it because they don't know enough to search through the issues or just never make it to the bottom of the docs.