Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 📚 improve inline TypeScript docs #109

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* WASM functions for processing Markdown text and MJML, written in Rust. See README.md for
* examples.
*/

import { instantiate } from "./lib/parsedown.generated.js";

interface MarkdownToHtmlOKOutput {
Expand Down Expand Up @@ -25,6 +30,16 @@ interface MarkdownToHtmlOptions {

type MarkdownToPlaintextOptions = Omit<MarkdownToHtmlOptions, "searchTerm">;

/**
* Convert the, input, `markdown` string to HTML using a [CommonMark](https://commonmark.org/)
* Markdown Parser
*
* @param markdown The Markdown text to parse
* @param options.enableSmartPunctuation `true` if "something" should be replaced with
* “something”, etc.
* @returns `markdown` parsed into HTML as an object or an error object. If successful, the HTML is
* in the `.html` field of the returned object.
*/
const markdownToHtml: (
markdown: string,
options?: MarkdownToHtmlOptions,
Expand All @@ -46,6 +61,13 @@ const markdownToHtml: (
});
};

/**
* Convert the, input, `markdown` string to plaintext, to use, for example in a broadcast email or
* RSS feed
*
* @param markdown The Markdown text to parse
* @returns `markdown` parsed into a plaintext string
*/
const markdownToPlaintext: (
markdown: string,
options?: MarkdownToPlaintextOptions,
Expand All @@ -62,6 +84,12 @@ const markdownToPlaintext: (
});
};

/**
* Convert the, input, `mjml` string to HTML, for use in a broadcast email, for example
*
* @param markdown The Markdown text to parse
* @returns `markdown` parsed into a plaintext string
*/
const mjmlToHtml: (mjml: string) => Promise<string> = async function mjmlToHtml(
mjml,
) {
Expand Down
Loading