mirror of
https://github.com/TxtDot/dalet.git
synced 2025-02-24 13:21:27 +03:00
doc: add 10 tags
This commit is contained in:
parent
8530f84830
commit
584970fe93
7 changed files with 266 additions and 10 deletions
|
@ -10,7 +10,9 @@
|
|||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start": "node ./dist/index.js",
|
||||
"bstart": "tsc && node ./dist/index.js"
|
||||
"bstart": "tsc && node ./dist/index.js",
|
||||
"lint": "eslint ./src",
|
||||
"lint:fix": "eslint ./src --fix"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -59,7 +59,7 @@ export function parseBody(body: RawBody): Body {
|
|||
}
|
||||
|
||||
export function parse(root_data: Uint8Array): Root {
|
||||
let root = decode(root_data);
|
||||
const root = decode(root_data);
|
||||
|
||||
if (!Array.isArray(root)) {
|
||||
throw new ParseError("Daletl root must be array");
|
||||
|
|
|
@ -15,9 +15,10 @@ const TagNormalizers = [
|
|||
|
||||
export { TagNormalizers };
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function n(body: z.ZodTypeAny, argument: z.ZodTypeAny, T: any) {
|
||||
return (tag: RawTagAsArray) => {
|
||||
let parsedBody = parseBody(tag[1]);
|
||||
const parsedBody = parseBody(tag[1]);
|
||||
|
||||
z.tuple([z.number().int(), body, argument]).parse([
|
||||
tag[0],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { bodyToRaw, chtml } from "../../utils";
|
||||
import { RawTag, Tag, Body } from "../types";
|
||||
import { RawTag, Tag } from "../types";
|
||||
|
||||
export default class El extends Tag {
|
||||
constructor(body: string | Tag[]) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { parse, Root, El, Heading } from "./lib";
|
||||
|
||||
let data = new Root([
|
||||
const data = new Root([
|
||||
new El("I am Element"),
|
||||
new Heading("I am heading", 1),
|
||||
]).encode();
|
||||
|
||||
let root = parse(data);
|
||||
const root = parse(data);
|
||||
|
||||
console.log(root.raw, "\n");
|
||||
console.log(root.toHtml());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Body, ParseError, RawBody, RawTag, Tag } from "./daletl/types";
|
||||
import { Body, RawBody, RawTag, Tag } from "./daletl/types";
|
||||
|
||||
export function bodyToRaw(body: Body): RawBody {
|
||||
if (typeof body === "string") {
|
||||
|
@ -41,12 +41,12 @@ export function chtml(
|
|||
body?: Body,
|
||||
props?: Props
|
||||
) {
|
||||
let classProp = classes ? { class: classNames } : {};
|
||||
const classProp = classes ? { class: classNames } : {};
|
||||
return html(tag, body, { ...props, ...classProp });
|
||||
}
|
||||
|
||||
function html(tag: string, body?: Body, props?: Props) {
|
||||
let pr = Object.entries(props || {})
|
||||
const pr = Object.entries(props || {})
|
||||
.map(([key, value]) => `${key}="${value}"`)
|
||||
.join(" ");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue