ts-markdown-parser
Version:
TypeScript library that converts markdown to HTML (with code support).
53 lines • 2.38 kB
TypeScript
import { MarkdownElement } from "../models";
/**
* Replaces reference links in markdown text with their corresponding titles and URLs.
*
* This function performs two passes over the markdown text:
* 1. It captures reference definitions and stores them in a map.
* 2. It replaces inline references with their corresponding titles and URLs.
*
* @param {string} markdown - The markdown text to process.
* @returns {string} The processed markdown text with reference links replaced.
*/
export declare const replaceReferenceLinks: (markdown: string) => string;
/**
* Escapes HTML special characters inside quotes or backticks to prevent HTML injection.
* - Converts special characters to their HTML entity equivalents.
*
* @param {string} html HTML string to be escaped.
* @returns {string} Escaped HTML string.
*/
export declare const escapeHtml: (html: string) => string;
/**
* Replaces markdown tables (that contain `|` and `_` characters) with table-related HTML elements.
*
* @param {string[]} lines Text containing markdown tables
* @returns {string} Text with `<table>` and `<tbody>` HTML injected into it
*/
export declare const markdownTableToHTML: (lines: string[]) => string;
/**
* Replaces special Unicode single quotes with a regular single quote.
*
* @param {string} text Text containing special single quotes.
* @returns {string} Text with special single quotes replaced.
*/
export declare const replaceSpecialQuotes: (text: string) => string;
/**
* Converts a Markdown string into an array of MarkdownElement objects.
* - Handles headers, code blocks, unordered lists, and paragraphs.
*
* @param {string} markdown Markdown string to be parsed.
* @returns {MarkdownElement[]} An array of MarkdownElement objects.
*/
export declare const parseMarkdown: (markdown: string) => MarkdownElement[];
/**
* Converts a MarkdownElement object to an HTML string.
* - Handles different element types including headers, code blocks, tables, and lists.
*
* @param {MarkdownElement} element MarkdownElement object to be converted.
* @returns {string} HTML representation of the MarkdownElement.
*/
export declare const elementToHtml: (element: MarkdownElement, opts: Record<string, any>) => string;
export declare const globalScript: () => string;
export declare const checkboxScript: () => string;
//# sourceMappingURL=markdown-parser.d.ts.map