« Home

Guide [guide-0000]

This guide explains how to use this project and what is expected behaviour.

Setup [guide-0001]

Steps to setup the project:

  1. Run raco pkg install --auto tr in the project
  2. Creates a directory mkdir your-site and goes into it
  3. Run raco tr init then update site.rkt (check Shell Commands for more CLI interaction)

raco tr init do the following

  1. Create .gitignore with
    _tmp/
    _build/
    assets/
  2. Create site.rkt with
    #lang racket/base
    (require scribble/html)
    (provide site)
    
    (define site
      (hash 'domain "your domain"
            'title "your site title"
            'description "your site description"
            'head (list)))
  3. git clone https://codeberg.org/dannypsnl/tr-assets.git assets

  4. Create directory content and content/post

  5. git init

Now you can add some *.scrbl in content/ directory as you wanted. Each *.scrbl is called a card.

Directory content/post is treated specially in that RSS only use cards in this directory as items.

A card addr.scrbl (no matter its full path) has an address addr, and the address must be unique in the whole TR project.

The content of card mostly are just HTML in at-exp form, scribble HTML describes more about what can be used.

Further guide will teach you what's in the toolbox.

Configuration [guide-0009]

The configuration is a Racket module site.rkt that (provide site) a hash. By default tr reads site.rkt; some commands let you point at a different file (read the CLI --help result to learn).

#lang racket/base
(require scribble/html)
(provide site)

(define site
  (hash 'domain "your domain"
        'title "your site title"
        'description "your site description"
        'head (list)))

Because the config is code, values can be computed and shared. For example a release config can reuse the dev one and override only the environment-specific keys, so identity such as head stays in one place:

#lang racket/base
(require (only-in "site.rkt" [site dev-site]))
(provide site)

(define site
  (hash-set* dev-site
             'mode "release"
             'output-path "_release"))

Optional options are

  1. 'output-path, default value is "_build", where tr build command produces files for publish. You can run

    python3 -m http.server -d _build

    to view result, or upload it to host.

  2. 'mode, default value is "release". When the value of 'mode is "dev", TR produces sourcemap.json in the output path, that enables Meta/Ctrl + E to edit the current page.

  3. 'head, a list of scribble HTML elements injected into the of every page. Use it for identity and metadata links, e.g.

    'head (list
            (link 'rel: "me" 'href: "https://mastodon.social/@you")
            (meta 'name: "fediverse:creator" 'content: "@you@mastodon.social")
            (link 'rel: "webmention" 'href: "https://webmention.io/you/webmention"))

    The rel="me" link lets a fediverse profile verify your site; the fediverse:creator meta attributes shared links to you.

Metadata [guide-0002]

There are several metadata can be set to a card, list as below:

  1. @taxon{...} it accepts a text
  2. @title{...} it accepts a list of forms
  3. @author{...} it only accepts a card address
  4. @author/literal{...} it accepts a text
  5. @date{...} it accepts a text, but I suggest in yyyy/mm/dd format
  6. @doi{...} it accepts a DOI format like 10.1145/3571239
  7. @orcid{...} it accepts a ORCID format text
  8. @meta/text{...} it accepts arbitrary text as metadata
  9. @meta/link{...} it accepts a link
  10. @toc/depth[n] it accepts an integer, which is the depth of generated TOC, the default value is 2

Example. A Regular card [guide-0008]

Here I made an example to show what will actually be put in your *.scrbl file.

@date{2025-07-05}
@taxon{Example}
@title{A card}
@author{people-addr}

@p{Hello, brabrabra...}

Link to other cards [guide-0003]

You can use @mention{addr} to mention a card, it will tell addr it has a backlinks, e.g. I can mention the guide itself Guide. If the mentioned card has taxon Reference, it will not be a related card, but a references card, let me mention a cool book as an example 10 PRINT CHR$(205.5+RND(1)); : GOTO 10.

You can use @transclude{addr} to include a card, it will tell addr it has a context. This guide itself is an example of transclude.

Embed external web page

Since you can use any HTML, iframe for sure is counted, you can embed external web page, e.g.

Math Support [guide-0004]

tr use KaTeX\color{#329894}\KaTeX in two forms: @m{...} and @mm{...}. One for inline and one for block, e.g.

  • @m{a \in \R} produces aRa \in \R
  • @mm{ \int_{a}^{b} x^2 \,dx } produces abx2dx \int_{a}^{b} x^2 \,dx

Except KaTeX\color{#329894}\KaTeX, tr also supports backend LaTeX\color{#008080}\LaTeX solution, you can put tikz program in @tikzcd{...} block to draw quiver, for example

figure tex4704

Or @texfig{...} for more flexible input (anything allowed in LaTeX\color{#008080}\LaTeX document block). For example

@texfig{
...
}

If you want to use packages, write as below (the change is introduced since texfig now must manually assigns LaTeX header part)

@texfig[#:header @"
\\usepackage{tikz}
\\usetikzlibrary{spath3, intersections, backgrounds}
"]{
...
}

We support @typst{...} which use Typst\color{#239dad}\text{Typst} as backend, check Typst backend for more information.

Immediate card [guide-000A]

We are not always want to create a new file for a card, especially when it's more like a subsection of the current article. You can use tr/card in this situation, check tr/card for more details.

Support Code in Card [guide-0007]

You can write @tr/code{...} to extend card, for example

@tr/code{#lang racket
(provide (all-defined-out))

(define RR "\\mathbb{R}")
}

then you can use @m{@RR} to get R\mathbb{R}. Check tr/code for more details.

Shell Commands [guide-0005]

If you face error like raco tr cannot find such command, run raco setup.

  1. Run raco tr build to build HTMLs
  2. Run raco tr watch to watch content changes and build on fly
  3. Run raco tr next to get next available address, for example, you might like to run
    vi $(raco tr next xxx).scrbl
    to work on a new file (replace vi with any command line editor command)
  4. Run raco tr meta to get metadata of address, I recommend you use | jq . after the command to get pretty output.

Special form [guide-0006]

There are some special forms for certain purpose

  1. @bibtex[...] it accepts a string that is bibtex format