diff --git a/mod.ts b/mod.ts index 2a88972..3d513aa 100644 --- a/mod.ts +++ b/mod.ts @@ -6,26 +6,26 @@ import { instantiate } from "./lib/parsedown.generated.js"; interface MarkdownToHtmlOKOutput { - errors?: never; - headings: { heading: string; id: string }[]; - html: string; - statistics: { - reading_time: number; - word_count: number; - }; + errors?: never; + headings: { heading: string; id: string }[]; + html: string; + statistics: { + reading_time: number; + word_count: number; + }; } interface MarkdownToHtmlErrorOutput { - errors: string[]; - headings?: never; - html?: never; - statistics?: never; + errors: string[]; + headings?: never; + html?: never; + statistics?: never; } interface MarkdownToHtmlOptions { - canonicalRootUrl?: string; - enableSmartPunctuation?: string; - searchTerm?: string; + canonicalRootUrl?: string; + enableSmartPunctuation?: string; + searchTerm?: string; } type MarkdownToPlaintextOptions = Omit; @@ -51,25 +51,25 @@ type MarkdownToPlaintextOptions = Omit; * in the `.html` field of the returned object. */ const markdownToHtml: ( - markdown: string, - options?: MarkdownToHtmlOptions, + markdown: string, + options?: MarkdownToHtmlOptions, ) => Promise = - async function markdownToHtml(markdown, options) { - const { markdown_to_html } = await instantiate(); - const { canonicalRootUrl, enableSmartPunctuation, searchTerm } = options ?? - {}; + async function markdownToHtml(markdown, options) { + const { markdown_to_html } = await instantiate(); + const { canonicalRootUrl, enableSmartPunctuation, searchTerm } = options ?? + {}; - return markdown_to_html(markdown, { - enable_smart_punctuation: true, - ...(typeof canonicalRootUrl !== "undefined" - ? { canonical_root_url: canonicalRootUrl } - : {}), - ...(typeof enableSmartPunctuation !== "undefined" - ? { enable_smart_punctuation: enableSmartPunctuation } - : {}), - ...(typeof searchTerm !== "undefined" ? { search_term: searchTerm } : {}), - }); - }; + return markdown_to_html(markdown, { + enable_smart_punctuation: true, + ...(typeof canonicalRootUrl !== "undefined" + ? { canonical_root_url: canonicalRootUrl } + : {}), + ...(typeof enableSmartPunctuation !== "undefined" + ? { enable_smart_punctuation: enableSmartPunctuation } + : {}), + ...(typeof searchTerm !== "undefined" ? { search_term: searchTerm } : {}), + }); + }; /** * Convert the, input, `markdown` string to plaintext, to use, for example in a broadcast email or @@ -79,19 +79,19 @@ const markdownToHtml: ( * @returns `markdown` parsed into a plaintext string */ const markdownToPlaintext: ( - markdown: string, - options?: MarkdownToPlaintextOptions, + markdown: string, + options?: MarkdownToPlaintextOptions, ) => Promise = async function markdownToPlaintext(markdown, options) { - const { markdown_to_plaintext } = await instantiate(); - const { canonicalRootUrl, enableSmartPunctuation } = options ?? {}; - return markdown_to_plaintext(markdown, { - ...(typeof canonicalRootUrl !== "undefined" - ? { canonical_root_url: canonicalRootUrl } - : {}), - ...(typeof enableSmartPunctuation !== "undefined" - ? { enable_smart_punctuation: enableSmartPunctuation } - : {}), - }); + const { markdown_to_plaintext } = await instantiate(); + const { canonicalRootUrl, enableSmartPunctuation } = options ?? {}; + return markdown_to_plaintext(markdown, { + ...(typeof canonicalRootUrl !== "undefined" + ? { canonical_root_url: canonicalRootUrl } + : {}), + ...(typeof enableSmartPunctuation !== "undefined" + ? { enable_smart_punctuation: enableSmartPunctuation } + : {}), + }); }; /** @@ -101,10 +101,10 @@ const markdownToPlaintext: ( * @returns `markdown` parsed into a plaintext string */ const mjmlToHtml: (mjml: string) => Promise = async function mjmlToHtml( - mjml, + mjml, ) { - const { mjml_to_html } = await instantiate(); - return mjml_to_html(mjml); + const { mjml_to_html } = await instantiate(); + return mjml_to_html(mjml); }; export { markdownToHtml, markdownToPlaintext, mjmlToHtml };