text-lite.js.es6 574 B

123456789101112131415161718
  1. import loadScript from './load-script';
  2. import { default as PrettyText } from 'pretty-text/pretty-text';
  3. export function cook(text, options) {
  4. return new Handlebars.SafeString(new PrettyText(options).cook(text));
  5. }
  6. // everything should eventually move to async API and this should be renamed
  7. // cook
  8. export function cookAsync(text, options) {
  9. if (Discourse.MarkdownItURL) {
  10. return loadScript(Discourse.MarkdownItURL)
  11. .then(()=>cook(text, options))
  12. .catch(e => Ember.Logger.error(e));
  13. } else {
  14. return Ember.RSVP.Promise.resolve(cook(text));
  15. }
  16. }