From aae79c95fe1ebb916114ad8406d458cd0f8566cf Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sun, 10 Aug 2014 02:10:16 +0200 Subject: [PATCH] Add rendering for html source element --- src/document/html/parser/link.c | 33 ++++++++++++++++++++++++++++++++ src/document/html/parser/link.h | 1 + src/document/html/parser/parse.c | 1 + 3 files changed, 35 insertions(+) diff --git a/src/document/html/parser/link.c b/src/document/html/parser/link.c index 7508c95e..6e8acb37 100644 --- a/src/document/html/parser/link.c +++ b/src/document/html/parser/link.c @@ -358,6 +358,39 @@ html_img(struct html_context *html_context, unsigned char *a, html_img_do(a, NULL, html_context); } +void +html_source(struct html_context *html_context, unsigned char *a, + unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5) +{ + unsigned char *src, *title; + struct document_options *options = html_context->options; + int display_style = options->image_link.display_style; + + src = get_url_val(a, "src", html_context->doc_cp); + if (!src) return; + + title = get_attr_val(a, "title", html_context->doc_cp); + if (!title || !*title) { + if (display_style == 3) { + mem_free_if(title); + title = get_image_filename_from_src(options->image_link.filename_maxlen, src); + } + } + + html_focusable(html_context, a); + + if (title && *title) { + put_link_line("Source: ", title, src, + html_context->options->framename, html_context); + } else { + put_link_line("", "Source", src, + html_context->options->framename, html_context); + } + + mem_free_if(title); + mem_free(src); +} + /* prefix can have entities in it, but linkname cannot. */ void put_link_line(unsigned char *prefix, unsigned char *linkname, diff --git a/src/document/html/parser/link.h b/src/document/html/parser/link.h index d06059f9..9b087e87 100644 --- a/src/document/html/parser/link.h +++ b/src/document/html/parser/link.h @@ -14,6 +14,7 @@ element_handler_T html_iframe; element_handler_T html_img; element_handler_T html_link; element_handler_T html_object; +element_handler_T html_source; element_handler_T html_audio; element_handler_T html_video; element_handler_T html_embed; diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index d4c6be3a..54e8cca0 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -482,6 +482,7 @@ static struct element_info elements[] = { {"S", html_underline, NULL, 0, ET_NESTABLE }, {"SCRIPT", html_script, NULL, 0, ET_NESTABLE }, {"SELECT", html_select, NULL, 0, ET_NESTABLE }, + {"SOURCE", html_source, NULL, 1, ET_NON_PAIRABLE}, {"SPAN", html_span, NULL, 0, ET_NESTABLE }, {"STRIKE", html_underline, NULL, 0, ET_NESTABLE }, {"STRONG", html_bold, NULL, 0, ET_NESTABLE },