Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

stilo render

stilo render file [-o OUTPUT] [-d] [--strict]

Renders a Texl document: prints its text with every <% %> formula replaced by its value.

Given beam.texl:

<!--{ bek4 : markdown }-->
# Beam check
<% L = 6, q = 12.5 %>
Span <% L %> m, load <% q %> kN/m.
<!--{ mom3 : markdown }-->
Midspan moment: **<% q * L ^ 2 / 8 %> kNm**
stilo render beam.texl
<!--{ bek4 : markdown }-->
# Beam check

Span 6 m, load 12.5 kN/m.
<!--{ mom3 : markdown }-->
Midspan moment: **56.25 kNm**

The cell markers, <!--{ ... }-->, stay in the output. They are HTML comments, so they do not show when the output is read as Markdown or HTML.

A chart is written as an SVG image, <svg ...> followed by its lines, which shows as the chart when the output is read as Markdown or HTML. Equations stay as their LaTeX text.

Arguments and options

ArgumentMeaning
fileThe document to render. A folder or a packed package (.texlz) renders its index.texl.
-o, --output OUTPUTWrites the rendering to this file instead of the terminal. An existing file is replaced.
-d, --debugNumbers the undefined values in the output, and explains each one on standard error.
--strictExits with status 1 if the document returned an undefined value. The output is still written.
stilo render beam.texl -o beam.md

Imports

Relative imports resolve from the document's own folder, as in the editor, and ~ stands for the folder of the document's package (your home folder outside a package). If projects/beam.texl contains:

<% texl.import("../library/steel.texl") ~> (lib -> bind "steel" lib.data) %>

then stilo render projects/beam.texl reads library/steel.texl, wherever you run the command from. Imports into packed packages work as in the editor.

Errors

A formula that cannot be computed does not stop the rendering: it shows as [[Undefined]], and the rest of the document renders. One line on standard error, which is not part of the output, says how many there are. Given report.texl:

<% L = 6, q = "12.5" %>
Moment: <% q * L ^ 2 / 8 %> kNm
stilo render report.texl

Moment: [[Undefined]] kNm
stilo: report.texl: 1 undefined value (use --debug to list them)

With --debug, the output numbers each value, and the same value keeps its number. Standard error explains each one: where it was made, as file:line:column, what went wrong, the source line with a caret under the position, and its causes.

stilo render report.texl --debug

Moment: [[Undefined #1]] kNm
stilo: report.texl: 1 undefined value

#1 report.texl:2:22  cannot divide an undefined value by the number `8`
     Moment: <% q * L ^ 2 / 8 %> kNm
                          ^
     caused by report.texl:2:14: cannot multiply the text `"12.5"` by the number `36`

An error made in an imported document points into that document, and a last line says where the value shows. As in the editor, only a value that a formula returns counts.

Undefined values do not change the exit status, unless you ask for it: --strict exits with status 1 if there are any, which is useful in a script that must not publish a broken document. The output is still written.

Otherwise, stilo render fails (with exit status 1) only when the file itself cannot be read, and says why, or when the output cannot be written.