Skip to content

An HTML AST, parser, and writer library written in TypeScript.

License

Notifications You must be signed in to change notification settings

LambdAurora/lib.html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lib.html

Language: TypeScript GitHub license JSR badge GitHub issues

An HTML AST, parser, and writer library written in TypeScript.

Example

import * as html from "@lambdaurora/libhtml";

const div = html.parse(`<div>
	<h1>Hello World!</h1>
	<p>
		This is a lovely HTML source.
	</p>
</div>`) as html.Element;

div.get_element_by_tag_name("h1").text // Hello World!

const alert = html.create_element("div")
	.with_child(html.create_element("h1")
		.with_child("Alert: this is a lovely day!")
	).with_child(html.create_element("p")
		.with_child("Have a good day!")
	);

const html_string = alert.html();

const dialog = html.dialog({
	children: [
		html.h1(["Hello world!"]),
		html.p(["I hope you have a wonderful day!"]),
		html.button(["Thank you"])
	],
	attributes: {
		open: ""
	}
});

const other_html_string = dialog.html();

Usage

Deno

Add the library from JSR:

deno add @lambdaurora/libhtml

Then import it:

import * as html from "@lambdaurora/libhtml";

Web

Import the library using esm.sh:

import * as html from "https://esm.sh/jsr/@lambdaurora/libhtml@1.3.0";

About

An HTML AST, parser, and writer library written in TypeScript.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published