Commit2ec9df95Recorded22 Aug 2026Repositorysigil-doc
feat: execute D8 -- generic base language, book genre as a sibling language
Message
Ruling D8 (David, 2026-08-22): the base language commits to one generic root and genres are languages, not extra roots in the base.
#lang sigil/docadmits exactly one@article, with anarticleauthor binding sharing@chapter's body so the legacy leading-string author path cannot drift between them.#lang sigil/doc/bookis new:src/sigil/doc/book/reader.sgl, a profile plus the documented convenience reader. It admits exactly one@chapterand owns the book/print genre, which is wheremake-print-publicationalready lives.- Document kind
bookis dropped. It was constructed nowhere in this package or in folio, and a book is an assembly rather than a document kind.articlestays: folio's publication lowering targets it. - Corpus migrated. Population = 23 files whose first line is
#lang sigil/doc; 19@chapter-rooted manuscripts move to#lang sigil/doc/bookby a header edit alone, 1 base-language fixture keeps its header and takes an@articleroot, 3 are unaffected.
The root-policy diagnostics are derived from the profile, so both languages' messages followed the root sets with no formatter edit. Their pinned literals moved with them and each is shown able to fail in test/sabotage-sd-p8.sh.
Two suites had @chapter manuscripts driven through the three-argument default-profile entry points; they now write @article. That spelling is the same length, so every location assertion and the pinned pre-SD-P1 classification transcript's three positive controls stay byte-identical.
Changed
README.md | 23 +++++++------
book/practical-sigil/01-useful-first-script.sgd | 2 +-
book/practical-sigil/02-change-the-question.sgd | 2 +-
docs/root-profiles.md | 82 +++++++++++++++++++++++++++++++++++++++-------
src/sigil/doc/author.sgl | 22 +++++++++++--
src/sigil/doc/book/reader.sgl | 45 ++++++++++++++++++++++++++
src/sigil/doc/model.sgl | 8 ++++-
src/sigil/doc/private/parser.sgl | 24 +++++++++++---
test/fixtures/d3-adversarial.sgd | 2 +-
test/fixtures/d3-backend-mismatch.sgd | 2 +-
test/fixtures/d3-duplicate.sgd | 2 +-
test/fixtures/d3-empty.sgd | 2 +-
test/fixtures/d3-examples.sgd | 2 +-
test/fixtures/glossary-lesson.sgd | 2 +-
test/fixtures/glossary-page.sgd | 2 +-
test/fixtures/minimal.sgd | 2 +-
test/fixtures/practical-sigil-change-question.sgd | 2 +-
test/fixtures/practical-sigil-chapter.sgd | 2 +-
test/fixtures/sd-manuscript-keyword-define.sgd | 2 +-
test/fixtures/sd-p1-article-root.sgd | 19 +++++------
test/fixtures/sd-p3-bare-prose.sgd | 2 +-
test/fixtures/sd-p3-wrapped.sgd | 2 +-
test/fixtures/sd-p4-collision.sgd | 2 +-
test/fixtures/sd-p4-witness.sgd | 2 +-
test/fixtures/sd-p7-sigil-doc-section.sgd | 2 +-
test/fixtures/semantic-structures.sgd | 2 +-
test/fixtures/url-links.sgd | 2 +-
test/sd-p1-classification-probe.sgl | 14 ++++----
test/test-passive-parse.sgl | 2 +-
test/test-prose-runs.sgl | 22 ++++++-------
test/test-reader.sgl | 68 +++++++++++++++++++-------------------
test/test-root-profile.sgl | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------
32 files changed, 424 insertions(+), 198 deletions(-)Diff
README.mdmodified
@@ -9,14 +9,14 @@ ordinary Sigil program with a prose-oriented reader:
9
@(define-syntax strong 10
(syntax-rules () ((_ child) (em child)))) 11
−12
@chapter ["A Small Document" "An Author"]+12
@article ["A Small Document" "An Author"] 13
14
@section ["First Section"] 15
16
@p: Prose can contain @strong{ordinary author macros}. 17
18
@end section−19
@end chapter+19
@end article 20
``` 21
22
Commands are ordinary imported or manuscript-local bindings. Everything in@@ -98,10 +98,15 @@ sigil -L src -L test eval -f test/sd-p4-witness-probe.sgl
98
See [`docs/passive-parse-api.md`](docs/passive-parse-api.md) for the node and 99
span representation, the guarantees, and the explicit non-guarantees. 100
−101
## Parameterizing the root container+101
## The root container, and the two languages 102
−103
`#lang sigil/doc` admits exactly one `@chapter` at top level. That policy is a−104
value rather than a constant, so a delegating language can name its own roots+103
`#lang sigil/doc` admits exactly one `@article` at top level — the generic standalone+104
document. The book/print genre is a sibling language, `#lang sigil/doc/book`, which admits+105
exactly one `@chapter`. That is ruling D8: the base language stays generic, and genres are+106
languages rather than extra roots in the base.+107
+108
Root policy is a value rather than a constant, so both of those languages are the same+109
parser with a different profile, and a language in another package can name its own roots 110
without forking the grammar or the location machinery: 111
112
```sigil@@ -111,7 +116,7 @@ without forking the grammar or the location machinery:
116
(parse-document-parts-with-profile folio-profile source source-name header-end) 117
``` 118
−114
`sigil/doc`'s own behaviour, including both root diagnostics, is unchanged. See−115
[`docs/root-profiles.md`](docs/root-profiles.md) for the profile fields, what a−116
profile deliberately does *not* vary, and how `article`/`book` documents become−117
reachable from source.+119
The root-policy diagnostics are derived from the profile, so each language reports its own+120
name and its own roots. See [`docs/root-profiles.md`](docs/root-profiles.md) for the+121
profile fields, the two shipped languages, what a profile deliberately does *not* vary,+122
and why the root comes from the `#lang` line rather than from an import.book/practical-sigil/01-useful-first-script.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["A Useful First Script" authors: '("David Wilson")] 3
4
@section["Begin with a Question" id: "first-script"]book/practical-sigil/02-change-the-question.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Change the Question" authors: '("David Wilson")] 3
4
@section["Turn a Script into a Tool" id: "script-into-tool"]docs/root-profiles.mdmodified
@@ -5,7 +5,15 @@ document root. SD-P1 makes the root-command set *and its multiplicity* a paramet
5
the reader, so a delegating language can deliver its own roots without forking the 6
grammar. 7
−8
`sigil/doc`'s own behaviour is unchanged, including both diagnostics, byte for byte.+8
**SD-P8 then used that parameter on `sigil/doc` itself** (ruling D8, 2026-08-22): the base+9
language is generic and genres are languages. `#lang sigil/doc` admits exactly one+10
`@article`; `@chapter` moved to the sibling genre language `#lang sigil/doc/book`. See+11
[Two shipped languages](#two-shipped-languages) below.+12
+13
The two root-policy diagnostics are DERIVED from the profile, so a language's messages+14
follow its root set with no second copy to keep in step. SD-P8 is the first change to+15
exercise that: moving the base root set reworded both of its messages without touching+16
the formatter. 17
18
## What a profile is 19
@@ -21,8 +29,8 @@ grammar.
29
| `roots` | non-empty list of distinct command-name symbols legal at top level | 30
| `multiplicity` | `'one` or `'one-or-more` | 31
−24
The built-in `sigil-doc-profile` is `("sigil/doc" (chapter) one)` — the historical policy,−25
spelled as a value.+32
The built-in `sigil-doc-profile` is `("sigil/doc" (article) one)`, and the genre profile+33
`sigil-doc-book-profile` in `(sigil doc book reader)` is `("sigil/doc/book" (chapter) one)`. 34
35
Everything is validated **at construction**, not at parse time: an empty root set, a 36
non-symbol root, a duplicate root, an unknown multiplicity, or an empty name all raise@@ -77,17 +85,67 @@ the complete grammar and every location here, change only the vocabulary and the
85
did; it reports what a manuscript declares. See `docs/passive-parse-api.md`. 86
- **Anything about `@` scanning, bodies, escapes, or locations.** 87
−80
## Reachable model kinds+88
## Two shipped languages+89
+90
sigil-doc ships the base plus the genres it owns. Today that is two languages, and they+91
differ **only** in their root profile.+92
+93
| `#lang` | module | root set | multiplicity | what it is for |+94
| --- | --- | --- | --- | --- |+95
| `sigil/doc` | `(sigil doc reader)` | `(article)` | `one` | the generic standalone document — README, design doc, spec, memo, blog post |+96
| `sigil/doc/book` | `(sigil doc book reader)` | `(chapter)` | `one` | the book/print genre; one manuscript is one chapter |+97
+98
The whole of the genre language is a profile and a two-line reader: 99
−82
The semantic model has always had `article`, `book`, and `chapter` document kinds, but−83
only `chapter` was producible from source. With the root set a parameter, a profile whose−84
roots name `article` or `book` produces those kinds from a manuscript —−85
`test/fixtures/sd-p1-article-root.sgd` does exactly that.+100
```sigil+101
(define-library (sigil doc book reader)+102
(import (sigil core) (sigil doc reader))+103
(export read-language-source sigil-doc-book-profile)+104
(begin+105
(define sigil-doc-book-profile+106
(make-document-profile "sigil/doc/book" '(chapter) 'one))+107
(define (read-language-source source context)+108
(read-language-source-with-profile sigil-doc-book-profile source context))))+109
```+110
+111
`#lang a/b/c` resolves to the module `(a b c reader)`, which is why a multi-segment+112
language id needs nothing special from the reader.+113
+114
**Why `@chapter` is not a base root.** A chapter is a *part* of an assembly, and the+115
assembly lives in this package too — `make-print-publication` in `(sigil doc publication)`,+116
driven by a module such as `book/practical-sigil/book.sgl`. The language that hands you+117
`@chapter` should be the one that owns book assembly. While `@chapter` was the base's only+118
root, the base's most common root was a fragment of a workflow the base does not contain,+119
and every standalone document had to call itself a chapter.+120
+121
**Why the root comes from `#lang` and not from an import.** Everything *below* the root is+122
already import-extensible: an author command is an ordinary binding and a manuscript can+123
`@(import …)` more of them. The root is different in kind — it is the document's *type*,+124
the first fact a tool wants, and root policy is enforced at parse time from nothing but+125
the source text. Making roots importable would either drag module resolution into the+126
reader (so what a document *is* depends on installed package state, and an indexer whose+127
normal case is scanning files it will reject could no longer classify one) or abolish root+128
policy altogether, retiring the diagnostic that catches an empty or truncated file. So:+129
**imports extend what a document can say; the `#lang` line declares what a document is.**+130
+131
**Where a new genre goes.** With its product owner, not here. `#lang folio/doc` is the+132
proof that a package outside sigil-doc can own a genre: it constructs its own profile,+133
delegates the complete grammar to `(sigil doc reader)`, and ships its own reader module.+134
sigil-doc ships `book` because Practical Sigil and print publication live here.+135
+136
## Reachable model kinds 137
−87
`#lang sigil/doc`'s own default root set is **unchanged** and still admits only−88
`@chapter`. Whether it should widen is a product decision about the language rather than−89
a parser question; it is recorded as an open numbered decision in the sigil-doc−90
implementation plan.+138
The semantic model has two document kinds, `article` and `chapter`, and both are now+139
producible from source by a shipped language. `book` was a third; SD-P8 removed it,+140
because it was constructed nowhere in this package or in folio and a book is an+141
*assembly* (`make-print-publication`) rather than a document kind. `make-document` now+142
refuses it by name: `kind must be article or chapter`.+143
+144
Note the boundary, which D8 fixed deliberately: root **commands** are the profile's+145
vocabulary and document **kinds** are the model's. A profile may name any command symbol;+146
what that command constructs is the model's business. A genre needing genuinely new+147
semantics follows folio's pattern — its own records, lowered to core kinds for+148
publication — rather than a new core kind. 149
150
## `@text{}` and `@expr{}` are ordinary commands 151
src/sigil/doc/author.sglmodified
@@ -1,6 +1,6 @@
1
(define-library (sigil doc author) 2
(import (sigil core) (sigil doc model) (sigil doc private author-runtime))−3
(export chapter section p text em code admonition aside warning+3
(export article chapter section p text em code admonition aside warning 4
items item table row cell video term term-ref glossary 5
exercise example project-check anchor ref url author-location author-flatten) 6
(begin@@ -21,11 +21,27 @@
21
(if (and (pair? xs) (string? (car xs))) 22
(loop (cdr xs) (cons (car xs) out)) 23
(list (reverse out) xs))))−24
(define (chapter title (keys: (authors #f)) (rest: values))+24
;; SD-P8 (D8 ruling, 2026-08-22). `@article` and `@chapter` are the same+25
;; command with a different kind, so they share one body: a second spelling+26
;; is a second thing to drift, and the legacy leading-string author path+27
;; below is exactly the kind of detail that would drift. The COMMAND NAME+28
;; passed to `children` is the kind's own symbol, so a flattening+29
;; diagnostic names the command the author actually wrote.+30
;;+31
;; Which of the two a manuscript may use at top level is decided by the+32
;; `#lang` profile, not here: `#lang sigil/doc` admits `@article`,+33
;; `#lang sigil/doc/book` admits `@chapter`. Both bindings stay visible in+34
;; both languages because a genre language reuses this whole module -- the+35
;; root POLICY is the parser's, and it runs before any of this evaluates.+36
(define (root-document kind title authors values) 37
(let* ((legacy (and (not authors) (split-legacy-authors values))) 38
(actual-authors (or authors (car legacy))) 39
(body (if legacy (cadr legacy) values)))−28
(make-document 'chapter title actual-authors (children 'chapter body) (author-location))))+40
(make-document kind title actual-authors (children kind body) (author-location))))+41
(define (article title (keys: (authors #f)) (rest: values))+42
(root-document 'article title authors values))+43
(define (chapter title (keys: (authors #f)) (rest: values))+44
(root-document 'chapter title authors values)) 45
;; SD-P7. `@section` asks the AMBIENT content profile rather than calling 46
;; the four-argument `make-section`, so a delegating language reuses this 47
;; command unchanged and its work items become legal section children. Undersrc/sigil/doc/book/reader.sgladded
@@ -0,0 +1,45 @@
+1
;;; (sigil doc book reader) -- the `#lang sigil/doc/book` entry point.+2
;;;+3
;;; SD-P8, executing the D8 ruling (David, 2026-08-22): GENERIC BASE, GENRES+4
;;; ARE LANGUAGES. `#lang sigil/doc` commits to one generic root, `@article`.+5
;;; The book/print genre lives here, and this module is the whole of it: one+6
;;; root profile naming `@chapter`, exactly one of it.+7
;;;+8
;;; WHY A CHAPTER IS NOT A BASE ROOT. A chapter is a PART of an assembly, not+9
;;; a document anyone writes standalone -- and the assembly it is a part of+10
;;; lives in this package too (`make-print-publication` in+11
;;; `(sigil doc publication)`, driven by a module like+12
;;; `book/practical-sigil/book.sgl`). The language that hands you `@chapter`+13
;;; is therefore the one that owns book assembly. Leaving `@chapter` in the+14
;;; base made the base's most common root a fragment of a workflow the base+15
;;; does not contain, and forced every standalone document -- README, design+16
;;; doc, memo, spec -- to call itself a chapter.+17
;;;+18
;;; WHY IT IS `sigil/doc/book` AND NOT `sigil/book`. David's ruling, same day:+19
;;; "(sigil doc book) feels better even if it implies sigil/doc/book, a+20
;;; clumsier but more accurate path." It keeps the genre inside the+21
;;; `(sigil doc *)` namespace this package already owns. `#lang a/b/c`+22
;;; resolves to the module `(a b c reader)`; multi-segment language ids were+23
;;; probed working before the ruling was taken.+24
;;;+25
;;; WHY IT IS THIS SHORT. `read-language-source-with-profile` is+26
;;; `(sigil doc reader)`'s documented convenience path for exactly this case:+27
;;; a language that keeps the sigil/doc author vocabulary and varies only the+28
;;; root container. A genre that needed a DIFFERENT author environment would+29
;;; instead call `parse-document-parts-with-profile` and assemble its own+30
;;; prelude, which is what `#lang folio/doc` does. This one does not, so+31
;;; writing out a second prelude would only create a second thing to drift.+32
;;; `@chapter` itself is unchanged and still comes from `(sigil doc author)`.+33
;;; See `docs/root-profiles.md`.+34
(define-library (sigil doc book reader)+35
(import (sigil core) (sigil doc reader))+36
(export read-language-source sigil-doc-book-profile)+37
(begin+38
;; The genre's whole contract. `'one`, not `'one-or-more`: a manuscript is+39
;; one chapter, and the multiplicity is what makes a second `@chapter` in+40
;; one file a diagnostic rather than a silently dropped root.+41
(define sigil-doc-book-profile+42
(make-document-profile "sigil/doc/book" '(chapter) 'one))+43
+44
(define (read-language-source source context)+45
(read-language-source-with-profile sigil-doc-book-profile source context))))src/sigil/doc/model.sglmodified
@@ -250,7 +250,13 @@
250
((exercise? node) (any contains-term-declaration? (exercise-children node))) 251
(else #f))) 252
(define (make-document kind title authors children loc)−253
(if (not (memq kind '(article book chapter))) (fail "make-document" "kind must be article, book, or chapter")+253
;; SD-P8 (D8 ruling, 2026-08-22). `book` was dropped: it was constructed+254
;; nowhere in this package or in folio, and a book is an ASSEMBLY --+255
;; `make-print-publication` in `(sigil doc publication)` -- not a document+256
;; kind. `article` is NOT dead and must stay: folio's `publication.sgl`+257
;; lowers a `note`/`project` root to a document of kind `article`, and it+258
;; is now the root `#lang sigil/doc` itself admits.+259
(if (not (memq kind '(article chapter))) (fail "make-document" "kind must be article or chapter") 260
(if (not (nonempty-string? title)) (fail "make-document" "title must be nonempty") 261
(if (or (not (proper-list? authors)) (not (every nonempty-string? authors))) (fail "make-document" "authors must be nonempty strings") 262
(doc-record kind: kind title: (string-copy title) authors: (copy-strings authors) children: (copy-list (require-block "make-document" children #f)) location: (require-location "make-document" loc))))))src/sigil/doc/private/parser.sglmodified
@@ -91,13 +91,27 @@
91
(define (document-profile-multiplicity profile) 92
(document-profile-record-multiplicity profile)) 93
−94
;; `sigil/doc`'s own profile: exactly today's policy, spelled as a value.−95
(define sigil-doc-profile (make-document-profile "sigil/doc" '(chapter) 'one))+94
;; `sigil/doc`'s own profile.+95
;;+96
;; SD-P8 (D8 ruling, 2026-08-22): the BASE language is GENERIC and GENRES+97
;; ARE LANGUAGES. `#lang sigil/doc` admits exactly one `@article` -- the+98
;; standalone document: README, design doc, memo, spec, blog post -- and+99
;; `@chapter`, which is a PART of a book rather than a document anyone+100
;; writes standalone, moved to the sibling genre language+101
;; `#lang sigil/doc/book` (`src/sigil/doc/book/reader.sgl`).+102
;;+103
;; Roots come only from the `#lang` profile: the header line is the import+104
;; statement for the root vocabulary, readable without evaluating anything,+105
;; which is what keeps a document's TYPE statically inspectable.+106
(define sigil-doc-profile (make-document-profile "sigil/doc" '(article) 'one)) 107
108
;; The two root-policy diagnostics are DERIVED from the profile rather than−98
;; written twice. That is what keeps the default byte-identical: with−99
;; `sigil-doc-profile` these render exactly the two strings this parser has−100
;; always raised, and a test pins both literals.+109
;; written twice, so a profile change reaches its own error messages with no+110
;; second copy to forget. SD-P8 is the first change to exercise that: moving+111
;; the base root set from `chapter` to `article` reworded both messages with+112
;; no edit here. A test pins both literals for the base AND for+113
;; `sigil/doc/book`, so the formatter cannot quietly reword a shipped+114
;; diagnostic -- and each pinned literal is shown able to fail. 115
(define (profile-root-names roots) 116
(let ((n (length roots))) 117
(condtest/fixtures/d3-adversarial.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["D3 Adversarial Controls" authors: '("David Wilson")]{ 3
@example["fake-exit" expect-error: "error: expected boom" timeout: 15]{ 4
@code["sigil"]{(begintest/fixtures/d3-backend-mismatch.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Backend Mismatch" authors: '("David Wilson")]{ 3
@project-check["d3-project" root: "d3-project-native" 4
files: '("package.sgl" "src/d3-project/main.sgl")test/fixtures/d3-duplicate.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Duplicate Examples" authors: '("David Wilson")]{ 3
@example["same" expect-value: "1"]{@code["sigil"]{1}} 4
@example["same" expect-value: "2"]{@code["sigil"]{2}}test/fixtures/d3-empty.sgdmodified
@@ -1,2 +1,2 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["No Examples" authors: '("David Wilson")]{@p{Passive only.}}test/fixtures/d3-examples.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Executable Examples" authors: '("David Wilson")]{ 3
@example["stdout" expect-stdout: "hello\n" timeout: 30]{ 4
@code["sigil"]{(display "hello\n")}test/fixtures/glossary-lesson.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Bindings and Environments"] 3
4
@p {test/fixtures/glossary-page.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Glossary of Terms"] 3
4
@(glossary)test/fixtures/minimal.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Minimal" authors: '("David Wilson")]{ 3
@anchor["start"]{} 4
@section["Hello" id: "hello"]{test/fixtures/practical-sigil-change-question.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Change the Question" authors: '("David Wilson")] 3
4
@section["Turn a Script into a Tool" id: "script-into-tool"]test/fixtures/practical-sigil-chapter.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@(import (fixtures practical-author-support)) 3
@(define tip-calls 0) 4
@(define (tip body)test/fixtures/sd-manuscript-keyword-define.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@(define (callout title (keys: (kind "note")) (rest: body)) 3
(make-admonition 'tip 4
(list (make-text (string-append kind ": " title) (author-location)))test/fixtures/sd-p1-article-root.sgdmodified
@@ -1,14 +1,15 @@
1
#lang sigil/doc−2
@(define (article title . body)−3
(make-document 'article title (list "SD-P1")−4
(author-flatten body (author-location) 'article)−5
(author-location)))−6
2
@article["An Article Root"]{ 3
@section["Reachable" id: "reachable"]{−9
@p{The model's @code{article} kind has been unreachable from source since D0,−10
because the reader admitted only @code{@@chapter}. It is reachable here through−11
a profile whose root set names @code{@@article}, with no change to the default−12
@code{sigil/doc} profile and no new binding in @code{(sigil doc author)}.}+4
@p{The model's @code{article} kind was unreachable from source until SD-P1 made+5
the root container a profile parameter, and until SD-P8 executed ruling D8 this+6
fixture had to define its own @code{@@article} command and be driven through a+7
hand-built profile to reach it.}+8
+9
@p{Neither is needed now. @code{@@article} is a shipped binding in+10
@code{(sigil doc author)} and it is the one root @code{#lang sigil/doc} admits,+11
so this manuscript is an ordinary document in the base language and the file+12
you are reading is what an author writes. The book genre moved to+13
@code{#lang sigil/doc/book}.} 14
} 15
}test/fixtures/sd-p3-bare-prose.sgdmodified
@@ -1,5 +1,5 @@
1
#lang sigil/doc−2
@chapter["Runs" authors: '("David Wilson")]{+2
@article["Runs" authors: '("David Wilson")]{ 3
@section["Inline" id: "inline"]{ 4
A naïve paragraph mentioning @code{define} and @ref["inline"]{this section} with @em{emphasis} in a café. 5
test/fixtures/sd-p3-wrapped.sgdmodified
@@ -1,5 +1,5 @@
1
#lang sigil/doc−2
@chapter["Runs" authors: '("David Wilson")]{+2
@article["Runs" authors: '("David Wilson")]{ 3
@section["Inline" id: "inline"]{ 4
@p{A naïve paragraph mentioning @code{define} and @ref["inline"]{this section} with @em{emphasis} in a café.} 5
test/fixtures/sd-p4-collision.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@(define support-binding 1) 3
@chapter["Passive Surface Pressure" authors: '("SD-P4")] 4
test/fixtures/sd-p4-witness.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@(display "SDP4-WITNESS-AUTHOR-EXPRESSION-RAN\n") 3
@(define (marked-paragraph . body) 4
;; A command at block position receives already-lowered block children, sotest/fixtures/sd-p7-sigil-doc-section.sgdmodified
@@ -1,6 +1,6 @@
1
#lang sigil/doc 2
@(define (task title . body) (vector 'foreign-task title body))−3
@chapter["Default unchanged" "SD-P7"]{+3
@article["Default unchanged" "SD-P7"]{ 4
@section["Tasks" id: "tasks"]{ 5
6
@p{Plain @code{sigil/doc}, no profile anywhere. This paragraph is the legaltest/fixtures/semantic-structures.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Semantic Structures" authors: '("Course Author")] 3
4
@itemstest/fixtures/url-links.sgdmodified
@@ -1,4 +1,4 @@
−1
#lang sigil/doc+1
#lang sigil/doc/book 2
@chapter["Links That Leave the Publication" authors: '("David Wilson")]{ 3
@section["Course Links" id: "course-links"]{ 4
@p{test/sd-p1-classification-probe.sglmodified
@@ -84,36 +84,36 @@
84
;; the head symbol and runs `paragraph-ranges` over the command's own source. 85
(report "C-text-command-at-block-position" 86
(lower-and-render−87
"#lang sigil/doc\n@chapter[\"C\" \"A\"]{\n@text{a text command}\n}" "c.sgd"))+87
"#lang sigil/doc\n@article[\"C\" \"A\"]{\n@text{a text command}\n}" "c.sgd")) 88
89
;; D. `@expr{...}` at BLOCK position inside a chapter. 90
(report "D-expr-command-at-block-position" 91
(lower-and-render−92
"#lang sigil/doc\n@chapter[\"D\" \"A\"]{\n@expr{an expr command}\n}" "d.sgd"))+92
"#lang sigil/doc\n@article[\"D\" \"A\"]{\n@expr{an expr command}\n}" "d.sgd")) 93
94
;; E. `@text{...}` at INLINE position inside a paragraph. 95
(report "E-text-command-inline" 96
(lower-and-render−97
"#lang sigil/doc\n@chapter[\"E\" \"A\"]{@p{before @text{inline text} after}}" "e.sgd"))+97
"#lang sigil/doc\n@article[\"E\" \"A\"]{@p{before @text{inline text} after}}" "e.sgd")) 98
99
;; I. `@text{...}` inside an INLINE `@code{...}` body. `inline-code-content` 100
;; concatenates `caddr` of each child; for a five-slot text node that is a 101
;; STRING, but for a six-slot command it is the child LIST. 102
(report "I-text-command-inside-inline-code" 103
(lower-and-render−104
"#lang sigil/doc\n@chapter[\"I\" \"A\"]{@p{@code{@text{x}}}}" "i.sgd"))+104
"#lang sigil/doc\n@article[\"I\" \"A\"]{@p{@code{@text{x}}}}" "i.sgd")) 105
106
;; F. POSITIVE CONTROL -- an ordinary inline command with no name collision. 107
;; This must render identically before and after the change. 108
(report "F-control-em-inline" 109
(lower-and-render−110
"#lang sigil/doc\n@chapter[\"F\" \"A\"]{@p{before @em{emphasis} after}}" "f.sgd"))+110
"#lang sigil/doc\n@article[\"F\" \"A\"]{@p{before @em{emphasis} after}}" "f.sgd")) 111
112
;; G. POSITIVE CONTROL -- ordinary prose at block position, which is a genuine 113
;; five-slot `text` pseudo-node and must keep lowering to a paragraph. 114
(report "G-control-bare-prose-block" 115
(lower-and-render−116
"#lang sigil/doc\n@chapter[\"G\" \"A\"]{\nbare prose paragraph\n}" "g.sgd"))+116
"#lang sigil/doc\n@article[\"G\" \"A\"]{\nbare prose paragraph\n}" "g.sgd")) 117
118
;; H. POSITIVE CONTROL -- a genuine top-level `@(...)` author expression, which 119
;; is a five-slot `expr` pseudo-node and must still be hoisted as a form.@@ -126,7 +126,7 @@
126
"OK: forms=" 127
(number->string 128
(length (parse-document-forms−129
"#lang sigil/doc\n@(define x 1)\n@chapter[\"H\" \"A\"]{@p{body}}"+129
"#lang sigil/doc\n@(define x 1)\n@article[\"H\" \"A\"]{@p{body}}" 130
"h.sgd" 16))))))) 131
132
(display "SD_P1_CLASSIFICATION_PROBE_COMPLETE 9 cases")test/test-passive-parse.sglmodified
@@ -419,7 +419,7 @@
419
;; lowering parse of a third manuscript runs in between as well. 420
(alpha-first (summary (inspect-document-source alpha "alpha.sgd" 16))) 421
(beta-middle (summary (inspect-document-source beta "beta.sgd" 16)))−422
(_lowered (parse-document-source "#lang sigil/doc\n@chapter[\"Gamma\" \"C\"]{@p{z}}" "gamma.sgd" 16))+422
(_lowered (parse-document-source "#lang sigil/doc\n@article[\"Gamma\" \"C\"]{@p{z}}" "gamma.sgd" 16)) 423
(alpha-again (summary (inspect-document-source alpha "alpha.sgd" 16)))) 424
(assert-equal alpha-alone alpha-first) 425
(assert-equal alpha-alone alpha-again)test/test-prose-runs.sglmodified
@@ -231,7 +231,7 @@
231
;; Folding it INTO a paragraph would nest a paragraph in a paragraph. The 232
;; run's values decide, and one block value means "hand it back unchanged". 233
(let* ((doc (eval-document−234
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+234
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 235
"@aside{@p{Remember @code{Sigil}.}}\n}") 236
"splice.sgd")) 237
(admonition (car (document-children doc))))@@ -251,7 +251,7 @@
251
(let ((message 252
(guard (exn (else (exception-message exn))) 253
(eval-document−254
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+254
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 255
"@section[\"S\" id: \"s\"]{\n" 256
"Prose then @anchor[\"mid\"]{} then more prose.\n}\n}") 257
"mixed.sgd"))))@@ -273,7 +273,7 @@
273
;; (model.sgl), so a run containing one is all-inline and becomes a 274
;; paragraph rather than a "mixes inline and block content" refusal. 275
(let* ((doc (eval-document−276
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+276
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 277
"@section[\"S\" id: \"s\"]{\n" 278
"See @url[\"https://example.org/a\"]{the spec} and " 279
"@url[\"https://example.org/b\"]{the guide} for more.\n}\n}")@@ -311,12 +311,12 @@
311
(guard (exn (else (exception-message exn))) 312
(eval-document source name))) 313
(let ((bare-message−314
(message-of (string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+314
(message-of (string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 315
"@section[\"S\" id: \"s\"]{\n" 316
"Prose then @aside{a block} then more.\n}\n}") 317
"folded.sgd")) 318
(wrapped-message−319
(message-of (string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+319
(message-of (string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 320
"@section[\"S\" id: \"s\"]{\n" 321
"@p{Prose then @aside{a block} then more.}\n}\n}") 322
"folded-wrapped.sgd")))@@ -331,7 +331,7 @@
331
;; and must stay three siblings, not one paragraph containing an admonition. 332
(test "a block-boundary command between prose lines stays a sibling block" 333
(let* ((doc (eval-document−334
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+334
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 335
"@section[\"S\" id: \"s\"]{\n" 336
"Intro prose.\n@aside{An aside.}\nMore prose.\n}\n}") 337
"boundary.sgd"))@@ -345,7 +345,7 @@
345
346
(test "a blank line still closes a run" 347
(let* ((doc (eval-document−348
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+348
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 349
"@section[\"S\" id: \"s\"]{\n" 350
"One with @code{a}.\n\nTwo with @code{b}.\n}\n}") 351
"blank.sgd"))@@ -364,7 +364,7 @@
364
;; also the body's first AND last child, so `trim-body-edges` has already 365
;; trimmed the node's range before paragraph formation ever sees it, and the 366
;; "the range is untrimmed" property below would be untestable on that shape.−367
(let* ((source (string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+367
(let* ((source (string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 368
"@section[\"S\" id: \"s\"]{\n Plain prose. \n\n Second. \n}\n}")) 369
(doc (eval-document source "plain.sgd")) 370
(paragraph (car (section-children (car (document-children doc)))))@@ -387,7 +387,7 @@
387
(let* ((doc (eval-document-forms 388
(string-append "#lang sigil/doc\n" 389
"@(define (shout) (text \"LOUD\"))\n"−390
"@chapter[\"T\" \"A\"]{\n"+390
"@article[\"T\" \"A\"]{\n" 391
"@section[\"S\" id: \"s\"]{\n" 392
"Prose then @(shout) then more.\n}\n}") 393
"expr.sgd"))@@ -402,7 +402,7 @@
402
;; in `author-paragraph-run` is "no value is inline", not "every value is a 403
;; block". Written on one line, both items are non-boundary. 404
(let* ((doc (eval-document−405
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+405
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 406
"@items{@item{First.} @item{Second.}}\n}") 407
"items.sgd")) 408
(list-node (car (document-children doc))))@@ -416,7 +416,7 @@
416
;; way -- what changes is that the paragraph's location is now the RUN's span 417
;; rather than the CELL's. 418
(let* ((doc (eval-document−419
(string-append "#lang sigil/doc\n@chapter[\"T\" \"A\"]{\n"+419
(string-append "#lang sigil/doc\n@article[\"T\" \"A\"]{\n" 420
"@table[columns: '(left)]{\n@row{\n" 421
"@cell{Open a file with @code{C-x C-f}}\n}\n}\n}") 422
"cell.sgd"))test/test-reader.sglmodified
@@ -2,7 +2,7 @@
2
(sigil doc private author-runtime) (sigil doc private parser) 3
(sigil doc inspect)) 4
−5
(define source "#lang sigil/doc\n@chapter[\"Minimal\" authors: '(\"Author\")]{@section[\"One\" id: \"one\"]{@p{Hello\nworld @em{nicely}.}}}")+5
(define source "#lang sigil/doc\n@article[\"Minimal\" authors: '(\"Author\")]{@section[\"One\" id: \"one\"]{@p{Hello\nworld @em{nicely}.}}}") 6
(define parsed (parse-document-source source "memory.sgd" 16)) 7
(define value (eval parsed)) 8
@@ -17,20 +17,20 @@
17
(assert-true (emphasis? (cadr (paragraph-children (car (section-children (car (document-children value))))))))) 18
19
(test "locations use UTF-8 bytes and scalar columns"−20
(let* ((utf8 "#lang sigil/doc\n@chapter[\"UTF-8\" \"Author\"]{@p{καλημέρα @em{κόσμε}}}")+20
(let* ((utf8 "#lang sigil/doc\n@article[\"UTF-8\" \"Author\"]{@p{καλημέρα @em{κόσμε}}}") 21
(doc (eval (parse-document-source utf8 "utf8.sgd" 16))) 22
(paragraph (car (document-children doc))) 23
(text-node (car (paragraph-children paragraph)))) 24
(assert-true (> (srcloc-span (text-location text-node)) (string-length (text-content text-node)))))) 25
26
(test "standard reader owns argument and expression boundaries"−27
(let ((with-delimiters "#lang sigil/doc\n@chapter[\"a ] title\" \"Author\"]{@p{ok}}"))+27
(let ((with-delimiters "#lang sigil/doc\n@article[\"a ] title\" \"Author\"]{@p{ok}}")) 28
(assert-equal "a ] title" (document-title (eval (parse-document-source with-delimiters "args.sgd" 16)))))−29
(let ((comment-delimiter "#lang sigil/doc\n@chapter[\"title\" ; ] belongs to the comment\n \"Author\"]{@p{ok}}"))+29
(let ((comment-delimiter "#lang sigil/doc\n@article[\"title\" ; ] belongs to the comment\n \"Author\"]{@p{ok}}")) 30
(assert-equal "title" (document-title (eval (parse-document-source comment-delimiter "comment.sgd" 16))))) 31
(assert-equal "ab" 32
(document-title (eval (parse-document-source−33
"#lang sigil/doc\n@chapter[(string-append \"a\" \"b\") \"A\"]{@p{body}}" "enabled.sgd" 16))))+33
"#lang sigil/doc\n@article[(string-append \"a\" \"b\") \"A\"]{@p{body}}" "enabled.sgd" 16)))) 34
(let ((message 35
(guard (exn (else (exception-message exn))) 36
(parse-document-source "#lang sigil/doc\n@(string-append \")\" \"x\"" "broken.sgd" 16))))@@ -38,43 +38,43 @@
38
(substring message 0 (string-length "read-syntax: broken.sgd:"))))) 39
40
(test "malformed nesting is rejected"−41
(assert-error (parse-document-source "#lang sigil/doc\n@chapter[\"x\" \"A\"]{@p{oops}" "eof.sgd" 16))+41
(assert-error (parse-document-source "#lang sigil/doc\n@article[\"x\" \"A\"]{@p{oops}" "eof.sgd" 16)) 42
(assert-error (parse-document-source "#lang sigil/doc\n}" "brace.sgd" 16))) 43
44
(test "named blocks are generic, nested, and mix with braces"−45
(let* ((named "#lang sigil/doc\n@chapter[\"Named\" authors: '(\"Author\")]\n @section[\"Outer\" id: \"outer\"]\n @p{brace inside named}\n @p\n named paragraph\n @end p\n @end section\n@end chapter\n")+45
(let* ((named "#lang sigil/doc\n@article[\"Named\" authors: '(\"Author\")]\n @section[\"Outer\" id: \"outer\"]\n @p{brace inside named}\n @p\n named paragraph\n @end p\n @end section\n@end article\n") 46
(doc (eval (parse-document-source named "named.sgd" 16))) 47
(section-node (car (document-children doc)))) 48
(assert-equal "Named" (document-title doc)) 49
(assert-equal 3 (srcloc-line (section-location section-node))) 50
(assert-equal 2 (length (section-children section-node))))−51
(let* ((generic "#lang sigil/doc\n@chapter[\"Generic\" \"Author\"]\n@tip\n@p{works}\n@end tip\n@end chapter\n")+51
(let* ((generic "#lang sigil/doc\n@article[\"Generic\" \"Author\"]\n@tip\n@p{works}\n@end tip\n@end article\n") 52
(form (parse-document-source generic "generic.sgd" 16))) 53
(assert-true (pair? (syntax->datum form))))) 54
55
(test "named terminators match exactly and inline commands require braces" 56
(assert-equal−57
"mismatch.sgd:4:1: sigil/doc: mismatched named block terminator; expected '@end section', got '@end chapter'"+57
"mismatch.sgd:4:1: sigil/doc: mismatched named block terminator; expected '@end section', got '@end article'" 58
(guard (exn (else (exception-message exn)))−59
(parse-document-source "#lang sigil/doc\n@chapter[\"x\" authors: '(\"A\")]\n@section[\"s\" id: \"s\"]\n@end chapter\n" "mismatch.sgd" 16)))+59
(parse-document-source "#lang sigil/doc\n@article[\"x\" authors: '(\"A\")]\n@section[\"s\" id: \"s\"]\n@end article\n" "mismatch.sgd" 16))) 60
(assert-equal 61
"inline-named.sgd:2:27: sigil/doc: command requires '{...}', a line body, or a line-level named body" 62
(guard (exn (else (exception-message exn)))−63
(parse-document-source "#lang sigil/doc\n@chapter[\"x\" \"A\"]{text @em\nbody\n@end em\n}" "inline-named.sgd" 16))))+63
(parse-document-source "#lang sigil/doc\n@article[\"x\" \"A\"]{text @em\nbody\n@end em\n}" "inline-named.sgd" 16)))) 64
65
(test "horizontal command spacing preserves compact semantics" 66
(define (title source) (document-title (eval (parse-document-source source "spacing.sgd" 16))))−67
(assert-equal "Compact" (title "#lang sigil/doc\n@chapter[\"Compact\" \"A\"]{@p{x}}"))−68
(assert-equal "Compact" (title "#lang sigil/doc\n@chapter \t [\"Compact\" \"A\"] \t {@p{x}}"))−69
(assert-equal "Compact" (title "#lang sigil/doc\n@chapter[\n \"Compact\" ; standard reader owns this comment\n \"A\"\n] {@p{x}}"))+67
(assert-equal "Compact" (title "#lang sigil/doc\n@article[\"Compact\" \"A\"]{@p{x}}"))+68
(assert-equal "Compact" (title "#lang sigil/doc\n@article \t [\"Compact\" \"A\"] \t {@p{x}}"))+69
(assert-equal "Compact" (title "#lang sigil/doc\n@article[\n \"Compact\" ; standard reader owns this comment\n \"A\"\n] {@p{x}}")) 70
;; A newline after the argument group chooses a named body, never a later brace. 71
(let ((doc (eval (parse-document-source−72
"#lang sigil/doc\n@chapter[\"x\" \"A\"]\n{not an opening brace}\n@end chapter\n"+72
"#lang sigil/doc\n@article[\"x\" \"A\"]\n{not an opening brace}\n@end article\n" 73
"newline.sgd" 16)))) 74
(assert-equal "{not an opening brace}" (text-content (car (paragraph-children (car (document-children doc)))))))) 75
76
(test "line bodies share command semantics and stop at the physical newline"−77
(let* ((source "#lang sigil/doc\n@chapter[\"Lines\" authors: '(\"A\")]\n@section[\"A:B\" id: \"a-b\"]: @p{nested @em{inline}}\n@p: καλημέρα\n@anchor[\"empty\"]: \n@end chapter\n")+77
(let* ((source "#lang sigil/doc\n@article[\"Lines\" authors: '(\"A\")]\n@section[\"A:B\" id: \"a-b\"]: @p{nested @em{inline}}\n@p: καλημέρα\n@anchor[\"empty\"]: \n@end article\n") 78
(doc (eval (parse-document-source source "lines.sgd" 16))) 79
(children (document-children doc)) 80
(section-node (car children))@@ -85,7 +85,7 @@
85
(assert-equal 5 (srcloc-column (text-location (car (paragraph-children following))))) 86
(assert-true (anchor? (caddr children)))) 87
(assert-error−88
(parse-document-source "#lang sigil/doc\n@chapter[\"x\" \"A\"]{@p{inline @em: rejected}}" "inline-line.sgd" 16)))+88
(parse-document-source "#lang sigil/doc\n@article[\"x\" \"A\"]{@p{inline @em: rejected}}" "inline-line.sgd" 16))) 89
90
(test "author results are nodes or proper node lists only" 91
(assert-equal "sigil/doc author: @expression must produce a document node or proper list of nodes"@@ -95,7 +95,7 @@
95
(author-normalize (list value) (document-location value) 'expression))) 96
97
(test "blank lines form deterministic paragraphs"−98
(let* ((prose "#lang sigil/doc\n@chapter[\"x\" \"A\"]{first\nline\n\nsecond}")+98
(let* ((prose "#lang sigil/doc\n@article[\"x\" \"A\"]{first\nline\n\nsecond}") 99
(doc (eval (parse-document-source prose "paragraphs.sgd" 16)))) 100
(assert-equal 2 (length (document-children doc))) 101
(assert-equal "first line" (text-content (car (paragraph-children (car (document-children doc))))))@@ -106,8 +106,8 @@
106
(let ((header (inspect-language-source source name))) 107
(eval (parse-document-source source name (language-header-end header))))) 108
(let* ((bom (string #\xFEFF))−109
(plain (string-append bom "#lang sigil/doc\n@chapter[\"BOM\" \"Author\"]{@p{καλημέρα}}"))−110
(script (string-append bom "#!/usr/bin/env sigil\n#lang sigil/doc\n@chapter[\"Script\" \"Author\"]{@p{καλημέρα}}"))+109
(plain (string-append bom "#lang sigil/doc\n@article[\"BOM\" \"Author\"]{@p{καλημέρα}}"))+110
(script (string-append bom "#!/usr/bin/env sigil\n#lang sigil/doc\n@article[\"Script\" \"Author\"]{@p{καλημέρα}}")) 111
(plain-doc (parse-inspected plain "bom.sgd")) 112
(script-doc (parse-inspected script "script.sgd"))) 113
(assert-equal "BOM" (document-title plain-doc))@@ -118,7 +118,7 @@
118
(assert-equal 1 (srcloc-column (document-location script-doc))))) 119
120
(test "generated constructor failures retain command origins"−121
(define bad-anchor "#lang sigil/doc\n@chapter[\"x\" \"A\"]{\n\n@anchor[\"Bad_ID\"]{}\n}")+121
(define bad-anchor "#lang sigil/doc\n@article[\"x\" \"A\"]{\n\n@anchor[\"Bad_ID\"]{}\n}") 122
(let* ((exn (guard (exn (else exn)) 123
(eval (parse-document-source bad-anchor "bad-anchor.sgd" 16)))) 124
(trace (exception-stack-trace exn))@@ -136,10 +136,10 @@
136
(assert-equal 1 (srcloc-column origin))) 137
(assert-equal "make-section: invalid id" 138
(guard (exn (else (exception-message exn)))−139
(eval (parse-document-source "#lang sigil/doc\n@chapter[\"x\" \"A\"]{\n\n@section[\"Title\"]{}\n}" "bad-id.sgd" 16))))+139
(eval (parse-document-source "#lang sigil/doc\n@article[\"x\" \"A\"]{\n\n@section[\"Title\"]{}\n}" "bad-id.sgd" 16)))) 140
(assert-equal "make-anchor: invalid id" 141
(guard (exn (else (exception-message exn)))−142
(eval (parse-document-source "#lang sigil/doc\n@chapter[\"x\" \"A\"]{\n\n@anchor[42]{}\n}" "bad-type.sgd" 16)))))+142
(eval (parse-document-source "#lang sigil/doc\n@article[\"x\" \"A\"]{\n\n@anchor[42]{}\n}" "bad-type.sgd" 16))))) 143
144
(test "ordinary author bindings work through commands and expressions" 145
(let* ((authoring@@ -150,7 +150,7 @@
150
" (set! author-call-count (+ author-call-count 1))\n" 151
" body)\n" 152
"@(define-syntax bold (syntax-rules () ((_ child) (em child))))\n"−153
"@chapter[\"Authoring\" \"A\"]{\n"+153
"@article[\"Authoring\" \"A\"]{\n" 154
"@authored{@p{command path}}\n" 155
"@(authored (p (text \"expression path\")))\n" 156
"@p{local @bold{macro}}\n"@@ -175,14 +175,14 @@
175
" (section\n" 176
" (string-append title (if (eq? option suffix:) suffix \"bad\"))\n" 177
" id: \"computed-heading\" body))\n"−178
"@chapter [\"Arguments\" \"A\"]\n"+178
"@article [\"Arguments\" \"A\"]\n" 179
"@computed-heading [\n" 180
" (title-parts \"Com\" \"puted\")\n" 181
" suffix: (string #\\!)\n" 182
"] {\n" 183
" @p { padded body }\n" 184
"}\n"−185
"@end chapter\n"))+185
"@end article\n")) 186
(doc (eval-document-source computed "computed.sgd" 16)) 187
(section-node (car (document-children doc))) 188
(paragraph (car (section-children section-node))))@@ -194,7 +194,7 @@
194
(string-append 195
"#lang sigil/doc\n" 196
"@(define (nested body) (list (list body)))\n"−197
"@chapter[\"Nested\" \"A\"]{\n"+197
"@article[\"Nested\" \"A\"]{\n" 198
"@nested{@p{one}}\n" 199
"@(list (list (p (text \"two\"))))\n" 200
"}\n"))@@ -209,7 +209,7 @@
209
(string-append 210
"#lang sigil/doc\n" 211
"@(define subject-ran #f)\n"−212
"@chapter[\"Subject\" \"A\"]{\n"+212
"@article[\"Subject\" \"A\"]{\n" 213
"@code[\"sigil\"]{@(set! subject-ran #t)}\n" 214
"}\n")) 215
(doc (eval-document-source subject "subject.sgd" 16))@@ -221,7 +221,7 @@
221
(let* ((source 222
(string-append 223
"#lang sigil/doc\n"−224
"@chapter[\"Code\" \"A\"]{\n"+224
"@article[\"Code\" \"A\"]{\n" 225
"@p{Call @code{map} here.}\n" 226
"@code[\"sigil\"] {\n(+ 1 2)\n}\n" 227
"@code[#f]: unlabelled line\n"@@ -247,12 +247,12 @@
247
(let* ((source 248
(string-append 249
"#lang sigil/doc\n"−250
"@chapter[\"Raw Code\" \"A\"]\n"+250
"@article[\"Raw Code\" \"A\"]\n" 251
"@code[\"brace\"] {\n email@example.com @@ @{x} {nested} καλημέρα \n}\n" 252
"@code[#f]\n email@example.com\n @@ and @end other and } are inert\n@end code\n" 253
"@code[\"line\"]: email@example.com @@ @{x} {nested} καλημέρα \n" 254
"@p{inline @code{email@@example.com} remains document markup}\n"−255
"@end chapter\n"))+255
"@end article\n")) 256
(doc (eval (parse-document-source source "raw-code.sgd" 16))) 257
(children (document-children doc)) 258
(brace (car children))@@ -271,7 +271,7 @@
271
272
(test "location indexing performs one deterministic scalar pass" 273
(define (pressure count)−274
(let loop ((i 0) (out "#lang sigil/doc\n@chapter[\"Scale\" \"A\"]{\n"))+274
(let loop ((i 0) (out "#lang sigil/doc\n@article[\"Scale\" \"A\"]{\n")) 275
(if (= i count) 276
(string-append out "}\n") 277
(loop (+ i 1)@@ -307,7 +307,7 @@
307
(let* ((undefined 308
(guard (exn (else exn)) 309
(eval-document-source−310
"#lang sigil/doc\n@chapter[\"x\" \"A\"]{\n@does-not-exist{}\n}"+310
"#lang sigil/doc\n@article[\"x\" \"A\"]{\n@does-not-exist{}\n}" 311
"undefined.sgd" 16))) 312
(undefined-origin 313
(srcloc-authoritative (vector-ref (author-frame undefined) 1))))@@ -321,7 +321,7 @@
321
(string-append 322
"#lang sigil/doc\n" 323
"@(define (explode . body) (error \"author boom\"))\n"−324
"@chapter[\"x\" \"A\"]{\n"+324
"@article[\"x\" \"A\"]{\n" 325
"@explode{}\n" 326
"}\n") 327
"explode.sgd" 16)))test/test-root-profile.sglmodified
@@ -21,7 +21,13 @@
21
;;; this phase does not touch. 22
(import (sigil test) (sigil fs) (sigil syntax) 23
(sigil doc) (sigil doc author) (sigil doc private author-runtime)−24
(sigil doc reader))+24
(sigil doc reader)+25
;; ONLY the profile. `(sigil doc book reader)` also exports+26
;; `read-language-source`, and an unqualified import silently shadows+27
;; the BASE language's reader -- which this suite calls by that name.+28
;; Cost of learning that: one arm that reported a `sigil/doc/book:`+29
;; diagnostic while claiming to exercise `#lang sigil/doc`.+30
(only (sigil doc book reader) sigil-doc-book-profile)) 31
32
;; ---------------------------------------------------------------- helpers 33
@@ -75,7 +81,15 @@
81
82
(define folio-profile (make-document-profile "folio/doc" '(note project) 'one-or-more)) 83
(define folio-one-profile (make-document-profile "folio/doc" '(note project) 'one))−78
(define container-profile (make-document-profile "sigil/doc" '(article book) 'one))+84
;; The byte offset just past the `#lang` line. Derived from the source rather+85
;; than written as 16 or 21: SD-P8 gave this suite manuscripts in two languages+86
;; whose header lines differ in length, and a hardcoded offset would silently+87
;; slice into the wrong place for one of them.+88
(define (header-end-of source)+89
(let loop ((i 0))+90
(cond ((>= i (string-length source)) i)+91
((char=? (string-ref source i) #\newline) (+ i 1))+92
(else (loop (+ i 1)))))) 93
94
(define folio-path "test/fixtures/sd-p1-folio-roots.sgd") 95
(define folio-source (source-of folio-path))@@ -137,27 +151,48 @@
151
;; The CLASS, not a spelling: a root outside the set is refused whichever 152
;; profile is asked, so a parser that ignored the allowlist reddens here 153
;; twice rather than once.−140
(let ((chapter-source "#lang sigil/doc\n@chapter[\"C\" \"A\"]{@p{body}}"))+154
;;+155
;; SD-P8 made this arm three-way rather than two-way. Since D8 the base and+156
;; the book genre name DIFFERENT roots, so `@chapter` is now a root some+157
;; sigil-doc profile rejects -- which is the case the two-profile version+158
;; could not express.+159
(let ((article-source "#lang sigil/doc\n@article[\"C\" \"A\"]{@p{body}}")+160
(chapter-source "#lang sigil/doc/book\n@chapter[\"C\" \"A\"]{@p{body}}")) 161
;; A folio profile must NOT accept sigil/doc's root. 162
(assert-equal 163
"folio/doc: top-level author forms must precede at least one @note or @project" 164
(message (lambda () (parse-document-parts-with-profile−145
folio-profile chapter-source "c.sgd" 16))))+165
folio-profile article-source "c.sgd" 16)))) 166
;; ...and sigil/doc's profile must NOT accept a folio root. 167
(assert-equal−148
"sigil/doc: top-level author forms must precede exactly one @chapter"+168
"sigil/doc: top-level author forms must precede exactly one @article" 169
(message (lambda () (parse-document-parts-with-profile 170
sigil-doc-profile folio-source folio-path 16))))−151
;; The same profile still accepts the root it DOES name -- otherwise a−152
;; parser that rejected everything would satisfy both assertions above.+171
;; ...nor the genre language's root, which is the direction D8 created.+172
(assert-equal+173
"sigil/doc: top-level author forms must precede exactly one @article"+174
(message (lambda () (parse-document-parts-with-profile+175
sigil-doc-profile chapter-source "c.sgd" 21))))+176
;; ...and the genre language refuses the BASE's root, symmetrically.+177
(assert-equal+178
"sigil/doc/book: top-level author forms must precede exactly one @chapter"+179
(message (lambda () (parse-document-parts-with-profile+180
sigil-doc-book-profile article-source "a.sgd" 16))))+181
;; Each profile still accepts the root it DOES name -- otherwise a parser+182
;; that rejected everything would satisfy every assertion above.+183
(let ((parts (parse-document-parts-with-profile+184
sigil-doc-profile article-source "c.sgd" 16)))+185
(assert-equal 1 (length (cadr parts)))) 186
(let ((parts (parse-document-parts-with-profile−154
sigil-doc-profile chapter-source "c.sgd" 16)))+187
sigil-doc-book-profile chapter-source "c.sgd" 21))) 188
(assert-equal 1 (length (cadr parts)))))) 189
190
(test "multiplicity is a parameter, and is enforced in both directions" 191
(let ((single "#lang sigil/doc\n@note[\"topics/only\"]{@p{one root}}\n")+192
(two-articles+193
"#lang sigil/doc\n@article[\"A\" \"A\"]{@p{x}}\n@article[\"B\" \"B\"]{@p{y}}\n") 194
(two-chapters−160
"#lang sigil/doc\n@chapter[\"A\" \"A\"]{@p{x}}\n@chapter[\"B\" \"B\"]{@p{y}}\n"))+195
"#lang sigil/doc/book\n@chapter[\"A\" \"A\"]{@p{x}}\n@chapter[\"B\" \"B\"]{@p{y}}\n")) 196
;; one-or-more accepts one AND several. 197
(assert-equal 1 (length (cadr (parse-document-parts-with-profile 198
folio-profile single "s.sgd" 16))))@@ -172,99 +207,145 @@
207
;; passing because `one` rejects everything. 208
(assert-equal 1 (length (cadr (parse-document-parts-with-profile 209
folio-one-profile single "s.sgd" 16))))−175
;; sigil/doc's own multiplicity is unchanged.+210
;; sigil/doc's own multiplicity is unchanged by SD-P8; only its root moved. 211
(assert-equal−177
"sigil/doc: top-level author forms must precede exactly one @chapter"+212
"sigil/doc: top-level author forms must precede exactly one @article" 213
(message (lambda () (parse-document-parts-with-profile−179
sigil-doc-profile two-chapters "t.sgd" 16))))))+214
sigil-doc-profile two-articles "t.sgd" 16))))+215
;; ...and the genre language carries the same `one`, which is what makes a+216
;; two-chapter manuscript a diagnostic rather than a dropped root.+217
(assert-equal+218
"sigil/doc/book: top-level author forms must precede exactly one @chapter"+219
(message (lambda () (parse-document-parts-with-profile+220
sigil-doc-book-profile two-chapters "t.sgd" 21)))))) 221
−181
(test "the default profile is today's policy and today's diagnostics, exactly"−182
;; These two literals are the strings this parser has raised since D1. They−183
;; are now DERIVED from `sigil-doc-profile` rather than written out, so this−184
;; arm is what stops the derivation from quietly rewording a shipped−185
;; diagnostic.+222
(test "the base profile is D8's policy and D8's diagnostics, exactly"+223
;; THE PINNED LITERALS. These are the two strings `#lang sigil/doc` raises,+224
;; and they are DERIVED from `sigil-doc-profile` rather than written out in+225
;; the parser, so this arm is what stops the derivation from quietly+226
;; rewording a shipped diagnostic.+227
;;+228
;; SD-P8 CHANGED THEM, from `@chapter` to `@article`, and that is exactly the+229
;; migration shape this estate distrusts: updating a pinned literal to match+230
;; the new output proves nothing on its own. Each literal below was therefore+231
;; shown still able to FAIL after the migration -- see+232
;; `test/sabotage-sd-p8.sh` legs 1-3, which perturb the PRODUCT (the profile+233
;; and the derivation) rather than the assertion and require this suite to+234
;; redden at these arms by name. 235
(assert-equal "sigil/doc" (document-profile-name sigil-doc-profile))−187
(assert-equal '(chapter) (document-profile-roots sigil-doc-profile))+236
(assert-equal '(article) (document-profile-roots sigil-doc-profile)) 237
(assert-equal 'one (document-profile-multiplicity sigil-doc-profile)) 238
(assert-equal−190
"sigil/doc: source must contain exactly one @chapter"+239
"sigil/doc: source must contain exactly one @article" 240
(message (lambda () (parse-document-parts-with-profile 241
sigil-doc-profile "#lang sigil/doc\n@(define x 1)\n" "n.sgd" 16)))) 242
(assert-equal−194
"sigil/doc: source must contain exactly one @chapter"+243
"sigil/doc: source must contain exactly one @article" 244
(message (lambda () (parse-document-parts-with-profile 245
sigil-doc-profile "#lang sigil/doc\n" "e.sgd" 16)))) 246
(assert-equal−198
"sigil/doc: top-level author forms must precede exactly one @chapter"+247
"sigil/doc: top-level author forms must precede exactly one @article" 248
(message (lambda () (parse-document-parts-with-profile 249
sigil-doc-profile−201
"#lang sigil/doc\n@chapter[\"C\" \"A\"]{@p{b}}\n@(define y 2)\n"+250
"#lang sigil/doc\n@article[\"C\" \"A\"]{@p{b}}\n@(define y 2)\n" 251
"a.sgd" 16)))) 252
;; Three-or-more root sets get an Oxford-comma phrase; pinned so the−204
;; formatter is covered beyond the one- and two-root cases.+253
;; formatter is covered beyond the one- and two-root cases. The names here+254
;; are ARBITRARY command symbols, deliberately not the model's kinds -- root+255
;; commands are the profile's vocabulary and document kinds are the model's,+256
;; and D8 is the ruling that separated them. 257
(assert-equal−206
"sigil/doc: source must contain exactly one @article, @book, or @chapter"+258
"sigil/doc: source must contain exactly one @article, @memo, or @chapter" 259
(message (lambda () (parse-document-parts-with-profile−208
(make-document-profile "sigil/doc" '(article book chapter) 'one)+260
(make-document-profile "sigil/doc" '(article memo chapter) 'one) 261
"#lang sigil/doc\n" "o.sgd" 16))))) 262
−211
(test "the model's article and book kinds are reachable from source"−212
;; B2's other half. The parser was the blocker: with the root set a−213
;; parameter, `article` and `book` are producible from a manuscript without−214
;; changing the default profile and without a new binding in−215
;; `(sigil doc author)`.+263
(test "the book genre language is a sibling profile with its own diagnostics"+264
;; SD-P8. `#lang sigil/doc/book` is the D8 home of the book/print genre. It+265
;; is a PROFILE, not a second parser: everything below the root -- the+266
;; grammar, the locations, the author vocabulary -- is `#lang sigil/doc`'s,+267
;; unchanged and undelegated-around.+268
;;+269
;; Its two literals are pinned for the same reason the base's are, and are+270
;; shown able to fail by the same sabotage legs. The `sigil/doc/book:` prefix+271
;; is the load-bearing part: a genre language that reported `sigil/doc:`+272
;; would send an author to the wrong language's documentation.+273
(assert-equal "sigil/doc/book" (document-profile-name sigil-doc-book-profile))+274
(assert-equal '(chapter) (document-profile-roots sigil-doc-book-profile))+275
(assert-equal 'one (document-profile-multiplicity sigil-doc-book-profile))+276
(assert-equal+277
"sigil/doc/book: source must contain exactly one @chapter"+278
(message (lambda () (parse-document-parts-with-profile+279
sigil-doc-book-profile "#lang sigil/doc/book\n" "e.sgd" 21))))+280
(assert-equal+281
"sigil/doc/book: source must contain exactly one @chapter"+282
(message (lambda () (parse-document-parts-with-profile+283
sigil-doc-book-profile+284
"#lang sigil/doc/book\n@(define x 1)\n" "n.sgd" 21))))+285
(assert-equal+286
"sigil/doc/book: top-level author forms must precede exactly one @chapter"+287
(message (lambda () (parse-document-parts-with-profile+288
sigil-doc-book-profile+289
"#lang sigil/doc/book\n@chapter[\"C\" \"A\"]{@p{b}}\n@(define y 2)\n"+290
"b.sgd" 21))))+291
;; POSITIVE CONTROL. Every assertion above is a refusal, and a profile that+292
;; refused everything would satisfy all three. This one must be accepted.+293
(let ((parts (parse-document-parts-with-profile+294
sigil-doc-book-profile+295
"#lang sigil/doc/book\n@chapter[\"C\" \"A\"]{@p{b}}\n" "g.sgd" 21)))+296
(assert-equal '() (car parts))+297
(assert-equal 1 (length (cadr parts)))))+298
+299
(test "the model's kinds are reachable from source, and `book` is gone"+300
;; B2's other half, rewritten by SD-P8.+301
;;+302
;; BEFORE D8 this arm had to build a `container-profile` naming `@article`+303
;; and `@book`, because neither kind was reachable from any shipped language.+304
;; `article` no longer needs one: it is what `#lang sigil/doc` itself admits,+305
;; so the arm now drives the DEFAULT profile and the coverage got stronger+306
;; rather than weaker. `chapter` is reachable through the genre profile.+307
;;+308
;; `book` is gone from the model entirely (D8 item 4): it was constructed+309
;; nowhere in this package or in folio, and a book is an ASSEMBLY built by+310
;; `make-print-publication`, not a document kind. Its old arm is replaced by+311
;; the refusal below, which is a stronger statement than the construction it+312
;; replaces -- it says the kind cannot come back by accident. 313
(define (evaluate profile source name)−217
(let loop ((forms (parse-document-forms-with-profile profile source name 16)) (last #f))+314
(let loop ((forms (parse-document-forms-with-profile profile source name+315
(header-end-of source)))+316
(last #f)) 317
(if (null? forms) last (loop (cdr forms) (eval (car forms))))))−219
(let ((article (evaluate container-profile+318
;; `@article` through the SHIPPED base profile, from the fixture on disk.+319
(let ((article (evaluate sigil-doc-profile 320
(source-of "test/fixtures/sd-p1-article-root.sgd") 321
"test/fixtures/sd-p1-article-root.sgd"))) 322
(assert-true (document? article)) 323
(assert-equal 'article (document-kind article)) 324
(assert-equal "An Article Root" (document-title article)))−225
;; NOTE: plain rest-args, not the `(keys: …) (rest: …)` spelling used inside−226
;; `(sigil doc author)`.−227
;;−228
;; CORRECTED 2026-08-11 (t-3aecae). The note that stood here said that−229
;; spelling "does NOT bind in a manuscript-local `@(define …)`". THAT IS−230
;; FALSE, and it sent a ticket after the wrong component. It binds perfectly−231
;; well in a manuscript -- see the `#lang`-path arm below, which loads−232
;; `test/fixtures/sd-manuscript-keyword-define.sgd` and gets both an explicit−233
;; keyword argument and a defaulted one.−234
;;−235
;; What actually fails is `evaluate` -- THIS helper, three lines up. It drives−236
;; each parsed form through the runtime `eval` procedure, and `eval` reaches−237
;; CPS conversion without the top-level macro-expansion pass, where−238
;; `cps_convert_expr` intercepts the SURFACE name `define` before the macro−239
;; fallback. So `(sigil core)`'s `define` macro never runs, and the primitive−240
;; converter cannot represent the extended parameter list: the define produces−241
;; NO BINDING AT ALL -- not a procedure missing its keywords -- and reports−242
;; nothing. The name is then unbound at the call site. `(opts: …)` and−243
;; `(rest: …)` alone fail the same way; it is not specific to `keys:`. Surface−244
;; `lambda` is NOT intercepted, which is why `(define f (lambda (x (keys: …))−245
;; …))` works under `eval` and the shorthand does not -- that is the available−246
;; workaround if a future arm here needs the keyword spelling.−247
;;−248
;; Plain rest-args are kept below because this arm's subject is the ROOT SET,−249
;; and it should not also depend on a core defect being fixed. Mechanism and−250
;; evidence: folio `investigations/eval-skips-define-macro-expansion`.−251
(let* ((book-source−252
(string-append−253
"#lang sigil/doc\n"−254
"@(define (book title . body)\n"−255
" (make-document 'book title (list \"SD-P1\")\n"−256
" (author-flatten body (author-location) 'book)\n"−257
" (author-location)))\n"−258
"@book[\"A Book Root\"]{@p{body}}\n"))−259
(book (evaluate container-profile book-source "b.sgd")))−260
(assert-true (document? book))−261
(assert-equal 'book (document-kind book)))−262
;; POSITIVE CONTROL on the arm itself: the same evaluation path still−263
;; produces a chapter under the default profile, so a failure above is about−264
;; the root set and not about evaluation being broken.−265
(let ((chapter (evaluate sigil-doc-profile−266
"#lang sigil/doc\n@chapter[\"C\" \"A\"]{@p{body}}" "c.sgd")))−267
(assert-equal 'chapter (document-kind chapter))))+325
;; `@chapter` through the SHIPPED genre profile. This is also the positive+326
;; control on the arm: a failure above is then about the root set rather than+327
;; about evaluation being broken.+328
(let ((chapter (evaluate sigil-doc-book-profile+329
"#lang sigil/doc/book\n@chapter[\"C\" \"A\"]{@p{body}}" "c.sgd")))+330
(assert-true (document? chapter))+331
(assert-equal 'chapter (document-kind chapter)))+332
;; THE DROPPED KIND. `make-document` must refuse `book` by name, and must+333
;; still accept the two that survive -- otherwise a constructor that refused+334
;; everything would satisfy the first assertion.+335
(let ((loc (make-srcloc "k.sgd" 1 1 0 1)))+336
(assert-error (make-document 'book "A Book" (list "A")+337
(list (make-paragraph (list (make-text "b" loc)) loc)) loc))+338
(assert-true (contains?+339
(message (lambda () (make-document 'book "A Book" (list "A")+340
(list (make-paragraph (list (make-text "b" loc)) loc))+341
loc)))+342
"kind must be article or chapter"))+343
(assert-equal 'article (document-kind+344
(make-document 'article "An Article" (list "A")+345
(list (make-paragraph (list (make-text "b" loc)) loc)) loc)))+346
(assert-equal 'chapter (document-kind+347
(make-document 'chapter "A Chapter" (list "A")+348
(list (make-paragraph (list (make-text "b" loc)) loc)) loc))))) 349
350
;; ---------------------------------------------------------------- t-3aecae 351
@@ -354,7 +435,7 @@
435
(assert-true (document-profile? (make-document-profile "x/doc" '(a b) 'one-or-more))) 436
;; A non-profile must not be accepted as one by the parse entry points. 437
(assert-error (parse-document-parts-with-profile−357
'not-a-profile "#lang sigil/doc\n@chapter[\"C\" \"A\"]{@p{b}}" "x.sgd" 16)))+438
'not-a-profile "#lang sigil/doc\n@article[\"C\" \"A\"]{@p{b}}" "x.sgd" 16))) 439
440
(test "a profile does not leak the aggregates it owns" 441
;; The ownership rule the semantic model uses, applied to configuration: a@@ -389,7 +470,7 @@
470
(let* ((source (string-append 471
"#lang sigil/doc\n" 472
"@(define (expr . body) (apply em body))\n"−392
"@chapter[\"Collision\" \"A\"]{@p{before @expr{inside} after}}"))+473
"@article[\"Collision\" \"A\"]{@p{before @expr{inside} after}}")) 474
(children (paragraph-children (car (document-children (evaluate source "x.sgd")))))) 475
(assert-equal 3 (length children)) 476
(assert-true (emphasis? (cadr children)))@@ -398,7 +479,7 @@
479
;; refused by name. Before this phase it reached the empty-prose filter, where 480
;; `caddr` of a command node is its child LIST and `trim` was handed a list. 481
(assert-equal−401
"sigil/doc: top-level author forms must precede exactly one @chapter"+482
"sigil/doc: top-level author forms must precede exactly one @article" 483
(message (lambda () (parse-document-parts-with-profile 484
sigil-doc-profile "#lang sigil/doc\n@text{a text command}\n" 485
"t.sgd" 16))))@@ -408,7 +489,7 @@
489
;; wrong node. At a body edge the command must survive as a command. 490
(let ((message-at-edge 491
(message (lambda () (evaluate−411
"#lang sigil/doc\n@chapter[\"E\" \"A\"]{\n@text{at the edge}\n}"+492
"#lang sigil/doc\n@article[\"E\" \"A\"]{\n@text{at the edge}\n}" 493
"e.sgd"))))) 494
(assert-true (not (contains? message-at-edge "NO ERROR"))) 495
;; Dispatched to the author `text` command, which wants a string and was@@ -418,18 +499,18 @@
499
;; that is the child LIST, so a head-symbol test hands `string-append` a list. 500
(assert-true 501
(contains? (message (lambda () (evaluate−421
"#lang sigil/doc\n@chapter[\"C\" \"A\"]{@p{@code{@text{x}}}}"+502
"#lang sigil/doc\n@article[\"C\" \"A\"]{@p{@code{@text{x}}}}" 503
"c.sgd"))) 504
"inline @code content must be text and document escapes")) 505
;; POSITIVE CONTROLS -- the genuine five-slot pseudo-nodes must be unaffected. 506
;; Bare prose is still folded into paragraphs...−426
(let ((doc (evaluate "#lang sigil/doc\n@chapter[\"P\" \"A\"]{\nbare prose\n}" "p.sgd")))+507
(let ((doc (evaluate "#lang sigil/doc\n@article[\"P\" \"A\"]{\nbare prose\n}" "p.sgd"))) 508
(assert-true (paragraph? (car (document-children doc)))) 509
(assert-equal "bare prose" (text-content (car (paragraph-children (car (document-children doc))))))) 510
;; ...and a real top-level `@(...)` is still hoisted as an author form. 511
(let ((parts (parse-document-parts-with-profile 512
sigil-doc-profile−432
"#lang sigil/doc\n@(define z 1)\n@chapter[\"Z\" \"A\"]{@p{b}}" "z.sgd" 16)))+513
"#lang sigil/doc\n@(define z 1)\n@article[\"Z\" \"A\"]{@p{b}}" "z.sgd" 16))) 514
(assert-equal 1 (length (car parts))) 515
(assert-equal 1 (length (cadr parts))))) 516
@@ -442,7 +523,7 @@
523
;; where only `<root>` is itself syntax. So `syntax-datum` applies to the form, 524
;; and plain list accessors apply inside it. 525
(let* ((forms (read-language-source−445
"#lang sigil/doc\n@chapter[\"C\" \"A\"]{@p{b}}" (context "c.sgd")))+526
"#lang sigil/doc\n@article[\"C\" \"A\"]{@p{b}}" (context "c.sgd"))) 527
(tail (syntax-datum (car (reverse forms)))) 528
(definition (syntax-datum (cadr (reverse forms))))) 529
(assert-equal 3 (length forms))@@ -468,9 +549,9 @@
549
;; that silently, and only a doubly-malformed manuscript can tell. This pins 550
;; the precedence so the two-pass structure cannot be "simplified" away. 551
(let* ((bad-code "@code[\"a\" \"b\"]{x}")−471
(both (string-append "#lang sigil/doc\n@chapter[\"C\" \"A\"]{\n"+552
(both (string-append "#lang sigil/doc\n@article[\"C\" \"A\"]{\n" 553
bad-code "\n}\ntrailing prose\n"))−473
(only-bad-code (string-append "#lang sigil/doc\n@chapter[\"C\" \"A\"]{\n"+554
(only-bad-code (string-append "#lang sigil/doc\n@article[\"C\" \"A\"]{\n" 555
bad-code "\n}\n")) 556
(both-message (message (lambda () (parse-document-parts-with-profile 557
sigil-doc-profile both "b.sgd" 16))))@@ -483,7 +564,7 @@
564
;; ...and with a policy violation ALSO present, the policy error is the one 565
;; reported -- the manuscript is never partially lowered. 566
(assert-equal−486
"sigil/doc: top-level author forms must precede exactly one @chapter"+567
"sigil/doc: top-level author forms must precede exactly one @article" 568
both-message) 569
(assert-true (not (contains? both-message "invalid arguments for @code"))))) 570