2021-02-24 08:43:35 +01:00
|
|
|
import loadScript from "./load-script";
|
|
|
|
import { default as PrettyText } from "pretty-text/pretty-text";
|
2018-02-08 05:30:55 +01:00
|
|
|
|
|
|
|
export function cook(text, options) {
|
|
|
|
return new Handlebars.SafeString(new PrettyText(options).cook(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
// everything should eventually move to async API and this should be renamed
|
|
|
|
// cook
|
|
|
|
export function cookAsync(text, options) {
|
|
|
|
if (Discourse.MarkdownItURL) {
|
|
|
|
return loadScript(Discourse.MarkdownItURL)
|
2021-02-24 08:43:35 +01:00
|
|
|
.then(() => cook(text, options))
|
|
|
|
.catch((e) => Ember.Logger.error(e));
|
2018-02-08 05:30:55 +01:00
|
|
|
} else {
|
|
|
|
return Ember.RSVP.Promise.resolve(cook(text));
|
|
|
|
}
|
|
|
|
}
|