diff --git a/zet.dpi.c b/zet.dpi.c index d0f7cc3..f59bc27 100644 --- a/zet.dpi.c +++ b/zet.dpi.c @@ -656,6 +656,30 @@ md_rndr_link(struct buf *ob, const struct buf *link, const struct buf *title, co return 1; } +static int +md_rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, void *opaque) +{ + struct html_renderopt *options = opaque; + if (!link || !link->size) return 0; + + BUFPUTSL(ob, "data, link->size); + BUFPUTSL(ob, "\" alt=\""); + + if (alt && alt->size) + houdini_escape_html0(ob, alt->data, alt->size, 0); + + if (title && title->size) { + BUFPUTSL(ob, "\" title=\""); + houdini_escape_html0(ob, title->data, title->size, 0); + } + + (void)options; + bufputs(ob, "\"/>"); + return 1; +} + static void put_link_truncated(struct buf *ob, const struct buf *link, int max_length) { char *buf = (char *)link->data; size_t len = link->size; @@ -822,6 +846,7 @@ static int dpi_serve_zet(int fd, char *path) { struct buf *ob = bufnew(128); sdhtml_renderer(&callbacks, &options, HTML_ESCAPE); callbacks.link = md_rndr_link; + callbacks.image = md_rndr_image; callbacks.autolink = md_rndr_autolink; static const unsigned int extensions = MKDEXT_NO_INTRA_EMPHASIS |