Mercurial
comparison markdown_converter/markdown_to_html.h @ 158:1c0878eb17de
[MrJuneJune] Readme file gets compiled in server side.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 14 Jan 2026 07:59:19 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 157:2db6253f355d | 158:1c0878eb17de |
|---|---|
| 1 /** | |
| 2 * Markdown to HTML Converter - C Implementation | |
| 3 * Supports: headers, bold, italic, links, lists, code blocks, blockquotes, horizontal rules | |
| 4 */ | |
| 5 #ifndef MARKDOWN_TO_HTML_H | |
| 6 #define MARKDOWN_TO_HTML_H | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 // Export macro for WASM/Emscripten | |
| 11 #ifdef __EMSCRIPTEN__ | |
| 12 #include <emscripten.h> | |
| 13 #define MDAPI EMSCRIPTEN_KEEPALIVE | |
| 14 #else | |
| 15 #ifdef _WIN32 | |
| 16 #ifdef MARKDOWN_EXPORTS | |
| 17 #define MDAPI __declspec(dllexport) | |
| 18 #else | |
| 19 #define MDAPI __declspec(dllimport) | |
| 20 #endif | |
| 21 #else | |
| 22 #define MDAPI extern | |
| 23 #endif | |
| 24 #endif | |
| 25 | |
| 26 /** | |
| 27 * Convert markdown string to HTML string. | |
| 28 * | |
| 29 * @param markdown The input markdown string (null-terminated) | |
| 30 * @return Newly allocated HTML string. Caller must free with markdown_free(). | |
| 31 * Returns NULL on allocation failure. | |
| 32 * | |
| 33 * Supported markdown features: | |
| 34 * - Headers: # H1, ## H2, ... ###### H6 | |
| 35 * - Bold: **text** or __text__ | |
| 36 * - Italic: *text* or _text_ | |
| 37 * - Strikethrough: ~~text~~ | |
| 38 * - Links: [text](url) | |
| 39 * - Images:  | |
| 40 * - Inline code: `code` | |
| 41 * - Code blocks: ```code``` | |
| 42 * - Unordered lists: -, *, + | |
| 43 * - Ordered lists: 1., 2., etc. | |
| 44 * - Blockquotes: > text | |
| 45 * - Horizontal rules: ---, ***, ___ | |
| 46 */ | |
| 47 MDAPI char *markdown_to_html(const char *markdown); | |
| 48 | |
| 49 /** | |
| 50 * Free HTML string returned by markdown_to_html. | |
| 51 * | |
| 52 * @param html The HTML string to free | |
| 53 */ | |
| 54 MDAPI void markdown_free(char *html); | |
| 55 | |
| 56 /** | |
| 57 * Get length of HTML string (useful for WASM memory operations). | |
| 58 * | |
| 59 * @param html The HTML string | |
| 60 * @return Length of the string, or 0 if NULL | |
| 61 */ | |
| 62 MDAPI size_t markdown_get_length(const char *html); | |
| 63 | |
| 64 #endif // MARKDOWN_TO_HTML_H |