05 Imports, workbooks, projects
One principle everywhere: **behind every rich control is a human-readable text file that the control edits.** The GUI is a view over text, never a second source of truth.
1. use (import)
#~~~ selfscribe
use markdown # a built-in template by name
use ./house-style.self # relative to this file
use ../shared/comments.self
use https://example.com/team.self # only if the host allows remote (off by default)
~~~
- Only the rules block of the imported file is read. Its body is ignored.
- A
useline is expanded in place, in textual order. Later wins (02 §6), so putuselines first if the document should override them.
- Imports may import. Cycles are cut with a diagnostic.
- The import's
slotandtitlestay in that file. Its other settings and variables applyto the importer unless the importer sets them again later. Rules the import puts in its default scope land in the importer's current scope; its named scopes keep their names.
- The engine never does I/O. It joins a relative path with the importing file's directory
into a canonical
/-separated key (the main document's key is thepathoption) and asks the hostresolver(key) -> string | null. The CLI resolves from disk, the web app from the File System Access handle or a zip, the edge worker from a bundle or KV. Remotescheme://imports reach the resolver only if the host setsallow_remote. - Built-in template names (
markdown,bbcode,comments,form,plain,workbook,data)resolve to files compiled into the engine, without the resolver.
- Any other bare name is a library rulebook: the host's saved rulebooks, asked for as
the key
lib:NAME(D72).use my-notesworks likeuse markdownonce the user has saved a rulebook calledmy-notes. Built-in names cannot be shadowed. The editor answerslib:NAMEfrom the open folder'sblocks/NAME.selffirst (page blocks, D231).
2. Levels of rules
#| Level | Where it lives | Applies to |
| Built-in default | engine | any file with no rules block (markdown) |
| Project default | selfscribe.self at the project root (or nearest ancestor folder) | every file under that folder that does not set project off |
| Workbook default | the workbook's workbook.self | every document in the workbook |
| Document | its own rules block | that document |
| Region | @scope | those lines |
Each level overrides the one above by the same rule-replacement mechanism. The inspector shows the full chain with origins.
The host passes project and workbook defaults as defaults: [{key, level}]. When present
(and the document does not set project off) they are applied first, as if by use, and
they replace the built-in default: a file with no rules block then gets only the
defaults, so a project file normally starts with use markdown.
3. Workbook
#A workbook is a folder or a zip with a workbook.self at its root. The file is itself a
Selfscribe document: rules on top, then a body listing the documents. The body uses ordinary
rules, so it stays editable by hand.
~~~ selfscribe
use ./theme.self
line - _ -> doc nest
line # _ -> section fold 1
set title Q3 Planning
~~~
# Planning
- intro.self
- goals.self
- goals/engineering.self
- goals/design.self
# Appendix
- glossary.self
doc and section are plugin targets of the workbook host: doc resolves a path and
records order and nesting; section groups. The editor's workbook panel is a GUI over
exactly this file: drag to reorder rewrites the lines.
Zip workbooks are read with the JS zip reader (fflate) and written back atomically. Gzip single-file workbooks are the same with one entry.
4. Project or workspace
#A project is any folder opened via the File System Access API or the desktop app. Recognised files:
| File | Purpose |
selfscribe.self | project default rules (see §2) |
*.self | documents |
workbook.self in a subfolder | that subfolder is a workbook |
blocks/NAME.self | a page block template: use NAME in any document of the folder reads it (D231) |
.selfscribe/ | editor state only (open tabs, fold state). Safe to delete. Never rules. |
Relative use paths resolve against the importing file. A document can therefore pull
rules from any sibling document, not only from dedicated style files.
5. Overrides in the document
#~~~ selfscribe
use ./house-style.self
off // ! _ # disable one imported rule
line // ! _ -> p.urgent { color: red; background: #fee } # or replace it
set rules hide
~~~