1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 18:25:07 +00:00

LibHTML: Start working on a very simplified HTML parser.

This commit is contained in:
Andreas Kling 2019-06-15 20:20:55 +02:00
parent a67e823838
commit 581d6b00c8
4 changed files with 139 additions and 22 deletions

View file

@ -1,10 +1,18 @@
#include <LibCore/CFile.h>
#include <LibHTML/Dump.h>
#include <LibHTML/Element.h>
#include <LibHTML/Parser.h>
#include <stdio.h>
int main()
int main(int argc, char** argv)
{
String html = "<html><head><title>my page</title></head><body><h1>Hi there</h1><p>Hello World!</p></body></html>";
CFile f(argc == 1 ? "/home/anon/small.html" : argv[1]);
if (!f.open(CIODevice::ReadOnly)) {
fprintf(stderr, "Error: %s\n", f.error_string());
return 1;
}
String html = String::copy(f.read_all());
auto doc = parse(html);
dump_tree(doc);
return 0;
}