Skip to content

Commit

Permalink
docs: update readme.typ from 0.1.0 to 0.5.0 (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin authored Aug 19, 2024
1 parent 6cbdf9b commit cd21af9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Prepare artifacts
run: |
shiroa build --font-path assets/fonts --path-to-root /typst.ts/cookery/ -w . -d ../../github-pages/cookery/ docs/cookery
cargo run --profile release-ci --bin typst-ts-cli -- compile --workspace ./github-pages/docs/ --entry ./github-pages/docs/readme.typ --format=pdf --format=vector
cargo run --profile release-ci --bin typst-ts-cli -- compile --workspace . --entry ./github-pages/docs/readme.typ --input=x-target=pdf-ayu --format=pdf --format=vector
- name: Copy assets
run: |
mkdir -p github-pages/compiler/
Expand Down
2 changes: 1 addition & 1 deletion docs/cookery/get-started.typ
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ See #link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.t
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/all-in-one.html")[All-in-one (Simplified) JavaScript Library]
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/compilers.html")[Compilers]
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/renderers.html")[Renderers]
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/trouble-shooting.html")[Troble shooting]
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/trouble-shooting.html")[Trouble shooting]
2 changes: 1 addition & 1 deletion docs/cookery/introduction.typ
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ So with *Form2*, you can continue rendering the document in different ways:
== Further reading

+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/get-started.html")[Get started with Typst.ts]
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/trouble-shooting.html")[Troble shooting]
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/trouble-shooting.html")[Trouble shooting]
174 changes: 4 additions & 170 deletions github-pages/docs/readme.typ
Original file line number Diff line number Diff line change
@@ -1,173 +1,7 @@
// The project function defines how your document looks.
// It takes your content and some metadata and formats it.
// Go ahead and customize it to your liking!
#let project(title: "", authors: (), body) = {
// Set the document's basic properties.

let style_color = rgb("#ffffff")
set document(author: authors, title: title)
set page(
numbering: none,
number-align: center,
height: auto,
background: rect(fill: rgb("#343541"), height: 100%, width: 100%),
)
set text(font: "Linux Libertine", lang: "en", fill: style_color)

// math setting
show math.equation: set text(weight: 400)
// let style_color = rgb("#ffffff")
// background: rect(fill: rgb("#343541"), height: 100%, width: 100%),

// code block setting
show raw: it => {
if it.block {
rect(
width: 100%,
inset: (x: 4pt, y: 5pt),
radius: 4pt,
fill: rgb(239, 241, 243),
[
#set text(fill: rgb("#000000"))
#place(right, text(luma(110), it.lang))
#it
],
)
} else {
it
}
}

// Main body.
set par(justify: true)

body
}

#show: project

Typst.ts allows you to independently run the Typst compiler and exporter (renderer) in your browser.

You can:

- locally run the compilation via `typst-ts-cli` to get a precompiled document,
- or use `reflexo-typst` to build your backend programmatically.
- build your frontend using the lightweight TypeScript library `typst.ts`.
- send the precompiled document to your readers' browsers and render it as HTML elements.

The Typst.ts application is designed to be fast due to the following reasons:

- Precompiled documents are much smaller than their PDF equivalents.
- For example, a compressed precompiled document is only 35KB while its corresponding PDF is 342KB.
- The renderer has a small code size.
- Typst itself has great performance.

== CLI

Run Compiler Example:

```bash
typst-ts-cli compile --workspace "fuzzers/corpora/math" --entry "fuzzers/corpora/math/main.typ"
```

Help:

```bash
$ typst-ts-cli --help
The cli for typst.ts.
Usage: typst-ts-cli [OPTIONS] [COMMAND]
Commands:
compile Run compiler. [aliases: c]
env Dump Client Environment.
font Commands about font for typst.
help Print this message or the help of the given subcommand(s)
Options:
-V, --version Print Version
--VV <VV> Print Version in format [default: none] [possible values: none, short, full, json, json-plain]
-h, --help Print help
```

Compile Help:

```bash
$ typst-ts-cli compile --help
Run compiler.
Usage: typst-ts-cli compile [OPTIONS] --entry <ENTRY>
Options:
-h, --help Print help
Compile options:
-w, --workspace <WORKSPACE> Path to typst workspace [default: .]
--watch watch mode
--trace <TRACE> enable tracing. possible usage: --trace=verbosity={0..3} where verbosity: {0..3} -> {warning, info, debug, trace}
-e, --entry <ENTRY> Entry file
--format <FORMAT> Output formats, possible values: `json`, `pdf`, `ast`, and `rmp`
-o, --output <OUTPUT> Output to directory, default in the same directory as the entry file [default: ]
--font-path <DIR> Add additional directories to search for fonts
```

== Renderer Example

```shell
# install simple-http-server or other alternative solutions
$ cargo install simple-http-server
$ simple-http-server -p 20810 --cors ./fuzzers/corpora/
$ simple-http-server -p 20811 --cors ./assets/ --compress=ttf,otf
$ cd packages/typst.ts && yarn install && yarn run build && simple-http-server -p 8075 --index --compress=js,json,otf,css,wasm --coep --coop
```

And open your browser to `http://localhost:8075`.

== Precompiler

The compiler is capable of producing artifact outputs from a Typst project. Thet artifact outputs can be easily distributed to remote endpoints.

== Renderer

The renderer accepts an input in artifact format and renders the document as HTML elements.

Import Typst.ts in your project:

- Using #link("https://www.npmjs.com/package/@myriaddreamin/typst.ts")[\@myriaddreamin/typst.ts]

```javascript
import { createTypstRenderer } from '@myriaddreamin/typst.ts';
const renderer = createTypstRenderer();
```

- Using #link("https://www.npmjs.com/package/@myriaddreamin/typst.react")[\@myriaddreamin/typst.react]

```javascript
import { TypstDocument } from '@myriaddreamin/typst.react';
export const App = (artifact: string) => {
return (
<div>
<h1>Demo: Embed Your Typst Document in React</h1>
<TypstDocument fill="#343541" artifact={artifact} />
</div>
);
};
```

- Using #link("https://www.npmjs.com/package/@myriaddreamin/typst.angular")[\@myriaddreamin/typst.angular]

In the module file of your awesome component.

```javascript
/// component.module.ts
import { TypstDocumentModule } from '@myriaddreamin/typst.angular';
```

Using directive `typst-document` in your template file.

```html
<typst-document fill="#343541" artifact="{{ artifact }}"></typst-document>
```

- Using #link("https://www.npmjs.com/package/@myriaddreamin/typst.vue3")[\@myriaddreamin/typst.vue3]

Coming soon.
#include "../../docs/cookery/introduction.typ"
+ #link("https://myriad-dreamin.github.io/typst.ts/cookery/introduction.html")[Full Documentation]

0 comments on commit cd21af9

Please sign in to comment.