doc: add 10 tags

This commit is contained in:
Artemy Egorov 2024-07-26 12:22:37 +03:00
parent 8530f84830
commit 584970fe93
7 changed files with 266 additions and 10 deletions

View file

@ -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",

View file

@ -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");

View file

@ -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],

View file

@ -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[]) {

View file

@ -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());

View file

@ -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(" ");

View file

@ -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 `<a href="#argument"></a>` 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"]
```