Skip to content
pi-c Artifact [88bbd32cdc]
Login

Artifact [88bbd32cdc]

Artifact 88bbd32cdc7c7d6f04ed9b60bcec332116473bd322d1f674303d2a1d5073d9d8:


/* HTML to readable text (htmltext.c), for the web_fetch tool: a forgiving single pass, not a
 * browser. Headings, links, lists, code blocks, quotes and tables stay, as markdown; script,
 * style, navigation and the rest of the page's machinery go. */
#ifndef PIC_HTMLTEXT_H
#define PIC_HTMLTEXT_H

#include <stddef.h>

/* The page's links and images, made absolute by the caller: HREF is as written in the page;
 * the result is malloc'd, or NULL to keep HREF as it is. NULL resolve: kept as written. */
typedef char *(*pic_html_resolve_fn)(void *ctx, const char *href);

/* The text of the LEN bytes of HTML (UTF-8), malloc'd and NUL-terminated; NULL when out of
 * memory. A <title> becomes a first line "Title: ..." when there is one. */
char *pic_html_to_text(const char *html, size_t len, pic_html_resolve_fn resolve, void *ctx);

#endif