1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[implementation] Standard document

This commit is contained in:
Witold Filipczyk 2021-09-15 19:29:31 +02:00
parent 387a2836f1
commit 00f3f224d1

View File

@ -14,6 +14,7 @@
#include "ecmascript/spidermonkey/document.h"
#include "ecmascript/spidermonkey/implementation.h"
#include "ecmascript/spidermonkey/util.h"
#include "util/conv.h"
#include <jsfriendapi.h>
#include <libxml/HTMLparser.h>
@ -72,11 +73,15 @@ implementation_createHTMLDocument(JSContext *ctx, unsigned int argc, JS::Value *
if (title) {
struct string str;
init_string(&str);
if (!init_string(&str)) {
mem_free(title);
args.rval().setNull();
return true;
}
add_to_string(&str, "<head><title>");
add_to_string(&str, title);
add_to_string(&str, "</title></head>");
add_to_string(&str, "<!doctype html>\n<html><head><title>");
add_html_to_string(&str, title, strlen(title));
add_to_string(&str, "</title></head><body></body></html>");
// Parse HTML and create a DOM tree
xmlDoc* doc = htmlReadDoc((xmlChar*)str.source, NULL, "utf-8",