diff --git a/sources/CONTRIBUTING.md b/sources/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..33c5343c5ccb810f10cd0b96bbaf87a61455b2bd --- /dev/null +++ b/sources/CONTRIBUTING.md @@ -0,0 +1,73 @@ +# Contributing to Typst +Thank you for considering to contribute to Typst. We want to foster a welcoming +and productive atmosphere for contributors. Therefore, we outline a few steps to +land your contribution below. + +1. Before starting significant work on a feature or refactoring, please + find/open an [issue] or start a thread in the [#contributors] channel on + Discord to discuss the design. Feel also free to ping a maintainer/team + member to get some input on your idea. Don't be shy! Typst is a complex + project with a long-term vision and it's frustrating to find out that your + idea does not align with that vision _after_ you have already implemented + something. +2. Fork the Typst repository and start with your contribution. If you, at any + point in this process, are unsure about how to do something in the Typst + codebase, reach out to a maintainer or a more experienced contributor. Also + have a look at the [`architecture.md`][architecture] file. It explains how + the compiler works. +3. Create a pull request (PR) in the Typst repository, outlining your + contribution, the technical rationale behind it, and, if it includes a new + feature, how users will use it. Best to link to an existing issue with this + information here. +4. When you send a PR, automated CI checks will run. Your PR can only be merged + if CI passes and will often also only get its first review round once it has + the green checkmark. You can ping a maintainer if you need guidance with + failing CI (or anything else). +5. A maintainer will review your PR. In this review, we check code quality, + bugs, and whether the contribution aligns with what was previously discussed. + If you think that a review comment misses something or is not quite right, + please challenge it! +6. If the review passes, your PR will be merged and ship in the next version of + Typst. You will appear as one of the contributors in the [changelog]. + Thank you! + +Below are some signs of a good PR: +- Implements a single, self-contained feature or bugfix that has been discussed + previously. +- Adds/changes as little code and as few interfaces as possible. Should changes + to larger-scale abstractions be necessary, these should be discussed + throughout the implementation process. +- Adds tests if appropriate (with reference output for visual/HTML tests). See + the [testing] readme for more details. +- Contains documentation comments on all new Rust types. +- Comes with brief documentation for all new Typst definitions + (elements/functions), ideally with a concise example that fits into ~5-10 + lines with <38 columns (check out existing examples for inspiration). This + part is not too critical, as we will touch up the documentation before making + a release. + +Sometimes, a contributor can become unresponsive during a review process. This +is okay! We will, however, close PRs on which we are waiting for a contributor +response after an extended period of time to avoid filling up the PR tracker +with many stale PRs. In the same way, it may take a while for us to find time to +review your PR. If there is no response after a longer while (1-2 weeks), feel +free to ping us, as we may have missed it. + +While Typst is an open-source project, it is also the product of a startup. We +always judge technical contributions to the project based on their technical +merits. However, as a company, our immediate priorities can and do change often +and sometimes without prior notice. This affects the design and decision making +process as well as the development and review velocity. Some proposals may also +have direct impact on our viability as a company, in which case we carefully +consider them from the business perspective. + +If you are unsure whether your idea is a good fit for this project, please +discuss it with us! The core question is "Does this help to make Typst the prime +technical typesetting app?". If the answer is yes, your idea is likely right for +Typst! + +[issue]: https://github.com/typst/typst/issues +[testing]: https://github.com/typst/typst/blob/main/tests/README.md +[#contributors]: https://discord.com/channels/1054443721975922748/1088371867913572452 +[architecture]: https://github.com/typst/typst/blob/main/docs/dev/architecture.md +[changelog]: https://typst.app/docs/changelog/ diff --git a/sources/README.md b/sources/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9526f3df480c5845cd98f5948c93293d134cfba4 --- /dev/null +++ b/sources/README.md @@ -0,0 +1,261 @@ +

+ Typst +

+ +

+ + Documentation + + Typst App + + Discord Server + + Apache-2 License + + Jobs at Typst +

