diff --git a/libs/typescript/package.json b/libs/typescript/package.json index 592ea5a..3826e00 100644 --- a/libs/typescript/package.json +++ b/libs/typescript/package.json @@ -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", diff --git a/libs/typescript/src/daletl/main.ts b/libs/typescript/src/daletl/main.ts index 352b245..07d3e23 100644 --- a/libs/typescript/src/daletl/main.ts +++ b/libs/typescript/src/daletl/main.ts @@ -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"); diff --git a/libs/typescript/src/daletl/normalizers.ts b/libs/typescript/src/daletl/normalizers.ts index 99ffe2f..d773bb9 100644 --- a/libs/typescript/src/daletl/normalizers.ts +++ b/libs/typescript/src/daletl/normalizers.ts @@ -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], diff --git a/libs/typescript/src/daletl/tags/el.ts b/libs/typescript/src/daletl/tags/el.ts index 0df97b7..726f2f5 100644 --- a/libs/typescript/src/daletl/tags/el.ts +++ b/libs/typescript/src/daletl/tags/el.ts @@ -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[]) { diff --git a/libs/typescript/src/index.ts b/libs/typescript/src/index.ts index a698685..f0e4eab 100644 --- a/libs/typescript/src/index.ts +++ b/libs/typescript/src/index.ts @@ -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()); diff --git a/libs/typescript/src/utils.ts b/libs/typescript/src/utils.ts index 317653c..fb0c0b3 100644 --- a/libs/typescript/src/utils.ts +++ b/libs/typescript/src/utils.ts @@ -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(" "); diff --git a/specification/tags.md b/specification/tags.md index 8d85de2..672c43d 100644 --- a/specification/tags.md +++ b/specification/tags.md @@ -95,7 +95,7 @@ br **Daletl example (json5 representation)**: ```json5 -[3] +3 ``` ## 4. Unordered list @@ -423,3 +423,256 @@ tpcol: { ], ] ``` + +## 15. Horizontal rule + +| Property | Description | +| -------- | ----------- | +| name | hr | +| id | 15 | +| body | no | +| argument | no | + +Creates a horizontal rule. + +**Daleth example**: + +```yaml +hr +``` + +**Daletl example (json5 representation)**: + +```json5 +15 +``` + +## 16. Bold + +| Property | Description | +| -------- | ----------- | +| name | b | +| id | 16 | +| body | text | +| argument | no | + +Creates **bold** text. + +**Daleth example**: + +```yaml +b: I am Bold +``` + +**Daletl example (json5 representation)**: + +```json5 +[16, "I am Bold"] +``` + +## 17. Italic + +| Property | Description | +| -------- | ----------- | +| name | i | +| id | 17 | +| body | text | +| argument | no | + +Creates _italic_ text. + +**Daleth example**: + +```yaml +i: I am Italic +``` + +**Daletl example (json5 representation)**: + +```json5 +[17, "I am Italic"] +``` + +## 18. Blockquote + +| Property | Description | +| -------- | ----------- | +| name | bq | +| id | 18 | +| body | text, tags | +| argument | no | + +Creates a blockquote. + +**Daleth example**: + +```yaml +bq: I am Blockquote +``` + +**Daletl example (json5 representation)**: + +```json5 +[18, "I am Blockquote"] +``` + +## 19. Footnote Link + +| Property | Description | +| -------- | -------------- | +| name | footlnk | +| id | 19 | +| body | no | +| argument | string, number | + +Link to footnote. + +**Daleth example**: + +```yaml +footlnk[1] +``` + +**Daletl example (json5 representation)**: + +```json5 +[19, null, 1] +``` + +## 20. Footnote + +| Property | Description | +| -------- | -------------- | +| name | footn | +| id | 20 | +| body | text | +| argument | string, number | + +Creates footnote. + +**Daleth example**: + +```yaml +footn[1]: I am Footnote +``` + +**Daletl example (json5 representation)**: + +```json5 +[20, "I am Footnote", 1] +``` + +## 21. Anchor + +| Property | Description | +| -------- | -------------- | +| name | a | +| id | 21 | +| body | no | +| argument | string, number | + +Creates anchor. Like `` in HTML. + +**Daleth example**: + +```yaml +a[0] +``` + +**Daletl example (json5 representation)**: + +```json5 +[21, null, 0] +``` + +## 22. Strikethrough + +| Property | Description | +| -------- | ----------- | +| name | s | +| id | 22 | +| body | text | +| argument | no | + +Creates ~~strikethrough~~ text. + +**Daleth example**: + +```yaml +s: I am Strikethrough +``` + +**Daletl example (json5 representation)**: + +```json5 +[22, "I am Strikethrough"] +``` + +## 23. Superscript + +| Property | Description | +| -------- | ----------- | +| name | sup | +| id | 23 | +| body | text | +| argument | no | + +Creates ^superscript^ text. + +**Daleth example**: + +```yaml +sup: I am Superscript +``` + +**Daletl example (json5 representation)**: + +```json5 +[23, "I am Superscript"] +``` + +## 24. Subscript + +| Property | Description | +| -------- | ----------- | +| name | sub | +| id | 24 | +| body | text | +| argument | no | + +Creates ~subscript~ text. + +**Daleth example**: + +```yaml +sub: I am Subscript +``` + +**Daletl example (json5 representation)**: + +```json5 +[24, "I am Subscript"] +``` + +## 25. Disclosure + +| Property | Description | +| -------- | ----------- | +| name | disc | +| id | 25 | +| body | text, tags | +| argument | string | + +Creates disclosure element. + +**Daleth example**: + +```yaml +disc[Click to expand]: I am Disclosure +``` + +**Daletl example (json5 representation)**: + +```json5 +[25, "I am Disclosure", "Click to expand"] +```