-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.typ
77 lines (59 loc) · 2.52 KB
/
test.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#show link: set text(fill: rgb(150, 50, 100))
#let title = [Typst-preview.el: live preview of typst documents!]
#align(center, text(17pt)[
*#title*
])
// This is an old version of README.md!
Live preview of typst files inside emacs! Building on #link("https://github.com/Enter-tainer/typst-preview")[typst-preview], which was originally written for VS Code, and also inspired by #link("https://github.com/chomosuke/typst-preview.nvim")[typst-preview.nvim].
#align(center+horizon)[
#box(width: 5cm,
[#align(center)[*Features*:]
#align(left)[
- Live preview of edits
- Source to preview jumping
- Preview to source jumping]]
)]
= Installation
== MELPA
Currently not on Melpa.
== Manual installation
Install the typst-preview binary from
#link("https://github.com/Enter-tainer/typst-preview/releases")[typst-preview]
and make sure it's in your `$PATH`. To test this, create test.typ and run
```bash
typst-preview test.typ
``` //
Then put `typst-preview.el` in your load-path, and put this in your init file:
```lisp
(require 'typst-preview)
```
Or, if you use `use-package`, try:
```lisp
(use-package websocket)
(use-package typst-preview
:straight nil ; if you use straight
:load-path "path-to-typst-preview.el")
```
= Usage & configuration
== Basic usage
Inside a .typ-file, run `M-x typst-preview-mode`. This will start a preview in your default browser, and connect the source buffer to the server, sending live updates.
Start, stop and restart ~typst-preview~ using ~M-x typst-preview-start~, ~M-x typst-preview-stop~ and ~M-x typst-preview-restart~.
Jumping from source to preview: `M-x typst-preview-send-position`.
This only works in text (i.e. not in a code block or in math mode) because of how the typst compiler works. See #link("https://github.com/Enter-tainer/typst-preview/issues/182")
== Change default browser
To preview the .typ file in a non-default browser:
```lisp
(setq typst-preview-browser "safari")
```
To preview the .typ file using `xwidget`, provided your emacs is built with `xwidget`-support:
```lisp
(setq typst-preview-browser "xwidget")
```
== Details:
Enabling `typst-preview-mode` runs `typst-preview-start`, which does a few things:
- Starts `typst-preview` on the current file, sending results to the buffer `*ws-typst-server*`.
- Connects to the `typst-preview` server using `websocket`
- Opens a browser pointing at the address of the preview
- Adds a hook to `after-change-functions` which sends the buffer to the server at each keystroke.
== Including files:
#include("test-include.typ")