Forester › Release notes [005P]
- June 1, 2023
- Jon Sterling, with contributions from Armaël Guéneau, Jinser Kafka, Kento Okura, Kuen-Bang Hou (Favonia), Lîm Tsú-thuàn, Nick Hu, Owen Lynch, Patrick Nicodemus, Riley Shahar, Trebor Huang
A tool for tending forests of evergreen notes.
Forester › Project information [0065]
- June 20, 2023
- Jon Sterling
| code forge: | sr.ht/~jonsterling/forester |
| ticket tracker: | todo.sr.ht/~jonsterling/forester |
| mailing lists: | sr.ht/~jonsterling/forester/lists |
| opam package: | ocaml.org/p/forester |
| tutorial: | How to create your own Stacks Project in 10 minutes |
Release. Forester 6.0 [VNQB]
- February 12, 2026
- Kento Okura, Jon Sterling
We thank Tarides and the OCaml Software Foundation for their financial support enabling this release.
Overview [N0GL]
- February 12, 2026
- Kento Okura, Jon Sterling
This release contains no language changes. We summarise the main changes below.
- HTML by default; XML in maintenance mode. In short, Forester now defaults to emitting HTML, which is not currently customisable. In the future we will consider allowing custom stylesheets as well as other customisation hooks. For users who wish to customise their forest output, the XML output is preserved under the
--emit-xmlflag, but you will need to render the XML locally to HTML now that browsers are removing XSLT support. Please see this article for more detailed instructions. We understand that many users will not yet be able to move to the HTML mode because of various customisations they have built on top of the XML mode; we would like to hear from you, because we are working on a design that would enable more extensibility on the HTML side in the future. - Performance. Forester 6.0 is several times faster across the board, thanks to more thorough use of multicore OCaml features. If you encounter any problems (e.g. deadlock), please contact us; we have done our best to make this solid, but correct use of multicore OCaml is a little challenging and we may have yet made some mistakes.
- Semantic tokenisation. Forester’s language server now emits semantic tokens; this means that editors (like Neovim) that support LSP semantic tokenization will have automatically syntax-highlight Forester documents without requiring a tree-sitter or TextMate grammar.
- Live preview. When you use an editor that can connect to Forester’s language server (like Helix or Neovim), Forester automatically starts up a preview server that you can access in your web browser at
localhost:8080.- Forester renders pages on-demand, which means that you no longer have to wait for the entire forest to render every time you change one thing. The preview is refreshed live as you type in your editor. Note that live updates are only available through the language server.
- If you add
edit_command = "/usr/bin/my-editor {tree}"to the[forest]block offorest.toml, an edit button will appear next to each tree in the preview mode; ctrl-e may also be used to invoke the configured editor. - In the live preview, Forester’s (limited) documentation can be accessed the lower-right-hand corner of the window.
- New search palette. In order to reduce our dependency on the JavaScript ecosystem, Forester now comes with its own homemade search palette, built in OCaml using Daniel Bünzli’s brr library. When in live preview mode (see above), it supports full-text search across your entire forest.
- Hypermedia approach. Forester’s main priority going forward remains its static output, which can be uploaded to any dumb web hosting provider, such as your University pages. We are, however, experimenting with the use of more sophisticated hypermedia controls (via HTMX) to provide better interactivity; the HTMX mode is currently used in the preview server and nowhere else.
- Better LSP compliance. Forester now emits UTF-16 character offsets, which are de facto required by most language clients. This opens the door to the possibility of a working Visual Studio Code extension, whose development is now underway.
- Improved unofficial Windows support. It is now possible in principle to run Forester on Windows (with thanks to Anil Madhavapeddy and other Eio contributors for their contributions). Forester’s developers do not use Windows, so we do not make any guarantees about Forester on Windows, but the situation is at least improved.
Breaking changes [PH4U]
- February 12, 2026
- Kento Okura, Jon Sterling
If you are using the experimental “foreign forests” feature, please note that you will need to ensure that the JSON blobs are produced and consumed by the same version of Forester. This feature is not currently intended to be stable (you use it at your own risk), but in the future we may introduce a stable version once we have considered the design more carefully.
As mentioned, this release contains no (intentional) language changes. As a warning, in a future release we are intending to pare down the language a bit and remove features that apparently nobody except Jon Sterling is using, including the experimental object system.
Code hosting changes [BMHS]
- February 12, 2026
- Kento Okura, Jon Sterling
For the longest time, the Forester project has been hosted by the excellent SourceHut code forge. Unfortunately, measures taken by SourceHut to block scraping bots have resulted in Forester’s developers themselves being unable to access SourceHut’s interface with enough frequency that we have decided to move everyday work to Tangled, on a knot self-hosted by Anil Madhavapeddy on Cambridge Computer Laboratory infrastructure. To be very clear, our transition is not motivated by SourceHut’s restrictive AI policies: Forester is not a vibe-coded project.
If/when Tangled becomes enshittified, we will move off of it too.
The SourceHut-based mailing lists remain the appropriate venue for reporting issues with Forester, and we will continue to maintain the SourceHut git repository as a mirror and as a release archive. We have not yet decided on whether to continue using SourceHut’s issue tracker or move to Tangled for that, but this should not affect end-users: the issue tracker is for maintainers to use, and if you have a problem or a suggestion, you should report it on the mailing list.
Release. Forester 5.0 [011P]
- October 20, 2024
- Jon Sterling, Kento Okura
This is a major release of Forester that includes many changes under the hood, as well as breaking changes that will require manual adjustments to existing forests. We are sorry for the frustration that these changes may cause to existing users, but we strongly believe that this is necessary for Forester to reach its potential as a tool that enhances rather than replaces the World Wide Web; we also strongly believe that these changes will make Forester more useful for existing users as well as the next thousand users.
Our thanks to Owen Lynch, davidad, and Anil Madhavapeddy for conversations leading to the design of this release. We are grateful to ARIA’s Safeguarded AI initiative for helping us get to 5.0.
Many of the changes included here are meant to support the future of Forester as an authoring tool for a new kind of Internet of Science that will enable the federation of many different forests by extending existing protocols with new hypermedia controls for content transclusion applicable to scientific authoring.
Tl;dr: migration guide [0126]
- October 20, 2024
- Jon Sterling, Kento Okura
To migrate your forest to Forester 5.0, do the following:
- Update your configuration file (§ [0125]).
- Take into account changes to the source language (§ [OYOT]).
- Any
\authoror\contributorattributions must take a tree address as their argument; when you wish to attribute a resource to a person who is not represented by a tree, you can use\author/literal{Somebody’s Name}or\contributor/literal{Somebody’s Name}(see § [012N]). - Rewrite any queries to use the new datalog engine (see § [013A]), as the legacy query engine has been removed.
- Take into account the renaming of several built-in relations (see § [013C]).
- View your forest locally using an HTTP server rather than directly through the file system (see § [VNQ8]).
- Begin dialing back your use of custom XML stylesheets (see § [0127]). It is possible that support for customisation at this level will be removed in a future release; if you have innovative customisations that are very important for your use of Forester, consider discussing them on the mailing list so that maintainers can better understand the problems you are solving.
An implementation of the language server protocol [0SOW]
- October 20, 2024
- Jon Sterling, Kento Okura
Forester now ships with an implementation of the language server protocol. See our documentation for more information and configuration examples for various editors. Its status is still experimental. If you encounter crashes or other issues, please let the us know by opening an issue or by writing to the mailing list
Changes to forest.toml format [0125]
- October 20, 2024
- Jon Sterling, Kento Okura
Several changes have been made to the forest.toml configuration format.
Canonical URLs for tree addresses [011Q]
- October 20, 2024
- Jon Sterling, Kento Okura
Up until this release, Forester’s trees were addressed by short strings — which, by convention, might be of the form xxx-NNNN or NNNN or some arbitrary string like sterling-2021-thesis. In order to prepare for the future in which multiple forests can be glued together, we replace Forester’s short names with fully qualified URLs that point to the location on the World Wide Web where a given tree would be published (if you choose to publish it). By default, all local trees will be resolved against http://forest.local/, which you should change if you choose to publish your forest on the Web. In your forest.toml configuration, first set a base URL for your forest like the following:
[forest] url = "https://www.forester-notes.com/"
Within this forest, a tree named foo is then associated to the canonical URL https://www.forester-notes.com/foo/. Forester’s renderer will produce the correct directory structure so that if you were to upload the contents of the output directory to https://www.forester-notes.com/, a link to https://www.forester-notes.com/foo/ would bring you to the foo tree.
Hyperlinks in Forester source code to trees within your own forest will automatically expand the short name foo to the canonical URL https://www.forester-notes.com/foo/. Canonical URLs are used as vertices in the graph.
What do we mean by “URL”? [011R]
- October 20, 2024
- Jon Sterling, Kento Okura
Today, “URLs” are a mostly implementation-defined concept that can only be understood by looking at the source code of major web browsers; in the future, this may congeal into an actual standard but today is not that day (nor is tomorrow, if the state of the whatwg/url “living” [non-]standard is any indication). It is best to think of Forester’s approach to URLs as provisional and subject to evolution as the Web continues to mature.
Simplifications to the source language [OYOT]
- October 20, 2024
- Jon Sterling, Kento Okura
Removal of imports within subtrees [OYOU]
- October 20, 2024
- Jon Sterling, Kento Okura
It is no longer permitted to have an \import declaration within a subtree: these can occur only at the top level of a file and therefore have file-level scope.
Removing transclusion overrides [011T]
- October 20, 2024
- Jon Sterling, Kento Okura
In prior versions of Forester, it was possible to override the title and the taxon of a transcluded tree using the fluid bindings \transclude/title and \transclude/taxon respectively. This feature is no longer supported in Forester 5.0, and existing users are encouraged to purge their use of it prior to upgrading to Forester 5.0.
In short, supporting this feature was greatly complicating the planned transition to a genuine hypermedia format; it could also be argued that it might have led to scenarios where an original author’s intentions are violated at the transclusion site.
Please note that transclusion options, such as \transclude/expanded, etc., are still supported.
Removal of autocapitalisation [OYOV]
- October 20, 2024
- Jon Sterling, Kento Okura
Titles and taxa will no longer be autocapitalised: this feature biases Forester toward specific languages and is annoyingly complex to maintain. Therefore, you must rename all your titles and taxa to be capitalised by hand. This can be done in VS Code using the following regexp: replace \\taxon\{([a-z]) with \\taxon{\U$1, etc.
Changes to fallthrough behaviour for undefined identifiers [OYOW]
- October 20, 2024
- Jon Sterling, Kento Okura
Previously, an undefined identifier like \foo would be emitted verbatim as text rather than raising a warning. The reasoning behind this was to smoothly support referring to existing commands in TeX-like environments (including KaTeX and embedded LaTeX). The trade-off was that authors would not receive warnings about what were in many cases typographical errors.
In Forester 5.0, the fallthrough behaviour of undefined identifiers is now restricted to code that is evaluated within a TeX-like environment (either KaTeX or embedded LaTeX). In all other cases, a warning will be emitted. This involves a trade-off, because the arguments to a macro like
\def\my-macro[x]{#{\int_{\x}}}
are evaluated first outside the math scope. Therefore, a call like \int{\alpha} written outside of a math scope would result in a warning. The recommended solution to this problem is to use a lazy argument, which will be evaluated in CBN. Here is an updated version of the macro that works uses a lazy argument:\def\my-macro[~x]{#{\int_{\x{}}}}The design is admittedly imperfect, but I believe this is an improvement as it allows us to catch more typos. I expect that the handling of undefined identifier fallthrough will continue to evolve.
Changes to attribution links [012N]
- October 20, 2024
- Jon Sterling, Kento Okura
In prior versions, the \author and \contributor command would detect whether its contents were the address of a tree; if so, it would create a wikilink to the tree and otherwise, the included text would appear directly. This feature was convenient for smoothly handling the case that an author of a given resource is not represented in the forest by a biographical tree; the downside is that it makes the assumption that at compiletime we shall know the entire contents of the forest (and, thus, whether a given address shall be bound to a tree).
To simplify the handling of author links and make it compatible with the open-world future of Forester, the behaviour is changed as follows:
- The argument to
\authorand\authormust be a (possibly relative) Forester URL. Thus, on my own forest, it would be OK to have either\author{jeanbénabou}or\author{https://www.jonmsterling.com/jeanbénabou}but it would not be OK to have\author{Jean Bénabou}. - To make an unlinked attribution containing, use
\author/literal{Jean Bénabou}.
New datalog-based query engine [013A]
- October 20, 2024
- Jon Sterling, Kento Okura
As the query engine has evolved, it has become a bit unwieldy and misshapen. In order to prevent further churn and facilitate the long-term development and use of Forester, we are replacing the query engine and graph analysis with a more general tool: datalog. With this change comes the ability to introduce arbitrary relations of any arity; this is a powerful and dangerous tool, so use it wisely.
On performance trade-offs [013B]
- October 20, 2024
- Jon Sterling, Kento Okura
Switching to datalog makes forests that make heavy use of queries a bit slower to render. We considered this trade-off carefully, but believe that for the long-term health of Forester, this is acceptable. In the near future, Forester will render trees on demand rather than all at once (except when you are preparing a static archive for upload/deployment); in this mode of use, Forester will be faster than ever.
Renamed built-in relations [013C]
- October 20, 2024
- Jon Sterling, Kento Okura
Forester’s built-in binary relations have been accessible via macros like \rel/authors, etc. In this release, these relations are being renamed to make them more pleasant and consistent to use with datalog.
| Old name | New name |
|---|---|
\rel/tags |
\rel/has-tag |
\rel/taxa |
\rel/has-taxon |
\rel/authors |
\rel/has-author |
\rel/contributors |
\rel/has-direct-contributor |
\rel/transclusion |
\rel/transcludes |
\rel/links |
\rel/links-to |
New built-in relations [013D]
- October 20, 2024
- Jon Sterling, Kento Okura
A few new built-in relations have been added.
\rel/is-node ?Xis a unary relation that holds for any tree address?X. This is needed when specifying reflexive binary relations: the clauseR ?X ?X -:is not allowed by datalog, so one must useR ?X ?X -: {\rel/is-node X}.\rel/transcludes/transitive-closureis the transitive closure of\rel/transcludes.\rel/transcludes/reflexive-transitive-closureis the reflexive transitive closure of\rel/transcludes.\rel/is-reference ?Xholds when?Xis designated as a reference/bibliographical tree. Currently, the built-in rules of the database deduce\rel/is-reference ?Xfor any tree?Xwith taxonReference. The purpose of abstracting from the taxon is to enable non-English users of Forester to benefit from the computation of bibliographies.- Similarly,
\rel/is-person ?Xholds when?Xis designated as a personal/biographical tree. Currently, the built-in rules of the database deduce\rel/is-reference ?Xfor any tree?Xwith taxonPerson. \rel/in-bundle-closure ?X ?Yis the reflexive transitive closure of the union of the transclusion relation with the relation of?Xrequiring the asset?Y. The purpose of this relation is to easily bundle up fragments of a forest (see § [30FN]).
All of these built-in relations can be defined in Forester’s dialect of datalog; they are predefined for convenience, and because they are used in the computation of backmatter.
Example. An example datalog query [013E]
- October 20, 2024
- Jon Sterling, Kento Okura
In order to illustrate the use of the datalog engine, I will show how to construct a query that will find all the reference trees written by jonmsterling that are tagged either accepted or refereed. The first thing we must do is define the smallest relation containing all trees tagged accepted or refereed; this is done by adding clauses to the database as follows.
First we define the name of a relation. In the current release, relations are global strings and there is no facility to generate a “fresh” one; that may change in the future.
\let\rel/accepted-or-refereed{jonmsterling.query.bibliography.accepted-or-refereed}Next, we add two defining clauses for our relation. In what follows, \datalog simply delimits content that should be parsed as a datalog expression, and \execute instructs Forester to execute the datalog expression.
\execute\datalog{
\rel/accepted-or-refereed ?X -: {\rel/has-tag ?X '{refereed}}
}
\execute\datalog{
\rel/accepted-or-refereed ?X -: {\rel/has-tag ?X '{accepted}}
}The left-hand side of the reversed turnstile -: is a proposition representing the goal; the right hand side is given by propositions representing the premises, each surrounded in braces and separated by whitespace. Metavariables are written with a question mark sigil. Literal content is embedded into a datalog proposition by surrounding it in '{...}; we will see that literal content is one kind of vertex in the graph database.
Now that we have actually defined the relation that we will use, we can run a query:
\query\datalog{
?X -:
{\rel/has-author ?X @{jonmsterling}}
{\rel/is-reference ?X}
{\rel/accepted-or-refereed ?X}
}The structure of a query identifies the metavariable being solved behind the turnstile, and then lists the clauses that must hold. Whereas a content vertex is addressed via '{...}, a URL vertex is addressed using @{...}.
Atom syndication support [30FO]
- October 20, 2024
- Jon Sterling, Kento Okura
It is now possible to syndicate a given tree as an Atom feed; for example, if you have a tree for your blog and its subtrees/transclusions are your blog posts, you can include the following code to generate an Atom feed for this blog:
\syndicate-current-tree-as-atom-feed
If your blog is located at https://www.my-great-forest.net/my-blog/, then there will be an atom feed placed at https://www.my-great-forest.net/my-blog/atom.xml.
This feature is experimental and has some limitations.
Publishing and implanting forests [30FN]
- October 20, 2024
- Jon Sterling, Kento Okura
Forester now includes an experimental feature to “publish” a portion of your forest to a JSON blob that can be read by Forester and implanted into another forest. For example, if you include the following code in a tree within your forest, then a file will be emitted at output/my-forest.json containing the compiled content of your entire forest, together with all the assets:
\syndicate-query-as-json-blob{my-forest}{
\datalog{
?X -: {\rel/in-host ?X '{www.my-great-forest.net}}
}
}Of course, more sophisticated queries can be used. For example, you can emit all the items tagged public together as follows:
\syndicate-query-as-json-blob{my-public-forest}{
\datalog{
?X -: {\rel/has-tag ?Z '{public}}
}
}To implant the resulting JSON file into another forest, simply copy over the file and add the following line to your configuration file:
[forest]
foreign = [{ path = "my-public-forest.json" }]By default, implanted trees will be rendered to your output folder underneath a foreign/ directory; if you wish to instead that links to implanted trees be routed directly to their canonical URLs (which will likely be the case if you implant a public forest), then you may configure that as follows:
[forest]
foreign = [{ path = "my-public-forest.json", route_locally = false }]This feature is highly experimental and has many limitations; it will change in breaking ways in the near future. Although we are very interested to learn about the limitations of this feature, we will be taking a hands-off approach to support until the feature has taken a more stable form.
Changes to how forests are viewed locally and deployed [VNQ8]
- October 20, 2024
- Jon Sterling, Kento Okura
In the past, Forester’s XML output used relative URLs for all links. This was tractable because the output had no directory structure, but this is increasingly becoming problematic—for example, foreign trees are going to be rendered to a subdirectory, but this breaks all the relative URLs. I have come to the conclusion that the only way forward is to use absolute URLs for everything, but this assumes that the output is being served from the root directory of some host. As a result, users must fire up an HTTP server in order to view their forest locally. With this release we will (TODO) include a built-in HTTP server, but early adopters can simply run python3 -m http.server 8000 from the output directory and open localhost:8000 in their browser.
Some users may wish to deploy their forest somewhere other than the root directory of a given (sub)domain. To achieve this and have all your links work correctly, enter the following configuration:
[forest] url = "https://www.my-great-website.net/my-subfolder/"
Changes to handling of assets [P9BN]
- October 20, 2024
- Jon Sterling, Kento Okura
Assets in compiled forests are content-addressed by their hash; a new primitive \route-asset is provided for generating the correct URL of an asset that is stored in a designated assets directory. For example, to embed an image that is stored in assets/images/my-great-illustration.jpg, you would write the following code:
\xmlns:html{http://www.w3.org/1999/xhtml}
\<html:img>[src]{\route-asset{assets/images/my-great-illustration.jpg}}{}The future of Forester’s XML format [0127]
- October 20, 2024
- Jon Sterling, Kento Okura
Forester currently emits archival-quality output in a custom XML format that is then interpreted using an XSLT stylesheet (as part of the “theme”). This format has served us well, enabling users to customise the presentation of their forests to a great degree. An added benefit of the XML format is to be able to easily convert a tree to LaTeX using another stylesheet.
However, the constantly changing XML format has been an equally frustrating source of churn for users of Forester, and I have for some time now been warning users who customise their theme that these customisations are technically possible but not supported (i.e. we make no promise not to break them).
The time is coming when Forester’s interaction model and output format will be changed drastically; rest assured that the core principles behind Forester (including the ability to generate static archival output that can be hosted anywhere) will be retained. We aim to become a better citizen of the World Wide Web by moving toward a more standard hypermedia format.
One possiblity is to extend HTML with just the hypermedia controls and embedded microformats needed for Forester’s operation. This re-coupling of presentation and data would, paradoxically, facilitate Forester to evolve more rapidly over time while simultaneously increasing the longevity of forests that have been compiled using older versions of the tool.
Release. Forester 4.3 [0109]
- August 10, 2024
- Jon Sterling, with contributions from Patrick Nicodemus, Kento Okura, Nick Hu, Owen Lynch
This is a smaller release that contains a few changes to how Forester works under the hood. As usual, you must upgrade your theme submodule to the 4.3.0 tag.
Changes to external LaTeX rendering [010A]
- August 10, 2024
- Jon Sterling, with contributions from Nick Hu
Previously, the \tex construct would generate a .tex file, convert it to an SVG file, and then copy it into output/resources/; this file would then be referenced in the resulting XML using the <forester:embeddex-tex> element, which was rendered by the theme to <html:img>.
Now, the contents of the SVG file are embedded directly into the resulting document as an <html:img> element with a base64-encoded data-url. The <forester:embedded-tex> element is no longer used.
The goal of this change is to make the output files more self-contained and less reliant on surrounding files. A downside of the present change is that it makes the output files a bit larger, as base64-encoded SVGs are not exactly small. In the future, we might instead embed the SVG code into the DOM (which could have some benefits for accessibility), but if we do this, we will have to massage the SVG output to remove duplicate @id attributes.
Static builds for linux [010B]
- August 10, 2024
- Jon Sterling, with contributions from Owen Lynch
A build-static-linux.sh script has been added which can be used, in connection with Docker, to build a static binary that can be run on Linux.
Release. Forester 4.2 [00WK]
- June 20, 2024
- Jon Sterling, with contributions from Kento Okura, Jinser Kafka
This release brings several internal changes that are meant to facilitate the further improvement of Forester, as well as some user-facing changes (most notably a new query language). These are breaking changes: existing queries will need to be translated, and you will need to upgrade your theme.
First-class functions and lazy arguments [00YF]
- June 20, 2024
- Jon Sterling
This release adds λ-abstraction, which can be written like so:
\fun[x][y]{Hello, \x and \y}In addition, lazy arguments are now supported. In any place that a function argument can be bound (e.g. in \def, \let, or \fun), an argument marked with a tilde is automatically wrapped in a thunk when it is passed. For example, consider the following code:
\def\my-fun[x][~y]{Hello, \x and \y{}!}
\p{\my-fun{foo}{bar}}In the above, the argument x is strict and y is a thunk that must be forced before being used—hence the application to {}; note that the results are not memoised. The code above is functionally equivalent to the following:
\def\my-fun[x][y]{Hello, \x and \y{}!}
\p{\my-fun{foo}{\fun[z]{bar}}}Of course, when your code is pure, passing by name vs. by value does not make a difference. The purpose of this feature is, however, to enable more expressive macros that make use of fluid bindings.
Example. Combining fluid bindings and lazy arguments [00YG]
- June 20, 2024
- Jon Sterling
Forester 4.0’s enhanced XML support makes it possible (see Example [00RL]) to write MathML directly as an alternative to using Forester’s TeX-like math mode via KaTeX. For example, we can write the following wrappers for some basic MathML elements:
\xmlns:mml{http://www.w3.org/1998/Math/MathML}
\def\math[body]{\<mml:math>{\body}}
\def\mrow[body]{\<mml:mrow>{\body}}
\def\mi[x]{\<mml:mi>{\x}}
\def\mo[o]{\<mml:mo>{\o}}
\def\mn[n]{\<mml:mn>{\n}}With this in hand, we can write prose involving MathML content, like so:
\p{Let \math{\mi{x}} and \math{\mi{y}} be integers such that \math{\mrow{\mrow{\mi{x}\mo{-}\mi{y}}\mo{=}\mn{0}}}.}The above is a bit messy. We can clean it up with some function definitions:
\def\plus[x][y]{\mrow{\x \mo{+} \y}}
\def\equals[x][y]{\mrow{\x \mo{=} \y}}
\let\x{\mi{x}}
\let\y{\mi{y}}
\p{Let \math{\x} and \math{\y} be integers such that \math{\equals{\plus{\x}{\y}}{\mn{0}}}.}It is annoying that we have to always wrap things in \math. By combining first-class functions, lazy arguments, and fluid bindings, we can lift this requirement:
% Allocate a fluid binding to hold the function that enters math mode.
\alloc\math-wrapper
% Ensure that a given (lazy) argument is evaluated inside a
% <mml:math> element.
\def\ensure-math[~body]{%
\scope{%
% Set a default value for \math-wrapper (no-op if already set).
\put?\math-wrapper{\fun[x]{\<mml:math>{\x}}}%
%
% Apply the current function bound to \math-wrapper.
\get\math-wrapper{%
% Bind \math-wrapper to the identity function in the current scope so that
% we do not get redundant <mml:math> nodes.
\put\math-wrapper{\fun[x]{\x}}%
%
% Force the \body thunk to evaluate the body within the wrapper.
\body{}%
}%
}%
}We now re-define our macro library to use the \ensure-math:
\def\mrow[~x]{\ensure-math{\<mml:mrow>{\x{}}}}
\def\mi[~x]{\ensure-math{\<mml:mi>{\x{}}}}
\def\mo[~x]{\ensure-math{\<mml:mo>{\x{}}}}
\def\mn[~x]{\ensure-math{\<mml:mn>{\x{}}}}
\def\plus[~x][~y]{\mrow{\x{} \mo{+} \y{}}}
\def\equals[~x][~y]{\mrow{\x{} \mo{=} \y{}}}Now, we can put MathML content freely into prose without needing to wrap it each time.
\let\x{\mi{x}}
\let\y{\mi{y}}
\p{Let \x and \y be integers such that \equals{\plus{\x}{\y}}{\mn{0}}.}Warning. Lazy arguments are experimental [00YH]
- June 20, 2024
- Jon Sterling
Please note that these features are experimental and subject to change—only build large macro libraries relying on them at your own risk.
New query language [00WS]
- June 20, 2024
- Jon Sterling
The existing querying feature, introduced in Forester 2.2, has been replaced by something much better — at the cost of a breaking change that will require existing queries to be rewritten.
New syntax for set operations [00WU]
- June 20, 2024
- Jon Sterling
Intersections of queries are formed using a variadic constructor \query/isect. For example, the following computes the intersection of the queries q1, q2, and q3:
\query/isect{q1}{q2}{q3}Unions of queries are formed similarly using the variadic \query/union constructor. The complement of a query q is written \query/compl{q}.
Note: as before, to render the results of a query you must use the \query command; for example:
\query{
\query/isect{q1}{q2}{q3}
}Query operations are first-class values [00WV]
- June 20, 2024
- Jon Sterling
Previously, the built-in query operations were written like \query/and, etc.; these names, however, were hard-coded into the lexer which meant that they did not work in the expected way with Forester’s hierarchical namespacing. This hardcoding has been removed, and query operations are treated as first-class values that are resolved from primitive names in the \query/ namespace. As such, the following code is equivalent to \query/compl{\query/taxon{theorem}}:
\scope{
\open\query
\compl{\taxon{Theorem}}
}A further consequence of this change is that queries can be defined compositionally by macros.
Relational queries [00WW]
- June 20, 2024
- Jon Sterling
The most significant user-facing change to the query language is the ability to form basic relational queries along several built-in relation-symbols; in fact, the built-in query constructors \query/taxon, \query/tag, and \query/author are all expressible in these terms.
Built-in relation symbols [00WX]
- June 20, 2024
- Jon Sterling
Forester includes several built-in relation symbols, maintained as graphs that are accumulated during evaluation:
\rel/transclusioncontains an edge fromxtoywhenxdirectly transcludesy, i.e. contains\transclude{y}.\rel/linkscontains an edge fromxtoywhenxlinks toy, i.e. contains something like[...](y)or[[y]].\rel/taxacontains an edge fromxtoywhenxhas taxony, i.e. contains\taxon{Y}.\rel/tagscontains an edge fromxtoywhenxhas tagy, i.e. contains\tag{y}.\rel/authorscontains an edge fromxtoywhenxhas authory, i.e. contains\author{y}.\rel/contributorscontains an edge fromxtoywhenxis a tree with contributory, i.e. contains\contributor{y}.
The implementation supports arbitrarily many relation symbols; this is not yet exposed to the user, but could in the future be employed by advanced users of Forester to support the development of sophisticated ontologies.
Query modes and polarities [00WZ]
- June 20, 2024
- Jon Sterling
Given an address x and a relation symbol r, there are several useful queries that we might wish to make:
- We might wish to find all incoming edges to
xinr, or we may wish to find all outgoing edges fromxinr. We shall refer to the differenec between incoming and outgoing edges is referred to as a polarity. - Rather than searching for edges, we may wish to search for paths — which corresponds to passing from a relation to its preorder reflection. We will refer to this distinction as a mode.
Forester supports both polarities and modes for relational queries via the following built-in constants:
\query/incomingand\query/outgoingdenote the two polarities.\query/edgesand\query/pathsrepresent the two modes.
The syntax of a relational query [00WY]
- June 20, 2024
- Jon Sterling
Example. Expressing built-in queries [00X0]
- June 20, 2024
- Jon Sterling
The built-in basic queries can be expressed in terms of \query/rel in the following way:
\def\my-query/author[x]{
\open\query
\rel{\edges}{\incoming}{\rel/authors}{\x}
}
\def\my-query/taxon[x]{
\open\query
\rel{\edges}{\incoming}{\rel/taxa}{\x}
}
\def\my-query/tag[x]{
\open\query
\rel{\edges}{\incoming}{\rel/tags}{\x}
}Example. Querying the (back)links and context a given tree [00X2]
- June 20, 2024
- Jon Sterling
Both the backlinks and (forward) links of a given tree can be computed using a query to the \rel/links relation, and the context (immediate parents) of a given tree can be obatined from the \query/transclusion relation:
\def\query/backlinks[x]{
\open\query
\rel{\edges}{\incoming}{\rel/links}{\x}
}
\def\query/links[x]{
\open\query
\rel{\edges}{\outgoing}{\rel/links}{\x}
}
\def\query/context[x]{
\open\query
\rel{\edges}{\incoming}{\rel/transclusion}{\x}
}Example. Querying a coslice of the transclusion preorder [00X4]
- June 20, 2024
- Jon Sterling
We can also write a query to compute the set of trees underneath a given tree in the transclusion preorder (including the original tree) — in other words, the coslice.
\def\query/transclusion-coslice[x]{
\open\query
\rel{\paths}{\outgoing}{\rel/transclusion}{\x}
}Unions and intersections of families of queries [00X1]
- June 20, 2024
- Jon Sterling
A further primitive query-former is the union or intersection of a certain family of queries indexed in the results of a fixed query. These are written as follows:
\query/union-fam{q}{qfam}
\query/isect-fam{q}{qfam}In the above, q is a query expression and qfam is a first-class function that takes an address and returns a query expression. There are a couple built-in instantiations of \query/union-fam and \query/isect-fam for the specific case where qfam is a family of relational queries; for example:
\query/union-fam-rel{q}{mode}{polarity}{rel}is equivalent to the following more verbose code:
\query/union-fam{q}{
\fun[x]{
\query/rel{mode}{pol}{\x}
}
}Example. Querying the bibliography of a given tree [00X3]
- June 20, 2024
- Jon Sterling
We can define a macro to compute the bibliography of a given tree, making use of \query/transclusion-coslice from Example [00X4].
\def\query/bibliography[x]{
\open\query
\isect{
\union-fam-rel{\transclusion-coslice{\x}}{\edges}{\outgoing}{\rel/links}
}{
\taxon{Reference}
}
}The above code first accumulates all the outgoing links from the given tree and any of its children, and then restricts (by intersection) to those with taxon reference.
Example. Querying all hereditary contributors to a tree [00X5]
- June 20, 2024
- Jon Sterling
We can use the union of families of relational queries to compute the set of (proper) contributors to a given tree. This is slightly subtle, because if a bibliographic tree is transcluded, we do not want its contributors to be included.
\def\query/contributors[x]{
\open\query
\union-fam-rel{
\isect{
\transclusion-coslice{\x}
}{
\compl{
\taxon{Reference}
}
}
}{\edges}{\outgoing}{\rel/contributors}
}In the future, the support for query-indexed families of queries might be generalised to allow arbitrary queries in the components rather than only relational ones. The current version of the feature should be viewed as somewhat provisional.
Warning. Queries are experimental [00WT]
- June 20, 2024
- Jon Sterling
It is strongly recommended that inexperienced users of Forester continue to limit their usage of queries until the feature has reached a stable interface.
Intermediate representation of the XML format [00WL]
- June 20, 2024
- Jon Sterling
Forester’s primary output format is XML, rendered live in the browser to HTML using an XSLT stylesheet. Although this will continue to be the main output format, together with Kento Okura as well as our friends from the Topos Institute I am hoping to explore richer hypermedia interfaces for forests that could transcend the limitations of static HTML output.
In order to support multiple backends without creating a log of code churn, I have created an OCaml abstraction of the XML format that will serve as a “source of truth” for Forester’s output — which can be serialised directly to XML, or rendered in a different way (e.g. as HTML or htmx emitted by a hypermedia server).
With this change, I would expect Forester’s XML format to begin to change less and less over time, perhaps culminating in a versioned schema. I do not, however, guarantee that I will not make breaking changes to the format going forward.
Generalised backmatter [00WM]
- June 20, 2024
- Jon Sterling
Currently, the backmatter of a tree is not customisable; although the default backmatter sections are useful for most trees, it is likely that some of the sections are less relevant at times, and that other kinds of queries would be useful to be able to include on a tree-by-tree basis.
In order to facilitate such a feature in the future, this release changes the representation of backmatter to support arbitrary content and queries. This is a breaking change to the XML format: the <backmatter> element now contains arbitrary <tree> elements that encode the backmatter sections. By virtue of the improved query engine, all default backmatter sections are computed from queries.
HTML figures and captions; embedded TeX [00WN]
- June 20, 2024
- Jon Sterling
This release adds \figure and \figcaption primitives that are interpreted by the XSLT stylesheet as HTML’s <figure> and <figcaption> elements.
The stylesheet no longer emits the images corresponding to embedded \LaTeX inside a <center> tag, as this is deprecated in HTML. Users are encouraged to wrap Forester’s \tex primitive in a macro that embeds a diagram in a figure. For example, the following code comes from my own macro preamble:
% Allocate a fluid binding to hold the default LaTeX preamble,
% e.g. for loading tikz packages.
\alloc\base/tex-preamble
\def\texfig[~body]{
\scope{
% Install a LaTeX preamble to be used by default if none is set.
\put?\base/tex-preamble{
% Some useful things from my own library.
\latex-preamble/string-diagrams
\latex-preamble/diagrams
}
% Wrap the diagram in a figure
\figure{
% Render the LaTeX code with the current preamble
\tex{\get\base/tex-preamble}{\body{}}
}
}
}Performance improvements in graph analysis [00ZF]
- June 20, 2024
- Jon Sterling
The previous graph implementation has been replaced with one that is more time-efficient (at the cost of space). Computing the transclusion preorder (or, more generally, the reflexive-transitive closure of relations) is orders of magnitude faster; my own forest ultimately compiles in twice the speed.
Release. Forester 4.1 [00S9]
- June 15, 2024
- Jon Sterling, with contributions from Kento Okura, Trebor Huang, Nick Hu
Special thanks to Kento Okura, Nick Hu, and Trebor Huang for their contributions to this release.
New forester init command [00U0]
- June 15, 2024
- Jon Sterling, with contributions from Kento Okura
To make it easier to set up a new forest, we have added a forester init command; when you run this command in an empty directory, it will initialise a git repository with a submodule for the default theme pinned to the correct release, and a configuration file.
Rendering only a subset of the forest [00WA]
- June 15, 2024
- Jon Sterling
A new option has been added to the forester build command to render only certain trees. For example, the following command will render only the trees at addresses xxx-MMMM and yyy-NNNN:
forester build forest.toml --render-only=xxx-MMMM,yyy-NNNN
Note that in order to maintain a correct graph analysis, the entire forest will nonetheless be evaluated. As rendering is the slowest part of the process, however, this option can still save a lot of time. In the future it could be useful to have a more sophisticated option that renders (e.g.) all children of a given tree, etc.
Changed behaviour of queries [00SP]
- June 15, 2024
- Jon Sterling
Forester’s rudimentary support for queries has been simplified somewhat. Previously, the results of a query would be gathered and, if non-empty, placed underneath an anonymous subtree (whose title could be modified using transclusion options).
In light of the user-level support for anonymous subtrees introduced in Forester 3.1, the behaviour of queries has been simplified: the results of a query are simply transcluded directly without being enclosed in a subtree.
Although the new behaviour is simpler, it is no longer possible to have a query subtree that is hidden when it returns no results. Users should treat the querying feature as highly provisional, and subject to change and even potential removal.
Addresses for anonymous trees [00SQ]
- June 15, 2024
- Jon Sterling
Previously, a subtree could be emitted without any address; this greatly complicated the logic of the graph analysis, designated parents, and other things. Now, emitting an anonymous subtree generates a fresh address in a separate namespace; as a result, these trees get rendered to their own XML file. Naturally, an anonymous subtree cannot be linked to or transcluded, but it can now participate properly in the graph analysis.
Incremental parsing [00SA]
- June 15, 2024
- Jon Sterling, with contributions from Nick Hu
Menhir’s incremental parsing API is adopted in order to make the parser more resiliant to syntax errors. The goal is to support language server protocol diagnostics in a future release.
Dependency audit [00WG]
- June 15, 2024
- Jon Sterling
In recent releases, Forester has become increasingly dependent on various system packages (including openssl) via transitive dependencies. This has caused a great deal of build breakage for both our developers and users, so we decided to remove all but the most critical dependencies to avoid losing control of things. Experimental tools that rely on more system dependencies that are likely to cause build breakage can be created, but only outside the main forester package.
Release. Forester 4.0 [00RF]
- April 5, 2024
- Jon Sterling, with contributions from Kento Okura
This is a major release of Forester that changes both the command line interface and the XML format, introducing many new features under the hood as well as quality-of-life improvements (including a 2X rendering speedup).
Forest configuration via TOML [00RG]
- April 5, 2024
- Jon Sterling, with contributions from Kento Okura
Previously, the locations of trees as well as assets and theme directories were configured by means of command line arguments. As this has become a bit unwieldy, especially as many users have multiple projections of their forest, we have consolidated these options under a simple TOML configuration file whose location is the first argument to most forester commands. Here is an example configuration file:
# forest.toml [forest] trees = ["trees"] assets = ["assets"] theme = "theme" root = "0001" base_url = "https://www.jonmsterling.com"
It is common to have multiple configurations. For example, if you have “public” trees located in a specific directory, you can have an additional configuration:
# public.toml [forest] trees = ["trees/public"] assets = ["assets"] theme = "theme" root = "0001" base_url = "https://www.jonmsterling.com"
Both the assets and theme keys are displayed above with their default values, so they could be omitted. There is an additional stylesheet key that can be used to set the name of the XSL stylesheet used (the default is forest.xsl).
To build the forest, simply run: forester build forest.toml; other options can be used (see forester build --help), such as forester build forest.toml --dev.
Enhanced XML support [00RH]
- April 5, 2024
- Jon Sterling
An XML namespace for Forester [00RI]
- April 5, 2024
- Jon Sterling
The XML format is now governed by the XML namespace with URI http://www.forester-notes.org/005P/; as is typical of XML grammars, element names are namespaced whereas attribute names lie in no namespace. Forester emits XML with element names qualified by a prefix bound to this namespace. This change breaks existing XSL stylesheets, so you must upgrade your theme.
The new version of the default theme contains rules to allow anything in either the http://www.w3.org/1999/xhtml or http://www.w3.org/1998/Math/MathML namespaces to be copied through to the output HTML (with namespace prefixes stripped). In combination with § [00RJ], this allows you to write HTML and MathML in Forester directly.
Please note that although Forester now has a namespace, it does not has a schema. Any direct integration with the XML format (e.g. by custom themes) is not supported and should be done at your own risk — several recent releases have illustrated the continued rapid evolution of the XML format with many breaking changes. I expect this evolution will continue for some time.
Emitting XML and resolving namespaces [00RJ]
- April 5, 2024
- Jon Sterling
Since version 3.0, Forester’s source language has supported a limited form of custom XML output by means of the \xml command. This support was, however, somewhat unwieldy: no built-in accounting for XML namespaces was included, so correct usage of \xml was prohibitively difficult because of the need for xmlns attributes on essentially every node.
Feature. XML namespace declaration [00RK]
- April 5, 2024
- Jon Sterling
Forester treats XML namespace prefixes in a way that respects \alpha -equivalence: in other words, any prefix mentioned must be bound, and it is possible for two different textually identical namespace prefixes to denote different namespaces depending on their scope. This makes it possible to compose code that emits XML without coordinating namespace prefixes, which I have found to be a major impediment to the correct use of XML for non-trivial work.
An XML namespace prefix is bound by a declaration like the following:
\xmlns:html{http://www.w3.org/1999/xhtml}This declaration has the same scoping rules as \def.
Feature. XML literals [00RM]
- April 5, 2024
- Jon Sterling
The old \xml syntax has been replaced with a new convenient notation for XML literals that supports declared XML namespace prefixes. The grammar of XML literals is summarised below:
qname ::= prefix:name | name
expr ::= ... | \<qname>[qname]{expr}...{expr}For example, if the prefix html: is bound to http://www.w3.org/1999/xhtml as in Feature [00RK], the expression \<html:mark>[class]{highlight}{some highlighted text} will emit the following XML:
<html:mark xmlns:html="http://www.w3.org/1999/xhtml" class="highlight"> some highlighted text </html:mark>
In reality, the appropriate @xmlns:html attribute will be attached only where it is needed in keeping with the hierarchical structure of the XML tree. Note that when the same textual prefix is bound to two different namespaces, one of them will be automatically \alpha -renamed so as to result in correct XML with the intended semantics.
Example. A worked example [00RL]
- April 5, 2024
- Jon Sterling
The following code causes MathML to be emitted (in the correct namespace), combining Feature [00RK] and Feature [00RM]:
\xmlns:mml{http://www.w3.org/1998/Math/MathML}
\<mml:math>[display]{block}{
\<mml:mrow>{
\<mml:msup>{
\<mml:mi>{x}
\<mml:mn>{2}
}
\<mml:mo>{+}
\<mml:mi>{x}
}
}The above displays as follows:
Release. Forester 3.1 [00HY]
- March 9, 2024
- Jon Sterling, with contributions from Kento Okura, Owen Lynch
To use this release, you will need to upgrade your theme and you may also need to edit your forest itself (please write to the mailing list if you encounter difficulties). Remember that this includes not only the XSLT stylesheet, but also the CSS stylesheet and the JavaScripts.
The base theme is now versioned: if you are using Forester 3.1, you can confidently use the 3.1.0 tag. The head of the main branch of the theme may at times include changes that are compatible with only the main branch of Forester itself.
Feature. Designated parents [00O3]
- March 9, 2024
- February 8, 2024
- Jon Sterling
In keeping with the philosophy of evergreen notes, hierarchical structure in Forester has always been introduced by transclusion of independent trees; in this model, a tree has no canonical parent because it may be contextualised in many distinct hierarchical narratives. Experience using Forester suggests that this is the right idea the vast majority of the time, but use-cases have emerged that challenge these assumptions: there do indeed arise natural subtrees that are exceedingly awkward to “decontextualise”.
For example, the features described in a changelog (such as the present one) are awkward to decontextualise because they refer to knowledge that is temporary in its applicability. Likewise, the subtrees of one’s daily notes or journal are likely to be fleeting in nature and may have little insight that can be decontextualised — and in spite of this, these notes remain important for restoring mental context on long-running projects, etc.
For these reasons, I have (reluctantly) added a new frontmatter directive \parent{xxx-NNNN}, which designates the tree at address xxx-NNNN as “the” context-providing parent of the current tree. This feature is experimental and under-theorised; it should be used sparingly.
When a given tree appears transcluded within its “designated” parent, it will be shown with the title that has been specified; however, when the tree appears outside of this context, its title will appear with the parent’s title prepended to it: “parent › child”.
Feature. Inline subtrees [00O4]
- March 9, 2024
- February 8, 2024
- Jon Sterling
Previously, there was a one-to-one mapping between trees and files. After discussion on the mailing list with Kristopher Brown, I have added support for defining new subtrees inline to an existing tree. The current behavior is that an inline subtree has its designated parent automatically assigned; author and date metadata is inherited (this may change in the future).
To emit (and transclude) a subtree at address xxx-NNNN, you can write the following:
\subtree[xxx-NNNN]{
\title{My title}
\p{my body}
}It is also possible to have an anonymous inline subtree, one that has no address of its own. In this case, write:
\subtree{
\title{My title}
\p{my body}
}An anonymous inline subtree will, naturally, not have its own page emitted and cannot be linked to. In the graph analysis (for computing backlinks, etc.), an anonymous inline subtree will be identified with its parent.
Inline subtrees should not be overrused; but they may make the process of daily journalling and other activities more lightweight.
One consequence of breaking the one-to-one relationship between trees and files is that commands like forester new need to actually fully evaluate the forest, whereas in the past it was possible to merely scan the file system. This is a trade-off: if your forest contains fatal errors, you cannot use forester new or related querying commands. You should never leave your forest with fatal errors long enough to notice this.
This feature is experimental and its behaviour may change. Use it at your own risk.
Feature. cleveref-style referencing [00HZ]
- January 12, 2024
- Jon Sterling
You can now write \ref{xxx-NNNN} to produce a link to the tree at address xxx-NNNN labeled by its taxon. After the taxon, the textual format and destination of the link depends on whether xxx-NNNN lies in the present context. If the linked tree is present, then link will refer to the first transclusion of the tree into the present context; otherwise, the link will refer to the tree’s stable address. For example:
- A reference to this very tree: Feature [00HZ].
- A reference to a parent of this tree: Release [00HY].
- A reference to a cousin of this tree: Feature [00EY].
The behavior of references within one tree naturally depends on the transclusion context in which you are viewing that tree. It is instructive to examine the examples above by viewing this tree from its parent or on its own page.
Feature. New forester query command [00O5]
- March 9, 2024
- Jon Sterling, with contributions from Kento Okura
Kento Okura has implemented a new forester query command that may be useful for creating external editor tooling; currently it is possible to query for lists of all prefixes (the xxx in xxx-NNNN), tags, and taxa. Please run forester query --help for more information.
Feature. Random vs. sequential generation of addresses [00O6]
- March 9, 2024
- Jon Sterling, with contributions from Owen Lynch
By default, Forester generates tree addresses sequentially within a given prefix; Owen Lynch has implemented forester new --random, which instead generates random tree identifiers. Although this option is not recommended for most users, it can be used to mitigate the problem of multiple collaborators creating trees within the same prefix. Please run forester new --help for more information.
Feature. Manual numbering for digital editions [00Q6]
- March 9, 2024
- Jon Sterling
Numbering of trees in Forester is by default relative and determined by position in the current view. When creating translations or digital editions, the numbering from the source material is what is important. For this reason, I have added a new frontmatter directive to impose a manual numbering on a given tree.
\taxon{Chapter}
\number{foo}This numbering will be used in the table of contents, headings, and by Feature [00HZ].
Change. Improvements to verbatim lexer [00OH]
- March 9, 2024
- Jon Sterling
Forester includes a special lexing mode for quoting source code, delimited by \startverb and \stopverb. This mode was never implemented properly and so it did not work well in practice; for example, previously the line comment lexer could be activated via % from within vebatim mode, which made it very difficult to quote code that has comments. The lexer has been revamped and the behavior of verbatim mode is a bit different from before.
Between the delimiters (\startverb,\stopverb), text now is taken precisely as-written, except that newlines are stripped from the beginning and the end of the quoted text. Previously, the strange behavior of comments noted above could be used to manually avoid an initial line break from appearing in the quoted text. So in a prior version of Forester, you may have written something like this:
\startverb% my verbatim text \stopverb
Now, you should instead write:
\startverb my verbatim text \stopverb
Change. Removal of \texpackage and changes to \tex [00LR]
- January 25, 2024
- Jon Sterling
In Forester 2.1, the \texpackage frontmatter command was added in order to accumulate a list of packages that are then used automatically when rendering \tex{code...}. From Forester 3.1, this feature is removed and to embed \LaTeX code, you must explicitly specify the preamble as follows:
\tex{
\usepackage{mypackage1}
\usepackage{mypackage2}
}{
my code goes here
}Of course, within a single project (or even forest), you may have a relatively stable set of \LaTeX packages that you need. In this case, it is recommended to wrap \tex in your own macro:
\def\my-tex[body]{
\tex{
\usepackage{mypackage1}
\usepackage{mypackage2}
}{\body}
}An even more sophisticated approach might use fluid bindings to allow local customisation of packages in use:
\alloc\my-tex-preamble
\def\my-tex[body]{
\scope{
\put?\my-tex-preamble{}
\tex{\get\my-tex-preamble}{\body}
}
}Change. Removal of undocumented \LaTeX output [00O2]
- March 9, 2024
- February 8, 2024
- Jon Sterling
Previously, Forester would emit .tex files for each of your trees in the latex directory. This feature has been removed, as \LaTeX can be generated more reliably using XSLT. Please see the forester-to-latex repository for an example stylesheet.
Change. Breaking changes to the XML format [00LS]
- January 25, 2024
- Jon Sterling
Forester 3.1 makes some breaking changes to the XML format; if you are using the default theme, just update it to the latest version to migrate your forest. The main change is that “trails” for subtrees (like “1.4.2”) are no longer computed ahead of time and stored in XML, but are instead computed on the fly in the XSLT stylesheet using <xsl:number>.
A further change is that embedded \LaTeX is no longer emitted using the <img> element: instead, there is a new <embedded-tex> element with an attribute @hash containing the name (without extension) of the appropriate SVG file, and with children elements <embedded-tex-preamble> and <embedded-tex-body>. These are meant to facilitate generation of \LaTeX documents from Forester’s XML output in combination with the filecontents environment.
Release. Forester 3.0 [00CW]
- November 3, 2023
- Jon Sterling, with contributions from Kento Okura, Lîm Tsú-thuàn, Owen Lynch, Kuen-Bang Hou (Favonia)
This is a major breaking release; some surgery may be required on existing forests. Thanks to Favonia, Kento Okura, Lîm Tsú-thuàn, and Owen Lynch for their contributions to this release. Thanks also to Adrien Guatto for bug reports.
Feature. Proper diagnostics with source locations [00CX]
- November 3, 2023
- Jon Sterling
Forester 3.0 adds proper diagnostics and error messages, via the excellent asai library maintained by Favonia. When something goes wrong in your forest, the terminal output should expain what happened while displaying the precise location in your source file.
Feature. Experimental support for objects [00EY]
- November 19, 2023
- Jon Sterling
To facilitate the development of extensible macro libraries for diagramming and other tasks, Forester 3.0 introduces experimental support for objects — which should be thought of as combination of records/structs, closures, and general recursion. An object is created like so:
\def\my-object{
\object[self]{
[method1]{
the implementation of this method
}
[method2]{
the implementation of another method
\self#method1
}
}
}The variable self is explicitly bound, and can be bound to any name you like. Methods currently are not allowed to take any arguments, but this may change in the future. A primitive form of inheritance is supported, using \patch:
\patch{\my-object}[self]{
[method1]{
\self/super#method1
some further code
}
}The support for objects in Forester 3.0 is extremely experimental and preliminary: users are discouraged from relying on it.
Feature. Improvements to date handling [00F0]
- November 20, 2023
- Jon Sterling
Forester 3.0 improves support for journaling with date-specific trees. When a tree is dated YYYY-MM-DD and there exists a tree at address YYYY-MM-DD, the date field will be hyperlinked to the latter. This involves changes to both the executable and the XSL stylesheet of the base theme. The purpose of this change is to better facilitate daily notes / journaling.
Additionally, Forester’s data model now allows multiple dates to be assigned to a single tree simultaneously.
Feature. Nix support [00FI]
- November 22, 2023
- Kento Okura
Forester 3.0 comes with a nix flake
for easy integration with nix-based systems. Users of nix can try
forester without installing the ocaml toolchain by running
nix run sourcehut:~jonsterling/ocaml-forester.
To create a development shell with forester and LaTeX dependencies,
create a file named flake.nix with the following content:
{
inputs = {
forester = {
url = "sourcehut:~jonsterling/ocaml-forester";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ self
, flake-utils
, nixpkgs
, forester
}:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
legacyPackages = import forester.legacyPackages.${system};
in
{
devShell =
pkgs.mkShell {
buildInputs = with pkgs; [
forester.packages.${system}.default
texlive.combined.scheme-full
fswatch
];
};
});
}and run nix develop.
The default template now ships with a flake and an envrc. If you created your forest using this template and would like to use direnv, simply copy flake.nix and .envrc to your forest base directory.
Feature. Lightweight templating in forester new [00G7]
- December 2, 2023
- Jon Sterling, Lîm Tsú-thuàn
Forester 3.0 adds a new --template option to the forester new command. Running forester new --template xxx-0001 will create a new tree with the contents of the existing tree xxx-0001.
Feature. Support for randomised tree identifiers in forester new [00GG]
- December 13, 2023
- Jon Sterling, Owen Lynch
The forester new has a new --random flag; when activated, the new tree will be allocated with a randomised unused tree identifier rather than the usual sequential tree identifier. This can be useful for projects that have multiple collaborators, although in this case, users are generally advised to claim their own namespaces.
Feature. Custom static assets directories [00GL]
- December 15, 2023
- Jon Sterling
A new --assets-dirs option has been added to the forester build command, which can be used to supply multiple directories containing static assets that should be copied into the forest. By default, the option is set to assets.
Breaking changes [00CY]
- November 3, 2023
- Jon Sterling
Forester 3.0 introduces a number of breaking changes to the source language in order to facilitate maintainability, diagnostic support, and extensibility of both the Forester tool and your individual forests.
Change. Fall-through of undefined identifiers [00CZ]
- November 3, 2023
- Jon Sterling
The fall-through for undefined identifiers in XML mode is removed in Forester 3.0: previously when an identifier \foo was undefined, it was possible to write \foo[attr]{value}{body} and have this be rendered in XML to <foo attr="value">body</foo>.
This behavior has been removed, but you can nonetheless write \xml{foo}[attr]{value}{body} to achieve the same. For content that is being rendered by either LaTeX or KaTeX, simple fallthrough (naturally without attributes or arguments) is supported; therefore #{\alpha} will render to \alpha .
Change. Primitive formatting commands [00D0]
- November 3, 2023
- Jon Sterling
As a consequence of the changed fallthrough behavior, several new primitives have been added to the source language, including \p, \em, \strong, \ol, \ul, \li, \blockquote, and \pre.
You can add further commands to your primitives using a combination of \def, \iftex, and \xml.
Release. Forester 2.5 [009Q]
- September 27, 2023
- Jon Sterling
Thanks to Lîm Tsú-thuàn and Vikraman Choudhury for their suggestions and bug reports on the mailing list.
New \iftex command [UM95]
- September 27, 2023
- Jon Sterling
A new \iftex command has been added, following a suggestion of Vikraman Choudhury; this can be used to control the behavior of macros, depending on whether they are being rendered by \LaTeX or by the browser. For example, \iftex{foo}{bar} will become foo when passed to the \LaTeX tool, but will be reated as bar when rendering for the browser.
Overriding taxa [UMS4]
- September 27, 2023
- Jon Sterling
A new fluid binding \transclude/taxon has been added to the transclusion overrides, which can be used to locally change the taxon of a transcluded tree. Thanks to Lîm Tsú-thuàn for implementing this.
Theme and asset directories [NRTU]
- September 27, 2023
- Jon Sterling
In order to support more modular development of forests, a new theme directory is expected to contain all the XSL, CSS, font, etc. assets that pertain to the presentation of your forest; the assets directory is meant to store things like images, PDFs, etc. that pertain to the content of your forest. The simplest way to take advantage of this new feature is to bind your theme directory to a git submodule pointing to the forester-base-theme repository. Your existing forest will still work fine for now even if you do not migrate to the new directory structure. I’m grateful to Armaël Guéneau for conversations that motivated me to make this change.
Release. Forester 2.4 [007M]
- September 22, 2023
- Jon Sterling
Thanks to Masanori Ogino and Harold Carr for their suggestions which have influenced this release. In addition to the major changes detailed below, there are a few minor improvements:
- The evaluator for Markdown-style links
[title](destination)now allowsdestinationto contain expressions other than text, so long as they evaluate to text. - The XML attribute support introduced in Forester 2.3 has been amended so that attributes appear in square brackets, e.g.
\p[class]{myclass}{body} - The
forester newcommand now has a--destoption, which is used to specify the directory in which to deposit the new tree (independently of the--diroption, which specifies the directory to scan for existing trees). Please runforester new --helpfor details.
Feature. Rudimentary support for RSS feeds [007Y]
- August 19, 2023
- Jon Sterling
Each tree generates an RSS feed containing its immediate children; if a tree is located at xxx-NNNN.xml, then the corresponding RSS file will be located at xxx-NNNN.rss.xml. Currently no content is placed in the RSS feed items, but in the future we may add some best-effort plain text linearization of the first paragraph of the tree or something. Feedback on this feature is welcome.
Feature. Wikilinks support [008Z]
- September 13, 2023
- Jon Sterling
This release adds support for “wikilinks” in the form [[destination]]; this will be rendered as a link whose title is given by the title of the tree at address destination. Users are discouraged from using wikilinks heavily, as it is better for your mind to “work a link into a sentence” naturally; but this can be very useful for linking to biographical trees or daily notes.
Change. Breaking changes to XML format [007X]
- August 19, 2023
- Jon Sterling
This release contains several breaking changes to the XML format that can break custom XSLT stylesheets.
- Taxa used to be attributes of
tree, but they are now child elements oftree/frontmatter. Therefore, what previously was written as<tree taxon="lemma"> <frontmatter> <!-- ... --> </frontmatter> <!-- ... --> </tree>is now written as follows:<tree> <frontmatter> <taxon>lemma</taxon> <!-- ... --> </frontmatter> <!-- ... --> </tree> Dates are now stored in machine-readable format. For example, what used to be written
<date>August 16, 2023</date>is now written as follows:<date> <year>2023</year> <month>8</month> <day>16</day> </date>
It is the responsibility of the XSLT stylesheet to format dates appropriately. Thanks to Masanori Ogino for suggesting this change.
- All identifiers in the XML format have been regularized to use snake-case; for instance,
sourcePathis nowsource-pathandshow_headingis nowshow-heading.
Release. Forester 2.3 [006Z]
- August 14, 2023
- Jon Sterling, with contributions from Armaël Guéneau, Riley Shahar
Armaël Guéneau, Riley Shahar, and Jon Sterling contributed code to this major release. Thanks also to Masanori Ogino for feature requests that made it into this release.
This release adds some new features to the command line interface. The original behavior of the forester command is now obtained by calling forester build. Please browse forester --help for more information.
Feature. Create new trees from the command line [0070]
- August 14, 2023
- Jon Sterling
A new command has been added in Forester 2.3 to simplify the creation of new trees with the correct base-36 identifier. If your personal namespace prefix is xxx, you may run the following command to create a new tree in the trees directory:
forester new --dir=trees --prefix=xxx
If the last tree in this directory was xxx-0039, a new tree will be generated at xxx-003A. The new tree will be populated with a correct \date declaration.
Feature. Tree title completion for tool support [0071]
- August 14, 2023
- Jon Sterling
A new forester complete command has been added to search for trees by their title; the purpose of this command is to facilitate external tool support, such as this proof-of-concept completion engine for neovim. Please browse forester complete --help for more information about this command.
Current limitations: the command is currently case sensitive and only searches prefixes; in the future, it would be desirable to support more flexible fuzzy-search.
Thanks to Riley Shahar for implementing this feature.
Feature. Rudimentary support for XML attributes [0072]
- August 14, 2023
- Jon Sterling
When Forester encounters an undefined function, it automatically passes through to the XML output. For instance, if the function \myfun is not defined, then the Forester code \myfun{hello} will render to the XML code <myfun>hello</myfun>. The Forester 2.3 extends this fall-through behavior to support XML attributes.
In particular, if you write \myfun{key1}{value1}{key2}{value2}{hello}, Forester will render the following XML code:
<myfun key1="value1" key2="value2"> hello </myfun>
Thanks to Masanori Ogino for suggesting this feature, and welcome to the Forester community!.
In addition to the major changes above, the following minor changes are included in this release:
- A
titleattribute attribute has been added to the XML output of internal links, in order to facilitate tooltips and other affordances in rendered forests. Thanks to Armaël Guéneau for implementing this feature. - Subdirectories of input directories will now be traversed automatically; note that the tree address model remains flat, and subdirectories are present only for convenience.
- Added a nicer command line interface with
--helpdocumentation. - I have migrated much of the system code to use the experimental Eio library for improved portability.
- The example forest has been removed from the main repository, and moved into a separate template repository.
Release. Forester 2.2 [005V]
- July 17, 2023
- Jon Sterling
Feature. Flexible transclusion options [0067]
- July 20, 2023
- Jon Sterling
This release replaces the old \transclude*, \transclude@ commands with a more flexible transclusion configuration mechanism using the support for fluid binding introduced in Forester 2.1. A basic transclusion with the default options is done in the same way as before:
\transclude{0005}The behavior of transclusion is, however, configurable by several globally allocated fluid bindings as depicted in the table below.
Table. Transclusion options [0069]
| Fluid Binding | Default | Meaning |
|---|---|---|
\transclude/title |
(none) | To override the tree’s title during transclusion. |
\transclude/toc |
true |
Show the tree in the table of contents. |
\transclude/expanded |
true |
Whether the tree is expanded or not. |
\transclude/heading |
true |
If set to false, the tree’s contents will be inlined. |
\transclude/metadata |
false |
Show in a tree’s heading. |
\transclude/numbered |
true |
Whether the tree is displayed with a number or not, transitively on subtrees. |
It is possible to achieve undesirable results by combining these options in undesirable ways; it is up to you to use them correctly.
Example. A configured transclusion [0068]
- July 20, 2023
- Jon Sterling
The following code produces an unnumbered transclusion that nonetheless appears in the table of context, with an overridden title.
\scope{
\put\transclude/title{A short title in context}
\put\transclude/numbered{false}
\transclude{0068}
}Feature. Queries [0066]
- July 20, 2023
- Jon Sterling
This release adds support for generating subsections from transclusions obtained by a query the forest; this can be used to produce topical bibliographies.
Example. A conjunctive query node [006A]
- July 20, 2023
- Jon Sterling
The following code will generate a subsection containing my “featured talks” as collapsed subtrees:
\scope{
\query{
\query/and{
\query/author{jonmsterling}
\query/taxon{reference}
\query/tag{featured}
}
}
}Under the hood, a query node is an “anonymous transclusion” and can therefore be configured using the same options as other transclusions.
A minor change is that the assets directly does not need to be flat anymore.
As always, existing forests can be upgraded by copying forest.xsl and style.css into their assets directory.
Release. Forester 2.1 [005O]
- June 1, 2023
- Jon Sterling
This is a major release that breaks compatibility of the XML format for trees; existing forests can be upgraded by copying forest.xsl and style.css into their assets directory.
- Development mode and edit button. A
--devoption has been added to theforesterexecutable; when this option is enabled, absolute paths will be embedded into tree metadata and an edit button is added to the top of the command palette. - Your own TeX preamble. There is no longer a hardcoded LaTeX preamble used for compiling graphics; instead, you can store your own
.styfiles in theassetsdirectory and import them locally in a specific tree using the new\texpackage{...}frontmatter command. - Fluid binding constructs. Macros in the Forester language have functional semantics, which means that they capture their environment at the time of definition; this differs from the stacks of dynamic scopes that are familiar from the TeX model. This release adds support for fluid bindings via
\alloc, \put, \getin order to simulate this behavior of TeX where desired; a scope can be delimited using\scope{...}. This can be useful for providing flexible configurations to macros. - Tables of contents. Tables of contents are now rendered by the default
forest.xslstylesheet. - LaTeX output. LaTeX output with full bibliography support is now available; this feature is still experimental, and may not work properly with some constructs (e.g. code blocks, etc.).
- Name resolution. The behavior of name resolution was highly erratic in the prior release, and this has been corrected by adopting the yuujinchou library. This change may break trees that depended on the prior behavior.
- Namespaces and hierarchical identifiers. Identifiers in the Forester language are now hierarchical, with components delimited by
/. Namespaces can be created using\namespace\foo{...}, outside which all exported identifiers are prefixed byfoo/. Namespaces can be opened into the current scope using\open\foo.