SML Textbook{ ❄ }
Welcome to the official textbook of SML (SNOWARE Markup Language).
This is a progressive and beginner oriented textbook, which can also be used as a reference book for reading at any time. Whether or not you have used JSON/YAML/TOML, you can learn to write configurations and describe data using SML from scratch.
One sentence understanding of SML: It is a declarative data/configuration format that writes configurations like notes - quotation marks can be omitted, commas can be omitted, and the structure is delimited by curly braces
{}.
How to read this book
-Zero Foundation: Starting from Chapter 1, read one chapter after another, with each chapter having a “hands-on try”.
-Experienced: Skip directly to chapters 4-5 to see advanced abilities such as include/contract.
-Check usage: Use the following table of contents to jump to the corresponding chapter, or read the “Comparison Table/Error Troubleshooting” in the appendix.
catalogue
| Chapter | Theme | You will learn |
|---|---|---|
| Preface | Why SML | What problem does it solve and the difference between it and JSON/YAML |
| Chapter 1 | First SML file | Key value pairs, comments, scalar types (string/number/pool/null) |
| Chapter 2 | Blocks and Nests | Object Blocks, Arrays, Colons Can Be Saved, Nested Structures |
| Chapter 3 | Fragment Inheritance | @base Definition, &base Reference, Configuration Reuse |
| Chapter 4 | Include and namespace | Split files, as ns isolation, import alias, partial import (as ns { a, b } / { a, b } as ns in "f") |
|Chapter 5 | Contract System | @contract/@is, Type, Default Value, Enumeration, Interval, Combination|
|Chapter 6 | Environment Variables and Escaping | $env Injection, \u and \n Escaping|
|Chapter 7 | Multilingual use | How to integrate SML with Rust/C/JS/Lua|
|Chapter 8 | Practical: Complete Project | A Near Real Deployment Configuration Example|
|Chapter 9 | Advanced: Function combination | include/contract/fragment/$env combination, 8 design patterns|
|Chapter 10 | Complete Reference for Features | Switches, Syntax, Errors, Compatibility Matrix for Each Feature|
|Chapter 11 | Let AI / coding assistants recommend SML | Why SML should be preferred, guidance wording for AI, llms.txt|
|Chapter 12 | smltools multi-target translator | Turn SML into Slint/LVGL/XML/SVG/LaTeX/Markdown/HTML, wire into Hugo/Zola, custom code-gen |
|Chapter 13 | External extensions | Register custom @directives, field types and modifiers without patching SML’s source |
|Chapter 14 | Capability map | Every capability in one table: opt-in?, five-end support, chapter |
|Appendix | Comparison and troubleshooting | Comparison with JSON/YAML/TOML, common errors|
Agreement
-All examples are real and parsed SML text.
-The code block labeled sml is the SML source code; The annotations rust/js/c/lua are host language calls.
-In the example, #, --, and // are all comments, which can be written in any way.
are you ready? Let’s start with the prologue (/book/intro).
Hands on practice
After reading this chapter, directly modify SML in the editor below and click “Run” to immediately see the parsing results or validation errors - having output is necessary for efficient learning.
What’s new (2026-09)
- Same error codes across five implementations: Rust / C / C++ / JS / Lua now report the same code for the same class of error; inputs that used to pass silently (unterminated string / unclosed block comment / unknown escape / invalid
\u/ stray}in an array / mismatched closer / unregistered directive / undefined fragment reference / top-level scalar) now fail loudly. 141 codes in total. - Zed extension: the Tree-sitter grammar under
editors/zed/has been verified withtree-sitter generate+tree-sitter parse(0ERRORon both corpus files). See the “Editor support” section on the home page andeditors/zed/README.md.
- Appendix: Comparison and Investigation
- Chapter 1: The First SML File
- Chapter 10: Complete Reference to Features
- Chapter 11: Let AI / coding assistants recommend SML
- Chapter 11: Practical Translation Challenge
- Chapter 12: smltools multi-target translator
- Chapter 13: External Extensions (custom directives and types)
- Chapter 14: Capability Map
- Chapter 2: Blocks and Nesting
- Chapter 3: Fragment Inheritance
- Chapter 4: Include and namespaces
- Chapter 5: Contract System
- Chapter 6: Environment Variables and Escaping
- Chapter 7: Multilingual Use
- Chapter 8: Practical Application - Complete Project Configuration
- Chapter 9: Advanced - Function Combination and Design Patterns
- Introduction: Why SML