📝 Memo: Editing typst.app/docs

Foreword
This is an informal memo on editing typst.app/docs.
The background was explained in How about a task force to generate a better documentation? by evandrojrsilva and others.

This is a wiki post licensed under Apache 2.0. You can edit it and leave your name in the signature area below. (Unfortunately, this is not a real wiki. You have to sign your name manually.)

How are docs organized

Special markups

Links

Not sure if your $-link is correct? Submit a PR first, and the CI will panic if it’s wrong. (It won’t check the hash anchor, though.)

Examples

The width of the page.
```example
#set page(
  width: 5cm,
  margin: (x: 1cm),
)
#for i in range(3) {
  box(square(width: 1cm))
}

>>> Glacier displacement is influenced
>>> by a number of factors, including
>>> + The climate
>>> + The topography
>>> + The geology
<<< ...
```

The above will turn into:

The width of the page.

#set page(
  width: 5cm,
  margin: (x: 1cm),
)
#for i in range(3) {
  box(square(width: 1cm))
}

...

You can use four backticks (````example … ````) if your example contains ```.

Preamble:

#set page(height: auto, width: 240pt, margin: 15pt)

Examples can have multiple pages. The block.height parameter has an instance.

Available fonts: typst-dev-assets/files/fonts at main · typst/typst-dev-assets · GitHub.

Criteria for adding examples, quoting Laurenz Mädje:

It’s important that examples don’t just demonstrate something, but are also visually appealing.
Also, examples should lean toward being “more practically useful rather than theoretically pristine”.

Examples—language tag

In 90% cases, you’ll use example. Nevertheless, there’re other choices.

  • example — show both source and preview
  • preview — show preview (without source)
  • typ, sh, bash, csv, …, or empty — show source (without preview)

Additionally, args can be specified after a colon:

  • example:"Example title" (for v0.14, not released yet)

    If there’re multiple examples, they can be disambiguated with (optional) titles.

  • example:single

    Keep only the first page, useful if you override set page(height: auto) with an absolute length.

  • example:⟨xâź©,⟨yâź©,⟨wâź©,⟨hâź©, e.g., example:0,0,612,317.5

    Keep only the first page and clip it. Lengths are in pt (points).

Highlighting

Plain inline raw created with `backticks` will be colorless.
In addition:

  • Use `{…}` to highlight in code mode, e.g., `{none}` and `{auto}`.
  • Use `[…]` to highlight in markup mode, e.g., `[Hello #[<label>]]` and `[\u{1f600}]`.

Heading

Headings converted to kebab case will be used as their IDs.

If you want to set an ID explicitly, append { #id } to the heading:

## How to create a basic table? { #basic-tables }

If you do so, then the ID (converted to title case) will also be used in the outline (the on this page sidebar).

Quirks

Paragraphs after a list

- A
- B

Please insert a newline after the list, because otherwise the sentence will belong to the last list item.

Footnotes

Footnotes definitions should be moved to the end of the doc comment. Otherwise, it’ll appear in the middle of the document.
See detailed specifications - pulldown-cmark.

Style Guide

Wrap lines at column 80. You could write the following in your .vscode/settings.json.

{
    "editor.rulers": [80]
}

Notes on rust-analyzer

You could turn off rust-analyzer.checkOnSave or even disable the whole rust-analyzer extension when editing docs.

Running cargo check in the repo typically takes ~800 MiB space.
(not counting cargo doc, cargo testit, cargo build -r, cargo build, etc.)

Signature Area

What's this?

This is a wiki post. After editing, you can leave your name below.

They will turn into the Co-authored-by field in the commit’s message, if I submit it to typst/docs/dev at main · typst/typst · GitHub in the future. (It may also remain in this form forever or be submitted by someone else, however.)

If you don’t know what Co-authored-by is, just write down your name or put a link to your Forum/GitHub profile.

9 Likes

That’s a good list! To add: Just like {auto} does code highlighting, you can do content highlighting with [*strong*].

1 Like

The forum guideline claims that all posts on the forum are licensed under CC BY 4.0, and no exception is mentioned.

I declared the wiki post above to be licensed under Apache 2.0, in order to reserve the possibility of future submissions to the git repo. I guess that’s okay?

Ideally the post would be available under both licenses.

1 Like

Apart from one edit by @Andrew you’re currently the author, so you can of course license the text under Apache in addition to CC-BY. I think you could (with Andrew’s approval) edit the foreword to point out that “by editing, you agree to dual-licensing under Apache and CC-BY” or something like that, similar to what you’d find on a repo.

As long as the Typst team has no problem with that happening on their forum, I think that should be a clean solution.

1 Like