结构
<KScript.Document template="report" title="Annual Report" author="The team" to="'report.pdf'">
<Contents />
<Section title="Summary" id="summary">
<Paragraph>Visits rose every quarter.</Paragraph>
<Section title="Details">
<List style="number">
<Item>First point.</Item>
<Item>Second point.</Item>
<List>
<Item>A point under the second.</Item>
</List>
</List>
</Section>
</Section>
<Section title="Appendix" numbered="false" new_page="true">
<Quote by="John Conway">I'm not a mathematician who's interested in applications.</Quote>
<Code language="python">print('hello')</Code>
</Section>
</KScript.Document>import KScript.Document
Document(template: report, title: 'Annual Report', author: 'The team', to: 'report.pdf') {
Contents
Section(title: 'Summary', id: 'summary') {
Paragraph "Visits rose every quarter."
Section(title: 'Details') {
List(style: number) {
Item "First point."
Item "Second point."
List {
Item "A point under the second."
}
}
}
}
Section(title: 'Appendix', numbered: false, new_page: true) {
Quote(by: 'John Conway') "I'm not a mathematician who's interested in applications."
Code(language: 'python') "print('hello')"
}
}| 元素 | 它是什么 |
|---|---|
Author(affiliation, email) |
作者。其文本即为姓名。也可以在文档上设置 author: "Ada Lovelace; Alan Turing"。 |
Abstract |
标题下方的摘要。 |
Section(title, id, numbered, new_page) |
章节。章节内的章节即为子章节,最多六级;第七级会报错。 |
Paragraph(id, align, lines) |
段落。 |
List(style, start) 和 Item |
列表:bullet、number、letter 或 roman。紧跟在 Item 之后的 List 会嵌套在该项中。 |
Quote(by) |
块引用。 |
Code(language) |
代码,使用等宽字体,保持原样。 |
Contents(title, depth) |
目录;在 PDF 中包含页码。 |
Markdown(path) |
从文本或文件生成 Markdown:见下文。 |
Latex(path, value) |
从文本、latex 值或 .tex 文件生成 LaTeX:见下文。 |
PageBreak, VSpace(height), Rule |
分页、VSpace(height: '1cm') 之类的间距,以及跨页的横线。 |