view markdown_converter/markdown_to_html.h @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents 1c0878eb17de
children
line wrap: on
line source

/**
 * Markdown to HTML Converter - C Implementation
 * Supports: headers, bold, italic, links, lists, code blocks, blockquotes, horizontal rules
 */
#ifndef MARKDOWN_TO_HTML_H
#define MARKDOWN_TO_HTML_H

#include <stddef.h>

// Export macro for WASM/Emscripten
#ifdef __EMSCRIPTEN__
  #include <emscripten.h>
  #define MDAPI EMSCRIPTEN_KEEPALIVE
#else
  #ifdef _WIN32
    #ifdef MARKDOWN_EXPORTS
      #define MDAPI __declspec(dllexport)
    #else
      #define MDAPI __declspec(dllimport)
    #endif
  #else
    #define MDAPI extern
  #endif
#endif

/**
 * Convert markdown string to HTML string.
 *
 * @param markdown The input markdown string (null-terminated)
 * @return Newly allocated HTML string. Caller must free with markdown_free().
 *         Returns NULL on allocation failure.
 *
 * Supported markdown features:
 * - Headers: # H1, ## H2, ... ###### H6
 * - Bold: **text** or __text__
 * - Italic: *text* or _text_
 * - Strikethrough: ~~text~~
 * - Links: [text](url)
 * - Images: ![alt](url)
 * - Inline code: `code`
 * - Code blocks: ```code```
 * - Unordered lists: -, *, +
 * - Ordered lists: 1., 2., etc.
 * - Blockquotes: > text
 * - Horizontal rules: ---, ***, ___
 */
MDAPI char *markdown_to_html(const char *markdown);

/**
 * Free HTML string returned by markdown_to_html.
 *
 * @param html The HTML string to free
 */
MDAPI void markdown_free(char *html);

/**
 * Get length of HTML string (useful for WASM memory operations).
 *
 * @param html The HTML string
 * @return Length of the string, or 0 if NULL
 */
MDAPI size_t markdown_get_length(const char *html);

#endif // MARKDOWN_TO_HTML_H