Skip to content

Commit

Permalink
style: 🛁 linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneylab committed Dec 9, 2024
1 parent 6ba0770 commit 31f3346
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MarkdownToHtmlOptions, "searchTerm">;
Expand All @@ -51,25 +51,25 @@ type MarkdownToPlaintextOptions = Omit<MarkdownToHtmlOptions, "searchTerm">;
* in the `.html` field of the returned object.
*/
const markdownToHtml: (
markdown: string,
options?: MarkdownToHtmlOptions,
markdown: string,
options?: MarkdownToHtmlOptions,
) => Promise<MarkdownToHtmlOKOutput | MarkdownToHtmlErrorOutput> =
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
Expand All @@ -79,19 +79,19 @@ const markdownToHtml: (
* @returns `markdown` parsed into a plaintext string
*/
const markdownToPlaintext: (
markdown: string,
options?: MarkdownToPlaintextOptions,
markdown: string,
options?: MarkdownToPlaintextOptions,
) => Promise<string> = 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 }
: {}),
});
};

/**
Expand All @@ -101,10 +101,10 @@ const markdownToPlaintext: (
* @returns `markdown` parsed into a plaintext string
*/
const mjmlToHtml: (mjml: string) => Promise<string> = 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 };

0 comments on commit 31f3346

Please sign in to comment.