SelfscribeDownloadOpen the app

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
~~~ 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 use line is expanded in place, in textual order. Later wins (02 §6), so put use

    lines first if the document should override them.

  • Imports may import. Cycles are cut with a diagnostic.
  • The import's slot and title stay in that file. Its other settings and variables apply

    to 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 the path option) and asks the host resolver(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. Remote scheme:// imports reach the resolver only if the host sets allow_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-notes works like use markdown once the user has saved a rulebook called my-notes. Built-in names cannot be shadowed. The editor answers lib:NAME from the open folder's blocks/NAME.self first (page blocks, D231).

2. Levels of rules

#
LevelWhere it livesApplies to
Built-in defaultengineany file with no rules block (markdown)
Project defaultselfscribe.self at the project root (or nearest ancestor folder)every file under that folder that does not set project off
Workbook defaultthe workbook's workbook.selfevery document in the workbook
Documentits own rules blockthat document
Region@scopethose 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
~~~ 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:

FilePurpose
selfscribe.selfproject default rules (see §2)
*.selfdocuments
workbook.self in a subfolderthat subfolder is a workbook
blocks/NAME.selfa 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
~~~ selfscribe
use ./house-style.self
off  // ! _                         # disable one imported rule
line // ! _  -> p.urgent { color: red; background: #fee }   # or replace it
set  rules hide
~~~