Skip to content

Commit b399cb2

Browse files
committed
docs(readme): update for v0.7.0
1 parent c0f6c12 commit b399cb2

1 file changed

Lines changed: 51 additions & 40 deletions

File tree

README.md

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,20 @@ Example: [PCS-OS](https://github.com/FBIKdot/PCS-OS)
1818
You can access Hnxml Standard through:
1919

2020
- Website generated by [Typedoc](https://typedoc.org/):
21-
[hnxml.js.org](https://hnxml.js.org)
21+
[hnxml.js.org](https://hnxml.js.org) (Most recommended)
2222
- Source code: [GitHub Repository](https://github.com/Modern-School/hnxml)
23+
- [JSR package page](https://jsr.io/@modernschoolproject/hnxml/doc)
2324

2425
## Use `hnxml.js` with TSX
2526

26-
Add package `@modernschoolproject/hnxml`
27+
Add package `@modernschoolproject/hnxml`. Check
28+
[the hnxml JSR package page](https://jsr.io/@modernschoolproject/hnxml/doc) to
29+
see how to install JSR packages using other package managers.
2730

2831
```bash
29-
# deno
30-
deno add jsr:@modernschoolproject/hnxml
31-
```
32-
33-
```bash
34-
# npm
35-
npx jsr add @modernschoolproject/hnxml
36-
```
37-
38-
```bash
39-
# yarn
40-
yarn add jsr:@modernschoolproject/hnxml
41-
```
42-
43-
```bash
44-
# pnpm
45-
pnpm i jsr:@modernschoolproject/hnxml
46-
```
47-
48-
```bash
49-
# bun
50-
bunx jsr add @modernschoolproject/hnxml
32+
deno add jsr:@modernschoolproject/hnxml # deno
33+
npx jsr add @modernschoolproject/hnxml # npm
34+
pnpm i jsr:@modernschoolproject/hnxml # pnpm
5135
```
5236

5337
Edit `compilerOptions` in `tsconfig.json` or `deno.json`
@@ -61,22 +45,12 @@ Edit `compilerOptions` in `tsconfig.json` or `deno.json`
6145
}
6246
```
6347

64-
Then declare `JSX.IntrinsicElements` for the Hacknet Extension XML types you
65-
want to generate.
66-
67-
For example, if you want to use `Mission` and `Actions`:
48+
Then create a `.jsx` or `.tsx` file and import render from `hnxml/jsx`. For
49+
example:
6850

69-
```ts
70-
import { render } from "@modernschoolproject/hnxml";
71-
72-
declare module "@modernschoolproject/hnxml/jsx-runtime" {
73-
namespace JSX {
74-
type IntrinsicElements =
75-
& import("@modernschoolproject/hnxml/jsx/mission").MissionElements
76-
& import("@modernschoolproject/hnxml/jsx/action").TriggerElements
77-
& import("@modernschoolproject/hnxml/jsx/task").TaskElements;
78-
}
79-
}
51+
```tsx
52+
// main.tsx
53+
import { render } from "@modernschoolproject/hnxml/jsx";
8054

8155
console.log(
8256
render(
@@ -87,6 +61,43 @@ console.log(
8761
>
8862
...
8963
</mission>,
90-
).end({ headless: true, allowEmptyTags: true }),
64+
).end({
65+
headless: true,
66+
prettyPrint: true,
67+
allowEmptyTags: false,
68+
spaceBeforeSlash: true,
69+
}),
70+
);
71+
```
72+
73+
Tips: you can use this way to set default `XMLBuilderCreateOptions`.
74+
75+
```tsx
76+
// render.ts
77+
import { render as _render } from "hnxml/jsx";
78+
import { JsxXmlElement } from "hnxml/jsx-runtime";
79+
80+
export function render(element: JsxXmlElement): string {
81+
return _render(element).end({
82+
headless: true,
83+
prettyPrint: true,
84+
allowEmptyTags: false,
85+
spaceBeforeSlash: true,
86+
});
87+
}
88+
```
89+
90+
```tsx
91+
// main.tsx
92+
import { render } from "./render.ts";
93+
94+
console.log(
95+
<mission
96+
id="missionID"
97+
activeCheck="true"
98+
shouldIgnoreSenderVerification="true"
99+
>
100+
...
101+
</mission>,
91102
);
92103
```

0 commit comments

Comments
 (0)