Introduction
KScript.Document writes scientific and professional documents: papers, reports, letters and invoices. One script can save the same document as PDF, Word (.docx), LaTeX (.tex), Markdown and HTML. It has LaTeX maths, numbered sections, tables and figures, citations from BibTeX, footnotes and cross-references. The PDF is written by KScript itself, so you don't need TeX, Word or anything else installed.
<KScript.Document template="paper" title="How Gliders Move" author="Ada Lovelace" to="'gliders.pdf'">
<Abstract>A glider returns to its own shape every \( p = 4 \) generations, one cell further on.</Abstract>
<Section title="Introduction">
<Paragraph>The Game of Life [@gardner1970] is played on a square grid. Each cell has **eight neighbours**.</Paragraph>
<Math id="eq-speed">v = \frac{\max(|\Delta x|, |\Delta y|)}{p} \, c</Math>
<Paragraph>Equation [#eq-speed] gives a pattern's speed.</Paragraph>
</Section>
<Bibliography>
<Source id="gardner1970" type="article" author="Martin Gardner" title="Mathematical Games" journal="Scientific American" year="1970" />
</Bibliography>
</KScript.Document>import KScript.Document
Document(template: paper, title: 'How Gliders Move', author: 'Ada Lovelace', to: 'gliders.pdf') {
Abstract "A glider returns to its own shape every \( p = 4 \) generations, one cell further on."
Section(title: 'Introduction') {
Paragraph "The Game of Life [@gardner1970] is played on a square grid. Each cell has **eight neighbours**."
Math(id: 'eq-speed') "v = \frac{\max(|\Delta x|, |\Delta y|)}{p} \, c"
Paragraph "Equation [#eq-speed] gives a pattern's speed."
}
Bibliography {
Source(id: 'gardner1970', type: 'article', author: 'Martin Gardner', title: 'Mathematical Games', journal: "Scientific American", year: 1970)
}
}To get started, import KScript.Document, which brings in Document and the elements that go inside it. Everything inside a Document block is ordinary KScript, so for, if, variables and functions work between the elements: a table can come from data, and a section can repeat for each item of a list.
The samples/documents folder has a full paper, a report, a letter and an invoice. kscript make document starts a new one.