Skip to content
pi-c Artifact [0ef4abad74]
Login

Artifact [0ef4abad74]

Artifact 0ef4abad74077b95d4b6a05b3819d09ef41fdf0f0a3efac318e5c001366b3419:


/* 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_fn: 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_fn, void *ctx);

#endif