This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- http://en.wikipedia.org/wiki/Atom_%28standard%29 -->
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<subtitle>A subtitle.</subtitle>
<link href="http://example.org/feed/" rel="self" />
<link href="http://example.org/" />
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
<email>johndoe@example.com</email>
</author>
<entry>
<title>Atom-Powered Robots Run Amok</title>
<link href="http://example.org/2003/12/13/atom03" />
<link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/>
<link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<content type="html"><p>Some content.</p></content>
</entry>
<entry/>
</feed>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<title>Attributes test</title>
</head>
<body>
<!-- Normal attributes -->
<button id="test0" class="value0" title="value1">class="value0" title="value1"</button>
<!-- Attributes with no quotes or value -->
<button id="test1" class=value2 disabled>class=value2 disabled</button>
<!-- Attributes with no space between them. No valid, but accepted by the browser -->
<button id="test2" class="value4"title="value5">class="value4"title="value5"</button>
</body>
</html>

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html><title>The Title</title><body>Hello world</body></html>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:ev="http://purl.org/rss/1.0/modules/event/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:admin="http://webns.net/mvcb/">
<channel rdf:about="https://github.com/fb55/htmlparser2/">
<title>A title to parse and remember</title>
<link>https://github.com/fb55/htmlparser2/</link>
<description/>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2015 the authors</dc:rights>
<dc:publisher>webmaster@thisisafakedoma.in</dc:publisher>
<dc:creator>webmaster@thisisafakedoma.in</dc:creator>
<dc:source>https://github.com/fb55/htmlparser2/</dc:source>
<dc:title>A title to parse and remember</dc:title>
<dc:type>Collection</dc:type>
<syn:updateBase>2011-11-04T09:39:10-07:00</syn:updateBase>
<syn:updateFrequency>4</syn:updateFrequency>
<syn:updatePeriod>hourly</syn:updatePeriod>
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://somefakesite/path/to/something.html"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="http://somefakesite/path/to/something.html">
<title><![CDATA[ Fast HTML Parsing ]]></title>
<link>
http://somefakesite/path/to/something.html
</link>
<description><![CDATA[
Great test content<br>A link: <a href="http://github.com">Github</a>
]]></description>
<dc:date>2011-11-04T09:35:17-07:00</dc:date>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2015 the authors</dc:rights>
<dc:source>
http://somefakesite/path/to/something.html
</dc:source>
<dc:title><![CDATA[ Fast HTML Parsing ]]></dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2011-11-04T09:35:17-07:00</dcterms:issued>
</item>
<item rdf:about="http://somefakesite/path/to/something-else.html">
<title><![CDATA[
This space intentionally left blank
]]></title>
<link>
http://somefakesite/path/to/something-else.html
</link>
<description><![CDATA[
The early bird gets the worm
]]></description>
<dc:date>2011-11-04T09:34:54-07:00</dc:date>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2015 the authors</dc:rights>
<dc:source>
http://somefakesite/path/to/something-else.html
</dc:source>
<dc:title><![CDATA[
This space intentionally left blank
]]></dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2011-11-04T09:34:54-07:00</dcterms:issued>
</item>
</rdf:RDF>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0"?>
<!-- http://cyber.law.harvard.edu/rss/examples/rss2sample.xml -->
<rss version="2.0">
<channel>
<title>Liftoff News</title>
<link>http://liftoff.msfc.nasa.gov/</link>
<description>Liftoff to Space Exploration.</description>
<language>en-us</language>
<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Weblog Editor 2.0</generator>
<managingEditor>editor@example.com</managingEditor>
<webMaster>webmaster@example.com</webMaster>
<item>
<title>Star City</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
<description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's &lt;a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm"&gt;Star City&lt;/a&gt;.</description>
<pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
</item>
<item>
<description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a &lt;a href="http://science.nasa.gov/headlines/y2003/30may_solareclipse.htm"&gt;partial eclipse of the Sun&lt;/a&gt; on Saturday, May 31st.</description>
<pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
</item>
<item>
<title>The Engine That Does More</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
<description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly. The proposed VASIMR engine would do that.</description>
<pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
</item>
<item>
<title>Astronauts' Dirty Laundry</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
<description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them. Instead, astronauts have other options.</description>
<pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
<media:content height="200" medium="image" url="https://picsum.photos/200" width="200"/>
</item>
</channel>
</rss>

View File

@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<title>SVG test</title>
</head>
<body>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Test</title>
<animate />
<polygon />
<g>
<path>
<title>x</title>
<animate />
</path>
</g>
</svg>
</body>
</html>

View File

@@ -0,0 +1,89 @@
import type { Parser, Handler } from "../Parser.js";
interface Event {
$event: string;
data: unknown[];
startIndex: number;
endIndex: number;
}
/**
* Creates a handler that calls the supplied callback with simplified events on
* completion.
*
* @internal
* @param callback Function to call with all events.
*/
export function getEventCollector(
callback: (error: Error | null, events?: Event[]) => void,
): Partial<Handler> {
const events: Event[] = [];
let parser: Parser;
function handle(event: string, data: unknown[]): void {
switch (event) {
case "onerror": {
callback(data[0] as Error);
break;
}
case "onend": {
callback(null, events);
break;
}
case "onreset": {
events.length = 0;
break;
}
case "onparserinit": {
parser = data[0] as Parser;
// Don't collect event
break;
}
default: {
// eslint-disable-next-line unicorn/prefer-at
const last = events[events.length - 1];
// Combine text nodes
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (event === "ontext" && last && last.$event === "text") {
(last.data[0] as string) += data[0];
last.endIndex = parser.endIndex;
break;
}
// Remove `undefined`s from attribute responses, as they cannot be represented in JSON.
if (event === "onattribute" && data[2] === undefined) {
data.pop();
}
if (!(parser.startIndex <= parser.endIndex)) {
throw new Error(
`Invalid start/end index ${parser.startIndex} > ${parser.endIndex}`,
);
}
events.push({
$event: event.slice(2),
startIndex: parser.startIndex,
endIndex: parser.endIndex,
data,
});
}
}
}
return new Proxy(
{},
{
get:
(_, event: string) =>
(...data: unknown[]) =>
handle(event, data),
},
);
}