Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From v0.21.0 To trunk
2025-10-07
| ||
13:36 | Adapt to zsx changes ... (Leaf check-in: 6071c1355a user: stern tags: trunk) | |
2025-10-06
| ||
16:58 | Adapt to zsx changes ... (check-in: 78140061ec user: stern tags: trunk) | |
2025-05-02
| ||
14:34 | Remove Zid for SxnPrelude ... (check-in: b5c74e61e1 user: stern tags: trunk) | |
2025-04-17
| ||
14:58 | Version 0.21.0 ... (check-in: ef331b4f0c user: stern tags: release, trunk, v0.21.0) | |
09:21 | Update changelog ... (check-in: 6f32e74255 user: stern tags: trunk) | |
Changes to api/const.go.
︙ | ︙ | |||
115 116 117 118 119 120 121 | const ( CommandAuthenticated = Command("authenticated") CommandRefresh = Command("refresh") ) // Supported search operator representations. const ( | | > > | | > > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | const ( CommandAuthenticated = Command("authenticated") CommandRefresh = Command("refresh") ) // Supported search operator representations. const ( BackwardDirective = "BACKWARD" // Backward-only context / thread ContextDirective = "CONTEXT" // Context directive CostDirective = "COST" // Maximum cost of a context operation DirectedDirective = "DIRECTED" // Context/thread collection can have general directions FolgeDirective = "FOLGE" // Folge thread ForwardDirective = "FORWARD" // Forward-only context / thread FullDirective = "FULL" // Include tags in context IdentDirective = "IDENT" // Use only specified zettel ItemsDirective = "ITEMS" // Select list elements in a zettel MaxDirective = "MAX" // Maximum number of context / thread results MinDirective = "MIN" // Minimum number of context results LimitDirective = "LIMIT" // Maximum number of zettel OffsetDirective = "OFFSET" // Offset to start returned zettel list OrDirective = "OR" // Combine several search expression with an "or" OrderDirective = "ORDER" // Specify metadata keys for the order of returned list PhraseDirective = "PHRASE" // Only unlinked zettel with given phrase PickDirective = "PICK" // Pick some random zettel RandomDirective = "RANDOM" // Order zettel list randomly ReverseDirective = "REVERSE" // Reverse the order of a zettel list SequelDirective = "SEQUEL" // Sequel / branching thread ThreadDirective = "THREAD" // Both folge and Sequel thread UnlinkedDirective = "UNLINKED" // Search for zettel that contain a phase(s) but do not link ActionSeparator = "|" // Separates action list of previous elements of query expression KeysAction = "KEYS" // Provide metadata key used MinAction = "MIN" // Return only those values with a minimum amount of zettel MaxAction = "MAX" // Return only those values with a maximum amount of zettel |
︙ | ︙ |
Changes to client/client_test.go.
︙ | ︙ | |||
23 24 25 26 27 28 29 | "t73f.de/r/zsc/api" "t73f.de/r/zsc/client" "t73f.de/r/zsc/domain/id" ) func TestZettelList(t *testing.T) { c := getClient() | | < < | < | < < < | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | "t73f.de/r/zsc/api" "t73f.de/r/zsc/client" "t73f.de/r/zsc/domain/id" ) func TestZettelList(t *testing.T) { c := getClient() if _, err := c.QueryZettel(context.Background(), ""); err != nil { t.Error(err) } } func TestGetProtectedZettel(t *testing.T) { c := getClient() if _, err := c.GetZettel(context.Background(), id.ZidStartupConfiguration, api.PartZettel); err != nil { if cErr, ok := err.(*client.Error); !ok || cErr.StatusCode != http.StatusForbidden { t.Error(err) } } } func TestGetSzZettel(t *testing.T) { c := getClient() value, err := c.GetEvaluatedSz(context.Background(), id.ZidDefaultHome, api.PartContent) if err != nil { |
︙ | ︙ |
Changes to domain/id/id.go.
︙ | ︙ | |||
85 86 87 88 89 90 91 | // WebUI JS zettel are in the range 30000..39999 // WebUI image zettel are in the range 40000..49999 ZidEmoji = Zid(40001) // Other sxn code zettel are in the range 50000..59999 | < | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | // WebUI JS zettel are in the range 30000..39999 // WebUI image zettel are in the range 40000..49999 ZidEmoji = Zid(40001) // Other sxn code zettel are in the range 50000..59999 // Predefined Zettelmarkup zettel are in the range 60000..69999 ZidRoleZettelZettel = Zid(60010) ZidRoleConfigurationZettel = Zid(60020) ZidRoleRoleZettel = Zid(60030) ZidRoleTagZettel = Zid(60040) |
︙ | ︙ |
Changes to domain/id/idset/idset.go.
︙ | ︙ | |||
129 130 131 132 133 134 135 | // IntersectOrSet removes all zettel identifier that are not in the other set. // Both sets can be modified by this method. One of them is the set returned. // It contains the intersection of both, if s is not nil. // // If s == nil, then the other set is always returned. func (s *Set) IntersectOrSet(other *Set) *Set { | | > > > > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | // IntersectOrSet removes all zettel identifier that are not in the other set. // Both sets can be modified by this method. One of them is the set returned. // It contains the intersection of both, if s is not nil. // // If s == nil, then the other set is always returned. func (s *Set) IntersectOrSet(other *Set) *Set { if s == nil { return other // no other.Clone(), since other != nil, i.e. "not found" } if other == nil { s.seq = s.seq[:0] return s } topos, spos, opos := 0, 0, 0 for spos < len(s.seq) && opos < len(other.seq) { sz, oz := s.seq[spos], other.seq[opos] if sz < oz { spos++ continue |
︙ | ︙ |
Changes to domain/meta/meta.go.
︙ | ︙ | |||
142 143 144 145 146 147 148 | KeyFolge = "folge" KeyFolgeRole = "folge-role" KeyForward = "forward" KeyLang = "lang" KeyLicense = "license" KeyModified = "modified" KeyPrecursor = "precursor" | < < < < | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | KeyFolge = "folge" KeyFolgeRole = "folge-role" KeyForward = "forward" KeyLang = "lang" KeyLicense = "license" KeyModified = "modified" KeyPrecursor = "precursor" KeyPrequel = "prequel" KeyPublished = "published" KeyQuery = "query" KeyReadOnly = "read-only" KeySequel = "sequel" KeySubordinates = "subordinates" KeySummary = "summary" KeySuperior = "superior" KeyURL = "url" KeyUselessFiles = "useless-files" KeyUserID = "user-id" KeyUserRole = "user-role" KeyVisibility = "visibility" ) // Supported keys. func init() { registerKey(KeyID, TypeID, usageComputed, "") registerKey(KeyTitle, TypeEmpty, usageUser, "") registerKey(KeyRole, TypeWord, usageUser, "") registerKey(KeyTags, TypeTagSet, usageUser, "") registerKey(KeySyntax, TypeWord, usageUser, "") // Properties that are inverse keys registerKey(KeyFolge, TypeIDSet, usageProperty, "") registerKey(KeySequel, TypeIDSet, usageProperty, "") registerKey(KeySubordinates, TypeIDSet, usageProperty, "") // Non-inverse keys registerKey(KeyAuthor, TypeString, usageUser, "") registerKey(KeyBack, TypeIDSet, usageProperty, "") registerKey(KeyBackward, TypeIDSet, usageProperty, "") registerKey(KeyBoxNumber, TypeNumber, usageProperty, "") registerKey(KeyCopyright, TypeString, usageUser, "") registerKey(KeyCreated, TypeTimestamp, usageComputed, "") registerKey(KeyCredential, TypeCredential, usageUser, "") registerKey(KeyDead, TypeIDSet, usageProperty, "") registerKey(KeyExpire, TypeTimestamp, usageUser, "") registerKey(KeyFolgeRole, TypeWord, usageUser, "") registerKey(KeyForward, TypeIDSet, usageProperty, "") registerKey(KeyLang, TypeWord, usageUser, "") registerKey(KeyLicense, TypeEmpty, usageUser, "") registerKey(KeyModified, TypeTimestamp, usageComputed, "") registerKey(KeyPrecursor, TypeIDSet, usageUser, KeyFolge) registerKey(KeyPrequel, TypeIDSet, usageUser, KeySequel) registerKey(KeyPublished, TypeTimestamp, usageProperty, "") registerKey(KeyQuery, TypeEmpty, usageUser, "") registerKey(KeyReadOnly, TypeWord, usageUser, "") registerKey(KeySummary, TypeString, usageUser, "") registerKey(KeySuperior, TypeIDSet, usageUser, KeySubordinates) registerKey(KeyURL, TypeURL, usageUser, "") |
︙ | ︙ | |||
275 276 277 278 279 280 281 | } } // SetNonEmpty stores the given value under the given key, if the value is non-empty. // An empty value will delete the previous association. func (m *Meta) SetNonEmpty(key string, value Value) { if value == "" { | > | > > > > > > > > > > > | > | | | | | < > | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | } } // SetNonEmpty stores the given value under the given key, if the value is non-empty. // An empty value will delete the previous association. func (m *Meta) SetNonEmpty(key string, value Value) { if value == "" { if key != KeyID { delete(m.pairs, key) } } else { m.Set(key, value.TrimSpace()) } } // Has returns true, if the given key is used in the metadata. func (m *Meta) Has(key string) bool { if m != nil { if _, found := m.pairs[key]; found || key == KeyID { return true } } return false } // Get retrieves the string value of a given key. The bool value signals, // whether there was a value stored or not. func (m *Meta) Get(key string) (Value, bool) { if m != nil { if value, found := m.pairs[key]; found { return value, true } if key == KeyID { return Value(m.Zid.String()), true } } return "", false } // GetDefault retrieves the string value of the given key. If no value was // stored, the given default value is returned. func (m *Meta) GetDefault(key string, def Value) Value { if value, found := m.Get(key); found { return value |
︙ | ︙ |
Changes to domain/meta/type.go.
︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | var ( cachedTypedKeys = make(map[string]*DescriptionType) mxTypedKey sync.RWMutex suffixTypes = map[string]*DescriptionType{ "-date": TypeTimestamp, "-number": TypeNumber, SuffixKeyRole: TypeWord, "-time": TypeTimestamp, SuffixKeyURL: TypeURL, "-zettel": TypeID, "-zid": TypeID, "-zids": TypeIDSet, } | > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | var ( cachedTypedKeys = make(map[string]*DescriptionType) mxTypedKey sync.RWMutex suffixTypes = map[string]*DescriptionType{ "-date": TypeTimestamp, "-number": TypeNumber, "-ref": TypeID, "-refs": TypeIDSet, SuffixKeyRole: TypeWord, "-time": TypeTimestamp, SuffixKeyURL: TypeURL, "-zettel": TypeID, "-zid": TypeID, "-zids": TypeIDSet, } |
︙ | ︙ |
Changes to domain/meta/values.go.
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | "iter" "slices" "strings" "time" zeroiter "t73f.de/r/zero/iter" "t73f.de/r/zsc/domain/id" "t73f.de/r/zsx/input" ) // Value ist a single metadata value. type Value string // AsBool returns the value interpreted as a bool. | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | "iter" "slices" "strings" "time" zeroiter "t73f.de/r/zero/iter" "t73f.de/r/zsc/domain/id" "t73f.de/r/zsx" "t73f.de/r/zsx/input" ) // Value ist a single metadata value. type Value string // AsBool returns the value interpreted as a bool. |
︙ | ︙ | |||
128 129 130 131 132 133 134 | ValueSyntaxJPEG = "jpeg" // Syntax: JPEG image ValueSyntaxJPG = "jpg" // Syntax: PEG image ValueSyntaxMarkdown = "markdown" // Syntax: Markdown / CommonMark ValueSyntaxMD = "md" // Syntax: Markdown / CommonMark ValueSyntaxNone = "none" // Syntax: no syntax / content, just metadata ValueSyntaxPlain = "plain" // Syntax: plain text ValueSyntaxPNG = "png" // Syntax: PNG image | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ValueSyntaxJPEG = "jpeg" // Syntax: JPEG image ValueSyntaxJPG = "jpg" // Syntax: PEG image ValueSyntaxMarkdown = "markdown" // Syntax: Markdown / CommonMark ValueSyntaxMD = "md" // Syntax: Markdown / CommonMark ValueSyntaxNone = "none" // Syntax: no syntax / content, just metadata ValueSyntaxPlain = "plain" // Syntax: plain text ValueSyntaxPNG = "png" // Syntax: PNG image ValueSyntaxSVG = zsx.SyntaxSVG // Syntax: SVG ValueSyntaxSxn = "sxn" // Syntax: S-Expression ValueSyntaxText = "text" // Syntax: plain text ValueSyntaxTxt = "txt" // Syntax: plain text ValueSyntaxWebp = "webp" // Syntax: WEBP image ValueSyntaxZmk = "zmk" // Syntax: Zettelmarkup ValueUserRoleCreator = "creator" ValueUserRoleOwner = "owner" |
︙ | ︙ |
Changes to go.mod.
1 2 | module t73f.de/r/zsc | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 | module t73f.de/r/zsc go 1.25 require ( t73f.de/r/sx v0.0.0-20250902163016-7a7a55d68dd6 t73f.de/r/sxwebs v0.0.0-20250902155414-673110c9fb48 t73f.de/r/webs v0.0.0-20250916082100-37e0307e3368 t73f.de/r/zero v0.0.0-20250904163008-d96be3da2aef t73f.de/r/zsx v0.0.0-20251007133258-f1844bbf951e ) |
Changes to go.sum.
|
| | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 | t73f.de/r/sx v0.0.0-20250902163016-7a7a55d68dd6 h1:vOyPEfxXze8QjcfxJK5GHb68PzDw2EomRwdUyDLnBVw= t73f.de/r/sx v0.0.0-20250902163016-7a7a55d68dd6/go.mod h1:D4NKzI2FRtNW0zCcvf+yCEplfoSnZAXiax9otvasu0w= t73f.de/r/sxwebs v0.0.0-20250902155414-673110c9fb48 h1:LCZQsACNivE0NkA6B296yTdHIN1wl88iAdx0J5pHzlA= t73f.de/r/sxwebs v0.0.0-20250902155414-673110c9fb48/go.mod h1:yOrGohF5eS9fcVR6Posxfv7PVDldqxEC1ZucTddhBPI= t73f.de/r/webs v0.0.0-20250916082100-37e0307e3368 h1:ul8l/OIWIlMDyt1Zc8N9dcTfXiT+p6o+6QUZbUp1Wqc= t73f.de/r/webs v0.0.0-20250916082100-37e0307e3368/go.mod h1:G3vn6fCTvYWwQby5cVNmXzHlOGhgBDfbbo/9OgIxy0g= t73f.de/r/zero v0.0.0-20250904163008-d96be3da2aef h1:ShqDx4DjirNThBlObVbmUqUwDuQ7qndxdFxBHs5Ui2Y= t73f.de/r/zero v0.0.0-20250904163008-d96be3da2aef/go.mod h1:cNaE2o9BWPFqLkmDuYaWrMJQS7GOo+wwmB9y8VfAF6c= t73f.de/r/zsx v0.0.0-20251007133258-f1844bbf951e h1:k0rbUZtWYeqSy8qrY3yOd8oyiT0hl8ekhpmVkx6AAfg= t73f.de/r/zsx v0.0.0-20251007133258-f1844bbf951e/go.mod h1:/JvaST9OR796HoQv23GBfRlbZAtn+qgEuYOnesf1qyo= |
Changes to sexp/sexp.go.
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import ( "errors" "fmt" "sort" "t73f.de/r/sx" "t73f.de/r/zsc/api" ) // EncodeZettel transforms zettel data into a sx object. func EncodeZettel(zettel api.ZettelData) sx.Object { return sx.MakeList( sx.MakeSymbol("zettel"), | > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import ( "errors" "fmt" "sort" "t73f.de/r/sx" "t73f.de/r/sx/sxbuiltins" "t73f.de/r/zsc/api" ) // EncodeZettel transforms zettel data into a sx object. func EncodeZettel(zettel api.ZettelData) sx.Object { return sx.MakeList( sx.MakeSymbol("zettel"), |
︙ | ︙ | |||
78 79 80 81 82 83 84 | Content: contentVals[1].(sx.String).GetValue(), }, nil } // EncodeMetaRights translates metadata/rights into a sx object. func EncodeMetaRights(mr api.MetaRights) *sx.Pair { return sx.MakeList( | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | Content: contentVals[1].(sx.String).GetValue(), }, nil } // EncodeMetaRights translates metadata/rights into a sx object. func EncodeMetaRights(mr api.MetaRights) *sx.Pair { return sx.MakeList( sx.MakeSymbol(sxbuiltins.List.Name), meta2sz(mr.Meta), sx.MakeList(sx.MakeSymbol("rights"), sx.Int64(int64(mr.Rights))), ) } func meta2sz(m api.ZettelMeta) sx.Object { var result sx.ListBuilder |
︙ | ︙ |
Changes to shtml/const.go.
︙ | ︙ | |||
9 10 11 12 13 14 15 | // // SPDX-License-Identifier: EUPL-1.2 // SPDX-FileCopyrightText: 2024-present Detlef Stern //----------------------------------------------------------------------------- package shtml | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | // // SPDX-License-Identifier: EUPL-1.2 // SPDX-FileCopyrightText: 2024-present Detlef Stern //----------------------------------------------------------------------------- package shtml import "t73f.de/r/sxwebs/sxhtml" // Symbols for HTML header tags var ( SymBody = sxhtml.MakeSymbol("body") SymHead = sxhtml.MakeSymbol("head") SymHTML = sxhtml.MakeSymbol("html") SymMeta = sxhtml.MakeSymbol("meta") SymScript = sxhtml.MakeSymbol("script") SymTitle = sxhtml.MakeSymbol("title") ) // Symbols for HTML body tags var ( SymA = sxhtml.MakeSymbol("a") SymASIDE = sxhtml.MakeSymbol("aside") symBLOCKQUOTE = sxhtml.MakeSymbol("blockquote") symBR = sxhtml.MakeSymbol("br") symCITE = sxhtml.MakeSymbol("cite") symCODE = sxhtml.MakeSymbol("code") symDD = sxhtml.MakeSymbol("dd") symDEL = sxhtml.MakeSymbol("del") SymDIV = sxhtml.MakeSymbol("div") symDL = sxhtml.MakeSymbol("dl") symDT = sxhtml.MakeSymbol("dt") symEM = sxhtml.MakeSymbol("em") SymEMBED = sxhtml.MakeSymbol("embed") SymFIGURE = sxhtml.MakeSymbol("figure") SymH1 = sxhtml.MakeSymbol("h1") SymH2 = sxhtml.MakeSymbol("h2") SymHR = sxhtml.MakeSymbol("hr") SymIMG = sxhtml.MakeSymbol("img") symINS = sxhtml.MakeSymbol("ins") symKBD = sxhtml.MakeSymbol("kbd") SymLI = sxhtml.MakeSymbol("li") symMARK = sxhtml.MakeSymbol("mark") SymOL = sxhtml.MakeSymbol("ol") SymP = sxhtml.MakeSymbol("p") symPRE = sxhtml.MakeSymbol("pre") symSAMP = sxhtml.MakeSymbol("samp") SymSPAN = sxhtml.MakeSymbol("span") SymSTRONG = sxhtml.MakeSymbol("strong") symSUB = sxhtml.MakeSymbol("sub") symSUP = sxhtml.MakeSymbol("sup") symTABLE = sxhtml.MakeSymbol("table") symTBODY = sxhtml.MakeSymbol("tbody") symTHEAD = sxhtml.MakeSymbol("thead") symTD = sxhtml.MakeSymbol("td") symTH = sxhtml.MakeSymbol("th") symTR = sxhtml.MakeSymbol("tr") SymUL = sxhtml.MakeSymbol("ul") ) // Symbols for HTML attribute keys var ( SymAttrClass = sxhtml.MakeSymbol("class") SymAttrHref = sxhtml.MakeSymbol("href") SymAttrID = sxhtml.MakeSymbol("id") SymAttrLang = sxhtml.MakeSymbol("lang") SymAttrOpen = sxhtml.MakeSymbol("open") SymAttrRel = sxhtml.MakeSymbol("rel") SymAttrRole = sxhtml.MakeSymbol("role") SymAttrSrc = sxhtml.MakeSymbol("src") SymAttrTarget = sxhtml.MakeSymbol("target") SymAttrTitle = sxhtml.MakeSymbol("title") SymAttrType = sxhtml.MakeSymbol("type") SymAttrValue = sxhtml.MakeSymbol("value") ) |
Changes to shtml/shtml.go.
︙ | ︙ | |||
65 66 67 68 69 70 71 | return nil } plist := sx.Nil() keys := a.Keys() for i := len(keys) - 1; i >= 0; i-- { key := keys[i] if key != zsx.DefaultAttribute && isValidName(key) { | | < | < < | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | return nil } plist := sx.Nil() keys := a.Keys() for i := len(keys) - 1; i >= 0; i-- { key := keys[i] if key != zsx.DefaultAttribute && isValidName(key) { plist = plist.Cons(sx.Cons(sxhtml.MakeSymbol(key), sx.MakeString(a[key]))) } } return plist } // Evaluate a metadata s-expression into a list of HTML s-expressions. func (ev *Evaluator) Evaluate(lst *sx.Pair, env *Environment) (*sx.Pair, error) { result := ev.Eval(lst, env) if err := env.err; err != nil { return nil, err |
︙ | ︙ | |||
121 122 123 124 125 126 127 | if env.err != nil || len(env.endnotes) == 0 { return nil } var result sx.ListBuilder result.AddN( SymOL, | | | < | < | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | if env.err != nil || len(env.endnotes) == 0 { return nil } var result sx.ListBuilder result.AddN( SymOL, sx.Nil().Cons(sx.Cons(SymAttrClass, sx.MakeString("zs-endnotes"))), ) for i, fni := range env.endnotes { noteNum := strconv.Itoa(i + 1) attrs := fni.attrs.Cons(sx.Cons(SymAttrClass, sx.MakeString("zs-endnote"))). Cons(sx.Cons(SymAttrValue, sx.MakeString(noteNum))). Cons(sx.Cons(SymAttrID, sx.MakeString("fn:"+fni.noteID))). Cons(sx.Cons(SymAttrRole, sx.MakeString("doc-endnote"))) backref := sx.Nil().Cons(sx.MakeString("\u21a9\ufe0e")). Cons(sx.Nil(). Cons(sx.Cons(SymAttrClass, sx.MakeString("zs-endnote-backref"))). Cons(sx.Cons(SymAttrHref, sx.MakeString("#fnref:"+fni.noteID))). Cons(sx.Cons(SymAttrRole, sx.MakeString("doc-backlink")))). Cons(SymA) var li sx.ListBuilder li.AddN(SymLI, attrs) li.ExtendBang(fni.noteHx) li.AddN(sx.MakeString(" "), backref) result.Add(li.List()) |
︙ | ︙ | |||
234 235 236 237 238 239 240 | } ev.fns[symVal] = fn } func (ev *Evaluator) bindMetadata() { ev.bind(sz.SymMeta, 0, ev.evalList) evalMetaString := func(args sx.Vector, env *Environment) sx.Object { | < < | < < < < | > > > > > > > > > > > > > > > > > > | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | } ev.fns[symVal] = fn } func (ev *Evaluator) bindMetadata() { ev.bind(sz.SymMeta, 0, ev.evalList) evalMetaString := func(args sx.Vector, env *Environment) sx.Object { return ev.evalMetaString(args[0], getString(args[1], env).GetValue(), env) } ev.bind(sz.SymTypeCredential, 2, evalMetaString) ev.bind(sz.SymTypeEmpty, 2, evalMetaString) ev.bind(sz.SymTypeID, 2, evalMetaString) ev.bind(sz.SymTypeNumber, 2, evalMetaString) ev.bind(sz.SymTypeString, 2, evalMetaString) ev.bind(sz.SymTypeTimestamp, 2, evalMetaString) ev.bind(sz.SymTypeURL, 2, evalMetaString) ev.bind(sz.SymTypeWord, 2, evalMetaString) evalMetaSet := func(args sx.Vector, env *Environment) sx.Object { var sb strings.Builder for obj := range getList(args[1], env).Values() { sb.WriteByte(' ') sb.WriteString(getString(obj, env).GetValue()) } s := sb.String() if len(s) > 0 { s = s[1:] } return ev.evalMetaString(args[0], s, env) } ev.bind(sz.SymTypeIDSet, 2, evalMetaSet) ev.bind(sz.SymTypeTagSet, 2, evalMetaSet) } func (ev *Evaluator) evalMetaString(nameObj sx.Object, content string, env *Environment) sx.Object { if env.err == nil { if nameSym, ok := sx.GetSymbol(nameObj); ok { a := make(zsx.Attributes, 2). Set("name", nameSym.GetValue()). Set("content", content) return ev.EvaluateMeta(a) } env.err = fmt.Errorf("%v/%T is not a symbol", nameObj, nameObj) } return sx.Nil() } // EvaluateMeta returns HTML meta object for an attribute. func (ev *Evaluator) EvaluateMeta(a zsx.Attributes) *sx.Pair { return sx.Nil().Cons(EvaluateAttributes(a)).Cons(SymMeta) } func (ev *Evaluator) bindBlocks() { ev.bind(zsx.SymBlock, 0, ev.evalList) ev.bind(zsx.SymPara, 0, func(args sx.Vector, env *Environment) sx.Object { return ev.evalSlice(args, env).Cons(SymP) }) ev.bind(zsx.SymHeading, 5, func(args sx.Vector, env *Environment) sx.Object { nLevel := getInt64(args[0], env) if nLevel <= 0 { env.err = fmt.Errorf("%v is a negative heading level", nLevel) return sx.Nil() } hLevel := nLevel + ev.headingOffset if hLevel > 6 { env.err = fmt.Errorf("%v is a too large heading level", hLevel) return sx.Nil() } sLevel := strconv.FormatInt(hLevel, 10) headingSymbol := sxhtml.MakeSymbol("h" + sLevel) a := GetAttributes(args[1], env) env.pushAttributes(a) defer env.popAttributes() if fragment := getString(args[3], env).GetValue(); fragment != "" { a = a.Set("id", ev.unique+fragment) } |
︙ | ︙ | |||
322 323 324 325 326 327 328 329 | return sx.Nil() } var result sx.ListBuilder result.Add(symBLOCKQUOTE) if attrs := EvaluateAttributes(GetAttributes(args[0], env)); attrs != nil { result.Add(attrs) } for _, elem := range args[1:] { | > | | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | return sx.Nil() } var result sx.ListBuilder result.Add(symBLOCKQUOTE) if attrs := EvaluateAttributes(GetAttributes(args[0], env)); attrs != nil { result.Add(attrs) } isCompact := isCompactList(args[1:]) for _, elem := range args[1:] { if quote, isPair := sx.GetPair(ev.Eval(makeCompactItem(isCompact, elem), env)); isPair { result.Add(quote.Cons(sxhtml.SymListSplice)) } } return result.List() }) ev.bind(zsx.SymDescription, 1, func(args sx.Vector, env *Environment) sx.Object { |
︙ | ︙ | |||
358 359 360 361 362 363 364 | dditem := getList(ddlst, env) result.Add(dditem.Cons(symDD)) } } return result.List() }) | | | | | | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | dditem := getList(ddlst, env) result.Add(dditem.Cons(symDD)) } } return result.List() }) ev.bind(zsx.SymTable, 2, func(args sx.Vector, env *Environment) sx.Object { thead := sx.Nil() if header := getList(args[1], env); !sx.IsNil(header) { thead = sx.Nil().Cons(ev.evalTableRow(symTH, header, env)).Cons(symTHEAD) } var tbody sx.ListBuilder if len(args) > 2 { tbody.Add(symTBODY) for _, row := range args[2:] { tbody.Add(ev.evalTableRow(symTD, getList(row, env), env)) } } table := sx.Nil() if !tbody.IsEmpty() { table = table.Cons(tbody.List()) |
︙ | ︙ | |||
428 429 430 431 432 433 434 | content := getString(args[1], env) if a.HasDefault() { content = sx.MakeString(visibleReplacer.Replace(content.GetValue())) } return evalVerbatim(a, content) }) ev.bind(zsx.SymVerbatimZettel, 0, nilFn) | | | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | content := getString(args[1], env) if a.HasDefault() { content = sx.MakeString(visibleReplacer.Replace(content.GetValue())) } return evalVerbatim(a, content) }) ev.bind(zsx.SymVerbatimZettel, 0, nilFn) ev.bind(zsx.SymBLOB, 3, func(args sx.Vector, env *Environment) sx.Object { a := GetAttributes(args[0], env) return evalBLOB(a, ev.evalSlice(args[3:], env), getString(args[1], env), getString(args[2], env)) }) ev.bind(zsx.SymTransclude, 2, func(args sx.Vector, env *Environment) sx.Object { if refSym, refValue := GetReference(args[1], env); refSym != nil { if refSym.IsEqualSymbol(zsx.SymRefStateExternal) { a := GetAttributes(args[0], env).Set("src", refValue).AddClass("external") // TODO: if len(args) > 2, add "alt" attr based on args[2:], as in SymEmbed return sx.Nil().Cons(sx.Nil().Cons(EvaluateAttributes(a)).Cons(SymIMG)).Cons(SymP) |
︙ | ︙ | |||
459 460 461 462 463 464 465 466 | return func(args sx.Vector, env *Environment) sx.Object { var result sx.ListBuilder result.Add(sym) if attrs := EvaluateAttributes(GetAttributes(args[0], env)); attrs != nil { result.Add(attrs) } if len(args) > 1 { for _, elem := range args[1:] { | > > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | return func(args sx.Vector, env *Environment) sx.Object { var result sx.ListBuilder result.Add(sym) if attrs := EvaluateAttributes(GetAttributes(args[0], env)); attrs != nil { result.Add(attrs) } if len(args) > 1 { isCompact := isCompactList(args[1:]) for _, elem := range args[1:] { var itemLb sx.ListBuilder itemLb.Add(SymLI) if res, isPair := sx.GetPair(ev.Eval(makeCompactItem(isCompact, elem), env)); isPair { itemLb.ExtendBang(res) } result.Add(itemLb.List()) } } return result.List() } } func isCompactList(elems sx.Vector) bool { for _, elem := range elems { item, isPair := sx.GetPair(elem) if !isPair { return false } if !zsx.SymBlock.IsEqual(item.Car()) { return false } item = item.Tail() if item.Tail() != nil { // more than two elements -> multiple paragraphs in item return false } head := item.Head() if !zsx.SymPara.IsEqual(head.Car()) { return false } } return true } func makeCompactItem(isCompact bool, elem sx.Object) sx.Object { if isCompact { if item, isPair := sx.GetPair(elem); isPair { elem = item.Tail().Head().Tail().Cons(zsx.SymInline) } } return elem } func (ev *Evaluator) evalDescriptionTerm(term *sx.Pair, env *Environment) *sx.Pair { var result sx.ListBuilder for obj := range term.Values() { elem := ev.Eval(obj, env) result.Add(elem) |
︙ | ︙ | |||
640 641 642 643 644 645 646 | noteNum := strconv.Itoa(len(env.endnotes) + 1) noteID := ev.unique + noteNum env.endnotes = append(env.endnotes, endnoteInfo{ noteID: noteID, noteAST: args[1:], noteHx: nil, attrs: attrPlist}) hrefAttr := sx.Nil().Cons(sx.Cons(SymAttrRole, sx.MakeString("doc-noteref"))). Cons(sx.Cons(SymAttrHref, sx.MakeString("#fn:"+noteID))). | | < | | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | noteNum := strconv.Itoa(len(env.endnotes) + 1) noteID := ev.unique + noteNum env.endnotes = append(env.endnotes, endnoteInfo{ noteID: noteID, noteAST: args[1:], noteHx: nil, attrs: attrPlist}) hrefAttr := sx.Nil().Cons(sx.Cons(SymAttrRole, sx.MakeString("doc-noteref"))). Cons(sx.Cons(SymAttrHref, sx.MakeString("#fn:"+noteID))). Cons(sx.Cons(SymAttrClass, sx.MakeString("zs-noteref"))) href := sx.Nil().Cons(sx.MakeString(noteNum)).Cons(hrefAttr).Cons(SymA) supAttr := sx.Nil().Cons(sx.Cons(SymAttrID, sx.MakeString("fnref:"+noteID))) return sx.Nil().Cons(href).Cons(supAttr).Cons(symSUP) }) ev.bind(zsx.SymFormatDelete, 1, ev.makeFormatFn(symDEL)) ev.bind(zsx.SymFormatEmph, 1, ev.makeFormatFn(symEM)) ev.bind(zsx.SymFormatInsert, 1, ev.makeFormatFn(symINS)) ev.bind(zsx.SymFormatMark, 1, ev.makeFormatFn(symMARK)) |
︙ | ︙ | |||
880 881 882 883 884 885 886 | } if ev.noLinks { return result.Cons(SymSPAN) } return result.Cons(EvaluateAttributes(a)).Cons(SymA) } | < < < < < < < < < | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 | } if ev.noLinks { return result.Cons(SymSPAN) } return result.Cons(EvaluateAttributes(a)).Cons(SymA) } func getString(val sx.Object, env *Environment) sx.String { if env.err == nil { if s, ok := sx.GetString(val); ok { return s } env.err = fmt.Errorf("%v/%T is not a string", val, val) } |
︙ | ︙ | |||
928 929 930 931 932 933 934 | return zsx.GetAttributes(getList(arg, env)) } // GetReference returns the reference symbol and the reference value of a reference pair. func GetReference(val sx.Object, env *Environment) (*sx.Symbol, string) { if env.err == nil { if p := getList(val, env); env.err == nil { | | | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | return zsx.GetAttributes(getList(arg, env)) } // GetReference returns the reference symbol and the reference value of a reference pair. func GetReference(val sx.Object, env *Environment) (*sx.Symbol, string) { if env.err == nil { if p := getList(val, env); env.err == nil { sym, val := zsx.GetReference(p) if sym != nil { return sym, val } env.err = fmt.Errorf("%v/%T is not a reference", val, val) } } return nil, "" |
︙ | ︙ |
Changes to sz/ref.go.
︙ | ︙ | |||
19 20 21 22 23 24 25 | "t73f.de/r/sx" "t73f.de/r/zsc/api" "t73f.de/r/zsc/domain/id" "t73f.de/r/zsx" ) | < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | "t73f.de/r/sx" "t73f.de/r/zsc/api" "t73f.de/r/zsc/domain/id" "t73f.de/r/zsx" ) // ScanReference scans a string and returns a reference. // // This function is very specific for Zettelstore. func ScanReference(s string) *sx.Pair { if len(s) == id.LengthZid { if _, err := id.Parse(s); err == nil { return zsx.MakeReference(SymRefStateZettel, s) } if s == "00000000000000" { return zsx.MakeReference(zsx.SymRefStateInvalid, s) } } else if len(s) > id.LengthZid && s[id.LengthZid] == '#' { zidPart := s[:id.LengthZid] if _, err := id.Parse(zidPart); err == nil { if u, err2 := url.Parse(s); err2 != nil || u.String() != s { return zsx.MakeReference(zsx.SymRefStateInvalid, s) } return zsx.MakeReference(SymRefStateZettel, s) } if zidPart == "00000000000000" { return zsx.MakeReference(zsx.SymRefStateInvalid, s) } } if strings.HasPrefix(s, api.QueryPrefix) { return zsx.MakeReference(SymRefStateQuery, s[len(api.QueryPrefix):]) } if strings.HasPrefix(s, "//") { if u, err := url.Parse(s[1:]); err == nil { if u.Scheme == "" && u.Opaque == "" && u.Host == "" && u.User == nil { if u.String() == s[1:] { return zsx.MakeReference(SymRefStateBased, s[1:]) } return zsx.MakeReference(zsx.SymRefStateInvalid, s) } } } if s == "" { return zsx.MakeReference(zsx.SymRefStateInvalid, s) } u, err := url.Parse(s) if err != nil || u.String() != s { return zsx.MakeReference(zsx.SymRefStateInvalid, s) } sym := zsx.SymRefStateExternal if u.Scheme == "" && u.Opaque == "" && u.Host == "" && u.User == nil { if s[0] == '#' { sym = zsx.SymRefStateSelf } else { sym = zsx.SymRefStateHosted } } return zsx.MakeReference(sym, s) } |
Changes to sz/zmk/block.go.
︙ | ︙ | |||
667 668 669 670 671 672 673 | case input.EOS: // add to table if cp.lastRow == nil { if row.IsEmpty() { return nil } cp.lastRow = sx.Cons(row.List(), nil) | | | 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | case input.EOS: // add to table if cp.lastRow == nil { if row.IsEmpty() { return nil } cp.lastRow = sx.Cons(row.List(), nil) return cp.lastRow.Cons(nil).Cons(nil).Cons(zsx.SymTable) } cp.lastRow = cp.lastRow.AppendBang(row.List()) return nil } // inp.Ch must be '|' } } |
︙ | ︙ | |||
739 740 741 742 743 744 745 | inp.Next() } inp.Next() // consume last '}' attrs := parseBlockAttributes(inp) inp.SkipToEOL() refText := string(inp.Src[posA:posE]) ref := cp.scanReference(refText) | | | 739 740 741 742 743 744 745 746 747 | inp.Next() } inp.Next() // consume last '}' attrs := parseBlockAttributes(inp) inp.SkipToEOL() refText := string(inp.Src[posA:posE]) ref := cp.scanReference(refText) return zsx.MakeTransclusion(attrs, ref, nil), true } |
Changes to sz/zmk/post-processor.go.
︙ | ︙ | |||
21 22 23 24 25 26 27 | ) var symInVerse = sx.MakeSymbol("in-verse") var symNoBlock = sx.MakeSymbol("no-block") type postProcessor struct{} | | | | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ) var symInVerse = sx.MakeSymbol("in-verse") var symNoBlock = sx.MakeSymbol("no-block") type postProcessor struct{} func (pp *postProcessor) VisitBefore(lst *sx.Pair, alst *sx.Pair) (sx.Object, bool) { if lst == nil { return nil, true } sym, isSym := sx.GetSymbol(lst.Car()) if !isSym { panic(lst) } if fn, found := symMap[sym]; found { return fn(pp, lst, alst), true } return nil, false } func (pp *postProcessor) VisitAfter(lst *sx.Pair, _ *sx.Pair) sx.Object { return lst } func (pp *postProcessor) visitPairList(lst *sx.Pair, alst *sx.Pair) *sx.Pair { var pList sx.ListBuilder for node := range lst.Pairs() { if elem, isPair := sx.GetPair(zsx.Walk(pp, node.Head(), alst)); isPair && elem != nil { pList.Add(elem) } } return pList.List() } var symMap map[*sx.Symbol]func(*postProcessor, *sx.Pair, *sx.Pair) *sx.Pair |
︙ | ︙ | |||
92 93 94 95 96 97 98 | symSeparator: ignoreProcess, } } func ignoreProcess(*postProcessor, *sx.Pair, *sx.Pair) *sx.Pair { return nil } | | | | | | | | | | | | | | | | | | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | symSeparator: ignoreProcess, } } func ignoreProcess(*postProcessor, *sx.Pair, *sx.Pair) *sx.Pair { return nil } func postProcessBlockList(pp *postProcessor, lst *sx.Pair, alst *sx.Pair) *sx.Pair { result := pp.visitPairList(lst.Tail(), alst) if result == nil { if noBlockPair := alst.Assoc(symNoBlock); noBlockPair == nil || sx.IsTrue(noBlockPair.Cdr()) { return nil } } return result.Cons(lst.Car()) } func postProcessInlineList(pp *postProcessor, lst *sx.Pair, alst *sx.Pair) *sx.Pair { sym := lst.Car() if rest := pp.visitInlines(lst.Tail(), alst); rest != nil { return rest.Cons(sym) } return nil } func postProcessRegion(pp *postProcessor, rn *sx.Pair, alst *sx.Pair) *sx.Pair { return doPostProcessRegion(pp, rn, alst, alst) } func postProcessRegionVerse(pp *postProcessor, rn *sx.Pair, alst *sx.Pair) *sx.Pair { return doPostProcessRegion(pp, rn, alst.Cons(sx.Cons(symInVerse, nil)), alst) } func doPostProcessRegion(pp *postProcessor, rn *sx.Pair, alstBlock, alstInline *sx.Pair) *sx.Pair { sym := rn.Car().(*sx.Symbol) next := rn.Tail() attrs := next.Car().(*sx.Pair) next = next.Tail() blocks := pp.visitPairList(next.Head(), alstBlock) text := pp.visitInlines(next.Tail(), alstInline) if blocks == nil && text == nil { return nil } return zsx.MakeRegion(sym, attrs, blocks, text) } func postProcessVerbatim(_ *postProcessor, verb *sx.Pair, _ *sx.Pair) *sx.Pair { if content, isString := sx.GetString(verb.Tail().Tail().Car()); isString && content.GetValue() != "" { return verb } return nil } func postProcessHeading(pp *postProcessor, hn *sx.Pair, alst *sx.Pair) *sx.Pair { next := hn.Tail() level := next.Car().(sx.Int64) next = next.Tail() attrs := next.Car().(*sx.Pair) next = next.Tail() slug := next.Car().(sx.String) next = next.Tail() fragment := next.Car().(sx.String) if text := pp.visitInlines(next.Tail(), alst); text != nil { return zsx.MakeHeading(int(level), attrs, text, slug.GetValue(), fragment.GetValue()) } return nil } func postProcessItemList(pp *postProcessor, ln *sx.Pair, alst *sx.Pair) *sx.Pair { attrs := ln.Tail().Head() elems := pp.visitListElems(ln.Tail(), alst) if elems == nil { return nil } return zsx.MakeList(ln.Car().(*sx.Symbol), attrs, elems) } func postProcessQuoteList(pp *postProcessor, ln *sx.Pair, alst *sx.Pair) *sx.Pair { attrs := ln.Tail().Head() elems := pp.visitListElems(ln.Tail(), alst.Cons(sx.Cons(symNoBlock, nil))) // Collect multiple paragraph items into one item. var newElems sx.ListBuilder var newPara sx.ListBuilder addtoParagraph := func() { |
︙ | ︙ | |||
202 203 204 205 206 207 208 | addtoParagraph() newElems.Add(item) } addtoParagraph() return zsx.MakeList(ln.Car().(*sx.Symbol), attrs, newElems.List()) } | | | | | | | | > | | | | | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | addtoParagraph() newElems.Add(item) } addtoParagraph() return zsx.MakeList(ln.Car().(*sx.Symbol), attrs, newElems.List()) } func (pp *postProcessor) visitListElems(ln *sx.Pair, alst *sx.Pair) *sx.Pair { var pList sx.ListBuilder for node := range ln.Tail().Pairs() { if elem := zsx.Walk(pp, node.Head(), alst); elem != nil { pList.Add(elem) } } return pList.List() } func postProcessDescription(pp *postProcessor, dl *sx.Pair, alst *sx.Pair) *sx.Pair { attrs := dl.Tail().Head() var dList sx.ListBuilder isTerm := false for node := range dl.Tail().Tail().Pairs() { isTerm = !isTerm if isTerm { dList.Add(pp.visitInlines(node.Head(), alst)) } else { dList.Add(zsx.Walk(pp, node.Head(), alst.Cons(sx.Cons(symNoBlock, nil)))) } } return dList.List().Cons(attrs).Cons(dl.Car()) } func postProcessTable(pp *postProcessor, tbl *sx.Pair, alst *sx.Pair) *sx.Pair { sym, next := tbl.Car(), tbl.Tail() attrs := next.Head() next = next.Tail() header := next.Head() if header != nil { // Already post-processed return tbl } rows, width := pp.visitRows(next.Tail(), alst) if rows == nil { // Header and row are nil -> no table return nil } header, rows, align := splitTableHeader(rows, width) alignRow(header, align) for node := range rows.Pairs() { alignRow(node.Head(), align) } return rows.Cons(header).Cons(attrs).Cons(sym) } func (pp *postProcessor) visitRows(rows *sx.Pair, alst *sx.Pair) (*sx.Pair, int) { maxWidth := 0 var pRows sx.ListBuilder for node := range rows.Pairs() { row := node.Head() row, width := pp.visitCells(row, alst) if maxWidth < width { maxWidth = width } pRows.Add(row) } return pRows.List(), maxWidth } func (pp *postProcessor) visitCells(cells *sx.Pair, alst *sx.Pair) (*sx.Pair, int) { width := 0 var pCells sx.ListBuilder for node := range cells.Pairs() { cell := node.Head() rest := cell.Tail() attrs := rest.Head() ins := pp.visitInlines(rest.Tail(), alst) pCells.Add(zsx.MakeCell(attrs, ins)) width++ } return pCells.List(), width } func splitTableHeader(rows *sx.Pair, width int) (header, realRows *sx.Pair, align []byte) { |
︙ | ︙ | |||
394 395 396 397 398 399 400 | case '>': return zsx.AttrAlignRight, true default: return sx.MakeString(""), false } } | | | | | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | case '>': return zsx.AttrAlignRight, true default: return sx.MakeString(""), false } } func (pp *postProcessor) visitInlines(lst *sx.Pair, alst *sx.Pair) *sx.Pair { length := lst.Length() if length <= 0 { return nil } inVerse := alst.Assoc(symInVerse) != nil vector := make([]*sx.Pair, 0, length) // 1st phase: process all childs, ignore ' ' / '\t' at start, and merge some elements for node := range lst.Pairs() { elem, isPair := sx.GetPair(zsx.Walk(pp, node.Head(), alst)) if !isPair || elem == nil { continue } elemSym := elem.Car() elemTail := elem.Tail() if inVerse && elemSym.IsEqual(zsx.SymText) { |
︙ | ︙ | |||
523 524 525 526 527 528 529 | if content, isString := sx.GetString(tail.Car()); isString && content.GetValue() != "" { return txt } } return nil } | | | | | | | | | | | | | | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | if content, isString := sx.GetString(tail.Car()); isString && content.GetValue() != "" { return txt } } return nil } func postProcessSoft(_ *postProcessor, sn *sx.Pair, alst *sx.Pair) *sx.Pair { if alst.Assoc(symInVerse) == nil { return sn } return sx.Cons(zsx.SymHard, nil) } func postProcessEndnote(pp *postProcessor, en *sx.Pair, alst *sx.Pair) *sx.Pair { next := en.Tail() attrs := next.Car().(*sx.Pair) if text := pp.visitInlines(next.Tail(), alst); text != nil { return zsx.MakeEndnote(attrs, text) } return zsx.MakeEndnote(attrs, sx.Nil()) } func postProcessMark(pp *postProcessor, en *sx.Pair, alst *sx.Pair) *sx.Pair { next := en.Tail() mark := next.Car().(sx.String) next = next.Tail() slug := next.Car().(sx.String) next = next.Tail() fragment := next.Car().(sx.String) text := pp.visitInlines(next.Tail(), alst) return zsx.MakeMark(mark.GetValue(), slug.GetValue(), fragment.GetValue(), text) } func postProcessInlines4(pp *postProcessor, ln *sx.Pair, alst *sx.Pair) *sx.Pair { sym := ln.Car() next := ln.Tail() attrs := next.Car() next = next.Tail() val3 := next.Car() text := pp.visitInlines(next.Tail(), alst) return text.Cons(val3).Cons(attrs).Cons(sym) } func postProcessEmbed(pp *postProcessor, ln *sx.Pair, alst *sx.Pair) *sx.Pair { next := ln.Tail() attrs := next.Car().(*sx.Pair) next = next.Tail() ref := next.Car() next = next.Tail() syntax := next.Car().(sx.String) text := pp.visitInlines(next.Tail(), alst) return zsx.MakeEmbed(attrs, ref, syntax.GetValue(), text) } func postProcessFormat(pp *postProcessor, fn *sx.Pair, alst *sx.Pair) *sx.Pair { symFormat := fn.Car().(*sx.Symbol) next := fn.Tail() // Attrs attrs := next.Car().(*sx.Pair) next = next.Tail() // Possible inlines if next == nil { return fn } inlines := pp.visitInlines(next, alst) return zsx.MakeFormat(symFormat, attrs, inlines) } |
Changes to sz/zmk/zmk.go.
︙ | ︙ | |||
57 58 59 60 61 62 63 | lastPara = cp.parseBlock(&blkBuild, lastPara) } if cp.nestingLevel != 0 { panic("Nesting level was not decremented") } var pp postProcessor | | < < < | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | lastPara = cp.parseBlock(&blkBuild, lastPara) } if cp.nestingLevel != 0 { panic("Nesting level was not decremented") } var pp postProcessor return pp.visitPairList(blkBuild.List(), nil).Cons(zsx.SymBlock) } func withQueryPrefix(src []byte) bool { return len(src) > len(api.QueryPrefix) && string(src[:len(api.QueryPrefix)]) == api.QueryPrefix } // runeModGrave is Unicode code point U+02CB (715) called "MODIFIER LETTER |
︙ | ︙ |
Changes to sz/zmk/zmk_test.go.
︙ | ︙ | |||
53 54 55 56 57 58 59 | var parser zmk.Parser for tcn, tc := range tcs { t.Run(fmt.Sprintf("TC=%02d,src=%q", tcn, tc.source), func(st *testing.T) { st.Helper() inp := input.NewInput([]byte(tc.source)) parser.Initialize(inp) ast := parser.Parse() | > > > | | > > > | | | | > > > > > | | | | | | | | | | | | | | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | var parser zmk.Parser for tcn, tc := range tcs { t.Run(fmt.Sprintf("TC=%02d,src=%q", tcn, tc.source), func(st *testing.T) { st.Helper() inp := input.NewInput([]byte(tc.source)) parser.Initialize(inp) ast := parser.Parse() if got := ast.String(); tc.want != got { st.Errorf("none\nwant=%q\n got=%q", tc.want, got) } copyAST := zsx.Walk(astWalker{}, ast, nil) if got := copyAST.String(); tc.want != got { st.Errorf("copy\nwant=%q\n got=%q", tc.want, got) } zsx.WalkIt(astWalkerIt{}, ast, nil) if got := ast.String(); tc.want != got { st.Errorf("itit\nwant=%q\n got=%q", tc.want, got) } }) } } type astWalker struct{} func (astWalker) VisitBefore(*sx.Pair, *sx.Pair) (sx.Object, bool) { return sx.Nil(), false } func (astWalker) VisitAfter(node *sx.Pair, _ *sx.Pair) sx.Object { return node } type astWalkerIt struct{} func (astWalkerIt) VisitBefore(*sx.Pair, *sx.Pair) bool { return false } func (astWalkerIt) VisitAfter(*sx.Pair, *sx.Pair) {} func TestEdges(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"\"\"\"\n; \n0{{0}}{0}\n\"\"\"", "(BLOCK (REGION-VERSE () ((DESCRIPTION () ()) (PARA (TEXT \"0\") (EMBED ((\"0\" . \"\")) (HOSTED \"0\") \"\")))))"}, }) } func TestEOL(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"", "(BLOCK)"}, {"\n", "(BLOCK)"}, {"\r", "(BLOCK)"}, {"\r\n", "(BLOCK)"}, {"\n\n", "(BLOCK)"}, }) } func TestText(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"abcd", "(BLOCK (PARA (TEXT \"abcd\")))"}, {"ab cd", "(BLOCK (PARA (TEXT \"ab cd\")))"}, {"abcd ", "(BLOCK (PARA (TEXT \"abcd\")))"}, {" abcd", "(BLOCK (PARA (TEXT \"abcd\")))"}, {"\\", "(BLOCK (PARA (TEXT \"\\\\\")))"}, {"\\\n", "(BLOCK)"}, {"\\\ndef", "(BLOCK (PARA (HARD) (TEXT \"def\")))"}, {"\\\r", "(BLOCK)"}, {"\\\rdef", "(BLOCK (PARA (HARD) (TEXT \"def\")))"}, {"\\\r\n", "(BLOCK)"}, {"\\\r\ndef", "(BLOCK (PARA (HARD) (TEXT \"def\")))"}, {"\\a", "(BLOCK (PARA (TEXT \"a\")))"}, {"\\aa", "(BLOCK (PARA (TEXT \"aa\")))"}, {"a\\a", "(BLOCK (PARA (TEXT \"aa\")))"}, {"\\+", "(BLOCK (PARA (TEXT \"+\")))"}, {"\\ ", "(BLOCK (PARA (TEXT \"\u00a0\")))"}, {"http://a, http://b", "(BLOCK (PARA (TEXT \"http://a, http://b\")))"}, }) } func TestSpace(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {" ", "(BLOCK)"}, {"\t", "(BLOCK)"}, {" ", "(BLOCK)"}, }) } func TestSoftBreak(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"x\ny", "(BLOCK (PARA (TEXT \"x\") (SOFT) (TEXT \"y\")))"}, {"z\n", "(BLOCK (PARA (TEXT \"z\")))"}, {" \n ", "(BLOCK)"}, {" \n", "(BLOCK)"}, }) } func TestHardBreak(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"x \ny", "(BLOCK (PARA (TEXT \"x\") (HARD) (TEXT \"y\")))"}, {"z \n", "(BLOCK (PARA (TEXT \"z\")))"}, {" \n ", "(BLOCK)"}, {" \n", "(BLOCK)"}, }) } func TestLink(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"[", "(BLOCK (PARA (TEXT \"[\")))"}, |
︙ | ︙ | |||
491 492 493 494 495 496 497 | {"E: &,?;c.", "(BLOCK (PARA (TEXT \"E: &,?;c.\")))"}, }) } func TestVerbatimZettel(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ | | | | | | | | | | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | {"E: &,?;c.", "(BLOCK (PARA (TEXT \"E: &,?;c.\")))"}, }) } func TestVerbatimZettel(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"@@@\n@@@", "(BLOCK)"}, {"@@@\nabc\n@@@", "(BLOCK (VERBATIM-ZETTEL () \"abc\"))"}, {"@@@@def\nabc\n@@@@", "(BLOCK (VERBATIM-ZETTEL ((\"\" . \"def\")) \"abc\"))"}, }) } func TestVerbatimCode(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"```\n```", "(BLOCK)"}, {"```\nabc\n```", "(BLOCK (VERBATIM-CODE () \"abc\"))"}, {"```\nabc\n````", "(BLOCK (VERBATIM-CODE () \"abc\"))"}, {"````\nabc\n````", "(BLOCK (VERBATIM-CODE () \"abc\"))"}, {"````\nabc\n```\n````", "(BLOCK (VERBATIM-CODE () \"abc\\n```\"))"}, {"````go\nabc\n````", "(BLOCK (VERBATIM-CODE ((\"\" . \"go\")) \"abc\"))"}, }) } func TestVerbatimEval(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"~~~\n~~~", "(BLOCK)"}, {"~~~\nabc\n~~~", "(BLOCK (VERBATIM-EVAL () \"abc\"))"}, {"~~~\nabc\n~~~~", "(BLOCK (VERBATIM-EVAL () \"abc\"))"}, {"~~~~\nabc\n~~~~", "(BLOCK (VERBATIM-EVAL () \"abc\"))"}, {"~~~~\nabc\n~~~\n~~~~", "(BLOCK (VERBATIM-EVAL () \"abc\\n~~~\"))"}, {"~~~~go\nabc\n~~~~", "(BLOCK (VERBATIM-EVAL ((\"\" . \"go\")) \"abc\"))"}, }) } func TestVerbatimMath(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"$$$\n$$$", "(BLOCK)"}, {"$$$\nabc\n$$$", "(BLOCK (VERBATIM-MATH () \"abc\"))"}, {"$$$\nabc\n$$$$", "(BLOCK (VERBATIM-MATH () \"abc\"))"}, {"$$$$\nabc\n$$$$", "(BLOCK (VERBATIM-MATH () \"abc\"))"}, {"$$$$\nabc\n$$$\n$$$$", "(BLOCK (VERBATIM-MATH () \"abc\\n$$$\"))"}, {"$$$$go\nabc\n$$$$", "(BLOCK (VERBATIM-MATH ((\"\" . \"go\")) \"abc\"))"}, }) } func TestVerbatimComment(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"%%%\n%%%", "(BLOCK)"}, {"%%%\nabc\n%%%", "(BLOCK (VERBATIM-COMMENT () \"abc\"))"}, {"%%%%go\nabc\n%%%%", "(BLOCK (VERBATIM-COMMENT ((\"\" . \"go\")) \"abc\"))"}, }) } func TestPara(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"a\n\nb", "(BLOCK (PARA (TEXT \"a\")) (PARA (TEXT \"b\")))"}, {"a\n \nb", "(BLOCK (PARA (TEXT \"a\")) (PARA (TEXT \"b\")))"}, }) } func TestSpanRegion(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {":::\n:::", "(BLOCK)"}, {":::\nabc\n:::", "(BLOCK (REGION-BLOCK () ((PARA (TEXT \"abc\")))))"}, {":::\nabc\n::::", "(BLOCK (REGION-BLOCK () ((PARA (TEXT \"abc\")))))"}, {"::::\nabc\n::::", "(BLOCK (REGION-BLOCK () ((PARA (TEXT \"abc\")))))"}, {"::::\nabc\n:::\ndef\n:::\n::::", "(BLOCK (REGION-BLOCK () ((PARA (TEXT \"abc\")) (REGION-BLOCK () ((PARA (TEXT \"def\")))))))"}, {":::{go}\n:::a", "(BLOCK (REGION-BLOCK ((\"go\" . \"\")) () (TEXT \"a\")))"}, {":::\nabc\n::: def ", "(BLOCK (REGION-BLOCK () ((PARA (TEXT \"abc\"))) (TEXT \"def\")))"}, }) } func TestQuoteRegion(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"<<<\n<<<", "(BLOCK)"}, {"<<<\nabc\n<<<", "(BLOCK (REGION-QUOTE () ((PARA (TEXT \"abc\")))))"}, {"<<<\nabc\n<<<<", "(BLOCK (REGION-QUOTE () ((PARA (TEXT \"abc\")))))"}, {"<<<<\nabc\n<<<<", "(BLOCK (REGION-QUOTE () ((PARA (TEXT \"abc\")))))"}, {"<<<<\nabc\n<<<\ndef\n<<<\n<<<<", "(BLOCK (REGION-QUOTE () ((PARA (TEXT \"abc\")) (REGION-QUOTE () ((PARA (TEXT \"def\")))))))"}, {"<<<go\n<<< a", "(BLOCK (REGION-QUOTE ((\"\" . \"go\")) () (TEXT \"a\")))"}, {"<<<\nabc\n<<< def ", "(BLOCK (REGION-QUOTE () ((PARA (TEXT \"abc\"))) (TEXT \"def\")))"}, }) } func TestVerseRegion(t *testing.T) { t.Parallel() checkTcs(t, replace("\"", nil, TestCases{ {"$$$\n$$$", "(BLOCK)"}, {"$$$\nabc\n$$$", "(BLOCK (REGION-VERSE () ((PARA (TEXT \"abc\")))))"}, {"$$$\nabc\n$$$$", "(BLOCK (REGION-VERSE () ((PARA (TEXT \"abc\")))))"}, {"$$$$\nabc\n$$$$", "(BLOCK (REGION-VERSE () ((PARA (TEXT \"abc\")))))"}, {"$$$\nabc\ndef\n$$$", "(BLOCK (REGION-VERSE () ((PARA (TEXT \"abc\") (HARD) (TEXT \"def\")))))"}, {"$$$$\nabc\n$$$\ndef\n$$$\n$$$$", "(BLOCK (REGION-VERSE () ((PARA (TEXT \"abc\")) (REGION-VERSE () ((PARA (TEXT \"def\")))))))"}, {"$$$go\n$$$x", "(BLOCK (REGION-VERSE ((\"\" . \"go\")) () (TEXT \"x\")))"}, {"$$$\nabc\n$$$ def ", "(BLOCK (REGION-VERSE () ((PARA (TEXT \"abc\"))) (TEXT \"def\")))"}, |
︙ | ︙ | |||
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | {"; abc\n: def\n\n ghi\n\n jkl", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\")) (PARA (TEXT \"ghi\")) (PARA (TEXT \"jkl\"))))))"}, {"; abc\n:", "(BLOCK (DESCRIPTION () ((TEXT \"abc\"))) (PARA (TEXT \":\")))"}, {"; abc\n: def\n: ghi", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\"))) (BLOCK (PARA (TEXT \"ghi\"))))))"}, {"; abc\n: def\n; ghi\n: jkl", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\")))) ((TEXT \"ghi\")) (BLOCK (BLOCK (PARA (TEXT \"jkl\"))))))"}, // Empty description {"; abc\n: ", "(BLOCK (DESCRIPTION () ((TEXT \"abc\"))) (PARA (TEXT \":\")))"}, // Empty continuation of definition {"; abc\n: def\n ", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\"))))))"}, }) } func TestTable(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ | > | | | | | | | | | | | | | | | | | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 | {"; abc\n: def\n\n ghi\n\n jkl", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\")) (PARA (TEXT \"ghi\")) (PARA (TEXT \"jkl\"))))))"}, {"; abc\n:", "(BLOCK (DESCRIPTION () ((TEXT \"abc\"))) (PARA (TEXT \":\")))"}, {"; abc\n: def\n: ghi", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\"))) (BLOCK (PARA (TEXT \"ghi\"))))))"}, {"; abc\n: def\n; ghi\n: jkl", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\")))) ((TEXT \"ghi\")) (BLOCK (BLOCK (PARA (TEXT \"jkl\"))))))"}, // Empty description {"; abc\n: ", "(BLOCK (DESCRIPTION () ((TEXT \"abc\"))) (PARA (TEXT \":\")))"}, {"; abc\n; def\n: ghi", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK) ((TEXT \"def\")) (BLOCK (BLOCK (PARA (TEXT \"ghi\"))))))"}, // Empty continuation of definition {"; abc\n: def\n ", "(BLOCK (DESCRIPTION () ((TEXT \"abc\")) (BLOCK (BLOCK (PARA (TEXT \"def\"))))))"}, }) } func TestTable(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"|", "(BLOCK)"}, {"||", "(BLOCK (TABLE () () ((CELL ()))))"}, {"| |", "(BLOCK (TABLE () () ((CELL ()))))"}, {"|a", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")))))"}, {"|a|", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")))))"}, {"|a| ", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")) (CELL ()))))"}, {"|a|b", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")) (CELL () (TEXT \"b\")))))"}, {"|a\n|b", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\"))) ((CELL () (TEXT \"b\")))))"}, {"|a|b\n|c|d", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")) (CELL () (TEXT \"b\"))) ((CELL () (TEXT \"c\")) (CELL () (TEXT \"d\")))))"}, {"|%", "(BLOCK)"}, {"|=a", "(BLOCK (TABLE () ((CELL () (TEXT \"a\")))))"}, {"|=a\n|b", "(BLOCK (TABLE () ((CELL () (TEXT \"a\"))) ((CELL () (TEXT \"b\")))))"}, {"|a|b\n|%---\n|c|d", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")) (CELL () (TEXT \"b\"))) ((CELL () (TEXT \"c\")) (CELL () (TEXT \"d\")))))"}, {"|a|b\n|c", "(BLOCK (TABLE () () ((CELL () (TEXT \"a\")) (CELL () (TEXT \"b\"))) ((CELL () (TEXT \"c\")) (CELL ()))))"}, {"|=<a>\n|b|c", "(BLOCK (TABLE () ((CELL ((align . \"left\")) (TEXT \"a\")) (CELL ())) ((CELL ((align . \"right\")) (TEXT \"b\")) (CELL () (TEXT \"c\")))))"}, {"|=<a|=b>\n||", "(BLOCK (TABLE () ((CELL ((align . \"left\")) (TEXT \"a\")) (CELL ((align . \"right\")) (TEXT \"b\"))) ((CELL ()) (CELL ((align . \"right\"))))))"}, }) } func TestTransclude(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"{{{a}}}", "(BLOCK (TRANSCLUDE () (HOSTED \"a\")))"}, |
︙ | ︙ | |||
852 853 854 855 856 857 858 | {"::a::{.go .py}", "(BLOCK (PARA (FORMAT-SPAN ((\"class\" . \"go py\")) (TEXT \"a\"))))"}, }) } func TestTemp(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ | | | 864 865 866 867 868 869 870 871 872 873 | {"::a::{.go .py}", "(BLOCK (PARA (FORMAT-SPAN ((\"class\" . \"go py\")) (TEXT \"a\"))))"}, }) } func TestTemp(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"", "(BLOCK)"}, }) } |