+ +Typst is a new markup-based typesetting system that is designed to be as powerful +as LaTeX while being much easier to learn and use. Typst has: + +- Built-in markup for the most common formatting tasks +- Flexible functions for everything else +- A tightly integrated scripting system +- Math typesetting, bibliography management, and more +- Fast compile times thanks to incremental compilation +- Friendly error messages in case something goes wrong + +This repository contains the Typst compiler and its CLI, which is everything you +need to compile Typst documents locally. For the best writing experience, +consider signing up to our [collaborative online editor][app] for free. + +## Example +A [gentle introduction][tutorial] to Typst is available in our documentation. +However, if you want to see the power of Typst encapsulated in one image, here +it is: +

+ Example +

+ + +Let's dissect what's going on: + +- We use _set rules_ to configure element properties like the size of pages or + the numbering of headings. By setting the page height to `auto`, it scales to + fit the content. Set rules accommodate the most common configurations. If you + need full control, you can also use [show rules][show] to completely redefine + the appearance of an element. + +- We insert a heading with the `= Heading` syntax. One equals sign creates a top + level heading, two create a subheading and so on. Typst has more lightweight + markup like this, see the [syntax] reference for a full list. + +- [Mathematical equations][math] are enclosed in dollar signs. By adding extra + spaces around the contents of an equation, we can put it into a separate block. + Multi-letter identifiers are interpreted as Typst definitions and functions + unless put into quotes. This way, we don't need backslashes for things like + `floor` and `sqrt`. And `phi.alt` applies the `alt` modifier to the `phi` to + select a particular symbol variant. + +- Now, we get to some [scripting]. To input code into a Typst document, we can + write a hash followed by an expression. We define two variables and a + recursive function to compute the n-th fibonacci number. Then, we display the + results in a center-aligned table. The table function takes its cells + row-by-row. Therefore, we first pass the formulas `$F_1$` to `$F_8$` and then + the computed fibonacci numbers. We apply the spreading operator (`..`) to both + because they are arrays and we want to pass the arrays' items as individual + arguments. + +
+ Text version of the code example. + + ```typst + #set page(width: 10cm, height: auto) + #set heading(numbering: "1.") + + = Fibonacci sequence + The Fibonacci sequence is defined through the + recurrence relation $F_n = F_(n-1) + F_(n-2)$. + It can also be expressed in _closed form:_ + + $ F_n = round(1 / sqrt(5) phi.alt^n), quad + phi.alt = (1 + sqrt(5)) / 2 $ + + #let count = 8 + #let nums = range(1, count + 1) + #let fib(n) = ( + if n <= 2 { 1 } + else { fib(n - 1) + fib(n - 2) } + ) + + The first #count numbers of the sequence are: + + #align(center, table( + columns: count, + ..nums.map(n => $F_#n$), + ..nums.map(n => str(fib(n))), + )) + ``` +
+ +## Installation +Typst's CLI is available from different sources: + +- You can get sources and pre-built binaries for the latest release of Typst + from the [releases page][releases]. Download the archive for your platform and + place it in a directory that is in your `PATH`. To stay up to date with future + releases, you can simply run `typst update`. + +- You can install Typst through different package managers. Note that the + versions in the package managers might lag behind the latest release. + - Linux: + - View [Typst on Repology][repology] + - View [Typst's Snap][snap] + - macOS: `brew install typst` + - Windows: `winget install --id Typst.Typst` + +- If you have a [Rust][rust] toolchain installed, you can install + - the latest released Typst version with + `cargo install --locked typst-cli` + - a development version with + `cargo install --git https://github.com/typst/typst --locked typst-cli` + +- Nix users can + - use the `typst` package with `nix-shell -p typst` + - build and run a development version with + `nix run github:typst/typst -- --version`. + +- Docker users can run a prebuilt image with + `docker run ghcr.io/typst/typst:latest --help`. + +## Usage +Once you have installed Typst, you can use it like this: +```sh +# Creates `file.pdf` in working directory. +typst compile file.typ + +# Creates PDF file at the desired path. +typst compile path/to/source.typ path/to/output.pdf +``` + +You can also watch source files and automatically recompile on changes. This is +faster than compiling from scratch each time because Typst has incremental +compilation. +```sh +# Watches source files and recompiles on changes. +typst watch file.typ +``` + +Typst further allows you to add custom font paths for your project and list all +of the fonts it discovered: +```sh +# Adds additional directories to search for fonts. +typst compile --font-path path/to/fonts file.typ + +# Lists all of the discovered fonts in the system and the given directory. +typst fonts --font-path path/to/fonts + +# Or via environment variable (Linux syntax). +TYPST_FONT_PATHS=path/to/fonts typst fonts +``` + +For other CLI subcommands and options, see below: +```sh +# Prints available subcommands and options. +typst help + +# Prints detailed usage of a subcommand. +typst help watch +``` + +If you prefer an integrated IDE-like experience with autocompletion and instant +preview, you can also check out [Typst's free web app][app]. + +## Community +The main places where the community gathers are our [Forum][forum] and our +[Discord server][discord]. The Forum is a great place to ask questions, help +others, and share cool things you created with Typst. The Discord server is more +suitable for quicker questions, discussions about contributing, or just to chat. +We'd be happy to see you there! + +[Typst Universe][universe] is where the community shares templates and packages. +If you want to share your own creations, you can submit them to our +[package repository][packages]. + +If you had a bad experience in our community, please [reach out to us][contact]. + +## Contributing +We love to see contributions from the community. If you experience bugs, feel +free to open an issue. If you would like to implement a new feature or bug fix, +please follow the steps outlined in the [contribution guide][contributing]. + +To build Typst yourself, first ensure that you have the +[latest stable Rust][rust] installed. Then, clone this repository and build the +CLI with the following commands: + +```sh +git clone https://github.com/typst/typst +cd typst +cargo build --release +``` + +The optimized binary will be stored in `target/release/`. + +Another good way to contribute is by [sharing packages][packages] with the +community. + +## Pronunciation and Spelling +IPA: /taɪpst/. "Ty" like in **Ty**pesetting and "pst" like in Hi**pst**er. When +writing about Typst, capitalize its name as a proper noun, with a capital "T". + +## Design Principles +All of Typst has been designed with three key goals in mind: Power, +simplicity, and performance. We think it's time for a system that matches the +power of LaTeX, is easy to learn and use, all while being fast enough to realize +instant preview. To achieve these goals, we follow three core design principles: + +- **Simplicity through Consistency:** + If you know how to do one thing in Typst, you should be able to transfer that + knowledge to other things. If there are multiple ways to do the same thing, + one of them should be at a different level of abstraction than the other. E.g. + it's okay that `= Introduction` and `#heading[Introduction]` do the same thing + because the former is just syntax sugar for the latter. + +- **Power through Composability:** + There are two ways to make something flexible: Have a knob for everything or + have a few knobs that you can combine in many ways. Typst is designed with the + second way in mind. We provide systems that you can compose in ways we've + never even thought of. TeX is also in the second category, but it's a bit + low-level and therefore people use LaTeX instead. But there, we don't really + have that much composability. Instead, there's a package for everything + (`\usepackage{knob}`). + +- **Performance through Incrementality:** + All Typst language features must accommodate for incremental compilation. + Luckily we have [`comemo`], a system for incremental compilation which does + most of the hard work in the background. + +[docs]: https://typst.app/docs/ +[app]: https://typst.app/ +[discord]: https://discord.gg/2uDybryKPe +[forum]: https://forum.typst.app/ +[universe]: https://typst.app/universe/ +[tutorial]: https://typst.app/docs/tutorial/ +[show]: https://typst.app/docs/reference/styling/#show-rules +[math]: https://typst.app/docs/reference/math/ +[syntax]: https://typst.app/docs/reference/syntax/ +[scripting]: https://typst.app/docs/reference/scripting/ +[rust]: https://rustup.rs/ +[releases]: https://github.com/typst/typst/releases/ +[repology]: https://repology.org/project/typst/versions +[contact]: https://typst.app/contact +[architecture]: https://github.com/typst/typst/blob/main/docs/dev/architecture.md +[contributing]: https://github.com/typst/typst/blob/main/CONTRIBUTING.md +[packages]: https://github.com/typst/packages/ +[`comemo`]: https://github.com/typst/comemo/ +[snap]: https://snapcraft.io/typst diff --git a/sources/crates/typst-syntax/README.md b/sources/crates/typst-syntax/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ced4096ef6cb314590fca3193d6d59c1ccd6bcda --- /dev/null +++ b/sources/crates/typst-syntax/README.md @@ -0,0 +1,40 @@ +# typst-syntax + +Welcome to the Typst Syntax crate! This crate manages the syntactical structure +of Typst by holding some core abstractions like assigning source file ids, +parsing Typst syntax, creating an Abstract Syntax Tree (AST), initializing +source "spans" (for linking AST elements to their outputs in a document), and +syntax highlighting. + +Below are quick descriptions of the files you might be editing if you find +yourself here :) + +- `lexer.rs`: The lexical foundation of the parser, which converts a string of + characters into tokens. +- `parser.rs`: The main parser definition, preparing a Concrete Syntax Tree made + of nested vectors of `SyntaxNode`s. +- `reparser.rs`: The algorithm for reparsing the minimal required amount of + source text for efficient incremental compilation. +- `ast.rs`: The conversion layer between the Concrete Syntax Tree of the parser + and the Abstract Syntax Tree used for code evaluation. +- `node.rs` & `span.rs`: The underlying data structure for the Concrete Syntax + Tree and the definitions of source spans used for efficiently pointing to a + syntax node in things like diagnostics. +- `kind.rs` & `set.rs`: An enum with all syntactical tokens and nodes and + bit-set data structure for sets of `SyntaxKind`s. +- `highlight.rs`: Extracting of syntax highlighting information out of the + Concrete Syntax Tree (and outputting as HTML). +- `path.rs`, `file.rs`, `package.rs`: The system for interning project and + package paths as unique file IDs and resolving them in a virtual filesystem + (not actually for _opening_ files). + +The structure of the parser is largely adapted from Rust Analyzer. Their +[documentation][ra] is a good reference for a number of the design decisions +around the parser and AST. + +The reparsing algorithm is explained in Section 4 of [Martin's thesis][thesis] +(though it changed a bit since). + +[ra]: https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/syntax.md +[thesis]: + https://www.researchgate.net/publication/364622490_Fast_Typesetting_with_Incremental_Compilation diff --git a/sources/docs/changelog/0.1.0.md b/sources/docs/changelog/0.1.0.md new file mode 100644 index 0000000000000000000000000000000000000000..396390e1d7941ae8c5386df8730678e5e50e8033 --- /dev/null +++ b/sources/docs/changelog/0.1.0.md @@ -0,0 +1,73 @@ +--- +title: 0.1.0 +description: Changes in Typst 0.1.0 +--- + +# Version 0.1.0 (April 04, 2023) + +## Breaking changes +- When using the CLI, you now have to use subcommands: + - `typst compile file.typ` or `typst c file.typ` to create a PDF + - `typst watch file.typ` or `typst w file.typ` to compile and watch + - `typst fonts` to list all fonts +- Manual counters now start at zero. Read the "How to step" section + [here]($counter) for more details +- The [bibliography styles]($bibliography.style) `{"author-date"}` and + `{"author-title"}` were renamed to `{"chicago-author-date"}` and + `{"chicago-author-title"}` + +## Figure improvements +- Figures now automatically detect their content and adapt their behavior. + Figures containing tables, for instance, are automatically prefixed with + "Table X" and have a separate counter +- The figure's supplement (e.g. "Figure" or "Table") can now be customized +- In addition, figures can now be completely customized because the show rule + gives access to the automatically resolved kind, supplement, and counter + +## Bibliography improvements +- The [`bibliography`] now also accepts multiple bibliography paths (as an + array) +- Parsing of BibLaTeX files is now more permissive (accepts non-numeric edition, + pages, volumes, dates, and Jabref-style comments; fixed abbreviation parsing) +- Labels and references can now include `:` and `.` except at the end +- Fixed APA bibliography ordering + +## Drawing additions +- Added [`polygon`] function for drawing polygons +- Added support for clipping in [boxes]($box.clip) and [blocks]($block.clip) + +## Command line interface +- Now returns with non-zero status code if there is an error +- Now watches the root directory instead of the current one +- Now puts the PDF file next to input file by default +- Now accepts more kinds of input files (e.g. `/dev/stdin`) +- Added `--open` flag to directly open the PDF + +## Miscellaneous improvements +- Added [`yaml`] function to load data from YAML files +- Added basic i18n for a few more languages (IT, RU, ZH, FR, PT) +- Added numbering support for Hebrew +- Added support for [integers]($int) with base 2, 8, and 16 +- Added symbols for double bracket and laplace operator +- The [`link`] function now accepts [labels]($label) +- The link syntax now allows more characters +- Improved justification of Japanese and Chinese text +- Calculation functions behave more consistently w.r.t to non-real results +- Replaced deprecated angle brackets +- Reduced maximum function call depth from 256 to 64 +- Fixed [`first-line-indent`]($par.first-line-indent) being not applied when a + paragraph starts with styled text +- Fixed extraneous spacing in unary operators in equations +- Fixed block spacing, e.g. in `{block(above: 1cm, below: 1cm, ..)}` +- Fixed styling of text operators in math +- Fixed invalid parsing of language tag in raw block with a single backtick +- Fixed bugs with displaying counters and state +- Fixed crash related to page counter +- Fixed crash when [`symbol`] function was called without arguments +- Fixed crash in bibliography generation +- Fixed access to label of certain content elements +- Fixed line number in error message for CSV parsing +- Fixed invalid autocompletion after certain markup elements + +## Contributors + diff --git a/sources/docs/changelog/0.10.0.md b/sources/docs/changelog/0.10.0.md new file mode 100644 index 0000000000000000000000000000000000000000..5a2a3dea3081db2f9947c89c363aba218b83a8be --- /dev/null +++ b/sources/docs/changelog/0.10.0.md @@ -0,0 +1,130 @@ +--- +title: 0.10.0 +description: Changes in Typst 0.10.0 +--- + +# Version 0.10.0 (December 4, 2023) + +## Bibliography management +- Added support for citation collapsing (e.g. `[[1]-[3]]` instead of + `[[1], [2], [3]]`) if requested by a CSL style +- Fixed bug where an additional space would appear after a group of citations +- Fixed link show rules for links in the bibliography +- Fixed show-set rules on citations +- Fixed bibliography-related crashes that happened on some systems +- Corrected name of the GB/T 7714 family of styles from 7114 to 7714 +- Fixed missing title in some bibliography styles +- Fixed printing of volumes in some styles +- Fixed delimiter order for contributors in some styles (e.g. APA) +- Fixed behavior of alphanumeric style +- Fixed multiple bugs with GB/T 7714 style +- Fixed escaping in Hayagriva values +- Fixed crashes with empty dates in Hayagriva files +- Fixed bug with spacing around math blocks +- Fixed title case formatting after verbatim text and apostrophes +- Page ranges in `.bib` files can now be arbitrary strings +- Multi-line values in `.bib` files are now parsed correctly +- Entry keys in `.bib` files now allow more characters +- Fixed error message for empty dates in `.bib` files +- Added support for years of lengths other than 4 without leading zeros in + `.bib` files +- More LaTeX commands (e.g. for quotes) are now respected in `.bib` files + +## Visualization +- Added support for [patterns]($tiling) as fills and strokes +- The `alpha` parameter of the [`components`]($color.components) function on + colors is now a named parameter **(Breaking change)** +- Added support for the [Oklch]($color.oklch) color space +- Improved conversions between colors in different color spaces +- Removed restrictions on [Oklab]($color.oklab) chroma component +- Fixed [clipping]($block.clip) on blocks and boxes without a stroke +- Fixed bug with [gradients]($gradient) on math +- Fixed bug with gradient rotation on text +- Fixed bug with gradient colors in PDF +- Fixed relative base of Oklab chroma ratios +- Fixed Oklab color negation + +## Text and Layout +- CJK text can now be emphasized with the `*` and `_` syntax even when there are + no spaces +- Added basic i18n for Greek and Estonian +- Improved default [figure caption separator]($figure.caption.separator) for + Chinese, French, and Russian +- Changed default [figure supplement]($figure.supplement) for Russian to short + form +- Fixed [CJK-Latin-spacing]($text.cjk-latin-spacing) before line breaks and in + [`locate`] calls +- Fixed line breaking at the end of links + +## Math +- Added [`mid`]($math.mid) function for scaling a delimiter up to the height of + the surrounding [`lr`]($math.lr) group +- The [`op`]($math.op) function can now take any content, not just strings +- Improved documentation for [math alignment]($category/math/#alignment) +- Fixed swallowing of trailing comma when a symbol is used in a function-like + way (e.g. `pi(a,b,)`) + +## Scripting +- Any non-identifier dictionary key is now interpreted as an expression: For + instance, `{((key): value)}` will create a dictionary with a dynamic key +- The [`stroke`] type now has a constructor that converts a value to a stroke or + creates one from its parts +- Added constructor for [`arguments`] type +- Added [`calc.div-euclid`]($calc.div-euclid) and + [`calc.rem-euclid`]($calc.rem-euclid) functions +- Fixed equality of [`arguments`] +- Fixed [`repr`]of [`cmyk`]($color.cmyk) colors +- Fixed crashes with provided elements like figure captions, outline entries, + and footnote entries + +## Tooling and Diagnostics +- Show rules that match on their own output now produce an appropriate error + message instead of a crash (this is a first step, in the future they will just + work) +- Too highly or infinitely nested layouts now produce error messages instead of + crashes +- Added hints for invalid identifiers +- Added hint when trying to use a manually constructed footnote or outline entry +- Added missing details to autocompletions for types +- Improved error message when passing a named argument where a positional one is + expected +- Jump from click now works on raw blocks + +## Export +- PDF compilation output is now again fully byte-by-byte reproducible if the + document's [`date`]($document.date) is set manually +- Fixed color export in SVG +- Fixed PDF metadata encoding of multiple [authors]($document.author) + +## Command line interface +- Fixed a major bug where `typst watch` would confuse files and fail to pick up + updates +- Fetching of the release metadata in `typst update` now respects proxies +- Fixed bug with `--open` flag on Windows when the path contains a space +- The `TYPST_FONT_PATHS` environment variable can now contain multiple paths + (separated by `;` on Windows and `:` elsewhere) +- Updated embedded New Computer Modern fonts to version 4.7 +- The watching process doesn't stop anymore when the main file contains invalid + UTF-8 + +## Miscellaneous Improvements +- Parallelized image encoding in PDF export +- Improved the internal representation of content for improved performance +- Optimized introspection (query, counter, etc.) performance +- The [document title]($document.title) can now be arbitrary content instead of + just a string +- The [`number-align`]($enum.number-align) parameter on numbered lists now also + accepts vertical alignments +- Fixed selectors on [quote] elements +- Fixed parsing of `[#return]` expression in markup +- Fixed bug where inline equations were displayed in equation outlines +- Fixed potential CRLF issue in [`raw`] blocks +- Fixed a bug where Chinese numbering couldn't exceed the number 255 + +## Development +- Merged `typst` and `typst-library` and extracted `typst-pdf`, `typst-svg`, and + `typst-render` into separate crates +- The Nix flake now includes the git revision when running `typst --version` + +## Contributors + diff --git a/sources/docs/changelog/0.11.0.md b/sources/docs/changelog/0.11.0.md new file mode 100644 index 0000000000000000000000000000000000000000..27478862d11ee2bb2a4989435ef0c13fa8deba6c --- /dev/null +++ b/sources/docs/changelog/0.11.0.md @@ -0,0 +1,270 @@ +--- +title: 0.11.0 +description: Changes in Typst 0.11.0 +--- + +# Version 0.11.0 (March 15, 2024) + +## Tables +- Tables are now _much_ more flexible, read the new + [table guide]($guides/table-guide) to get started +- Added [`table.cell`] element for per-cell configuration +- Cells can now span multiple [columns]($table.cell.colspan) or + [rows]($table.cell.rowspan) +- The [stroke]($table.cell.stroke) of individual cells can now be customized +- The [`align`]($table.align) and [`inset`]($table.inset) arguments of the table + function now also take `{(x, y) => ..}` functions +- Added [`table.hline`] and [`table.vline`] for convenient line customization +- Added [`table.header`] element for table headers that repeat on every page +- Added [`table.footer`] element for table footers that repeat on every page +- All the new table functionality is also available for [grids]($grid) +- Fixed gutter-related bugs + +_Thanks to [@PgBiel](https://github.com/PgBiel) for his work on tables!_ + +## Templates +- You can now use template packages to get started with new projects. Click + _Start from template_ on the web app's dashboard and choose your preferred + template or run the `typst init