Index: VERSION ================================================================== --- VERSION +++ VERSION @@ -1,1 +1,1 @@ -0.10.0 +0.11.0-dev Index: cmd/register.go ================================================================== --- cmd/register.go +++ cmd/register.go @@ -1,7 +1,7 @@ //----------------------------------------------------------------------------- -// Copyright (c) 2020-2022 Detlef Stern +// Copyright (c) 2020-2023 Detlef Stern // // This file is part of Zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations @@ -20,15 +20,14 @@ _ "zettelstore.de/z/box/membox" // Allow to use in-memory box. _ "zettelstore.de/z/encoder/htmlenc" // Allow to use HTML encoder. _ "zettelstore.de/z/encoder/mdenc" // Allow to use markdown encoder. _ "zettelstore.de/z/encoder/sexprenc" // Allow to use sexpr encoder. _ "zettelstore.de/z/encoder/textenc" // Allow to use text encoder. - _ "zettelstore.de/z/encoder/zjsonenc" // Allow to use ZJSON encoder. _ "zettelstore.de/z/encoder/zmkenc" // Allow to use zmk encoder. _ "zettelstore.de/z/kernel/impl" // Allow kernel implementation to create itself _ "zettelstore.de/z/parser/blob" // Allow to use BLOB parser. _ "zettelstore.de/z/parser/draw" // Allow to use draw parser. _ "zettelstore.de/z/parser/markdown" // Allow to use markdown parser. _ "zettelstore.de/z/parser/none" // Allow to use none parser. _ "zettelstore.de/z/parser/plain" // Allow to use plain parser. _ "zettelstore.de/z/parser/zettelmark" // Allow to use zettelmark parser. ) Index: docs/manual/00001004051200.zettel ================================================================== --- docs/manual/00001004051200.zettel +++ docs/manual/00001004051200.zettel @@ -2,11 +2,11 @@ title: The ''file'' sub-command role: manual tags: #command #configuration #manual #zettelstore syntax: zmk created: 20210126175322 -modified: 20230109105434 +modified: 20230125222036 Reads zettel data from a file (or from standard input / stdin) and renders it to standard output / stdout. This allows Zettelstore to render files manually. ``` zettelstore file [-t FORMAT] [file-1 [file-2]] @@ -17,14 +17,13 @@ Supported values are: [[''html''|00001012920510]] (default), [[''md''|00001012920513]], [[''sexpr''|00001012920516]], [[''text''|00001012920519]], - [[''zjson''|00001012920503]] (deprecated in v0.11), and [[''zmk''|00001012920522]]. ; ''file-1'' : Specifies the file name, where at least metadata is read. If ''file-2'' is not given, the zettel content is also read from here. ; ''file-2'' : File name where the zettel content is stored. If neither ''file-1'' nor ''file-2'' are given, metadata and zettel content are read from standard input / stdin. Index: docs/manual/00001012920500.zettel ================================================================== --- docs/manual/00001012920500.zettel +++ docs/manual/00001012920500.zettel @@ -2,15 +2,14 @@ title: Encodings available via the [[API|00001012000000]] role: manual tags: #api #manual #reference #zettelstore syntax: zmk created: 20210126175322 -modified: 20230109104839 +modified: 20230125222102 A zettel representation can be encoded in various formats for further processing. * [[html|00001012920510]] * [[md|00001012920513]] * [[sexpr|00001012920516]] * [[text|00001012920519]] -* [[zjson|00001012920503]] (will be deprecated in v0.11) * [[zmk|00001012920522]] DELETED docs/manual/00001012920503.zettel Index: docs/manual/00001012920503.zettel ================================================================== --- docs/manual/00001012920503.zettel +++ docs/manual/00001012920503.zettel @@ -1,38 +0,0 @@ -id: 00001012920503 -title: ZJSON Encoding -role: manual -tags: #api #manual #reference #zettelstore -syntax: zmk -created: 20210126175322 -modified: 20230109104722 - -**Note**: ZJSON encoding will be deprecated in v0.11 ---- -A zettel representation that allows to process the syntactic structure of a zettel. -It is a JSON-based encoding format, but different to the structures returned by using the plain [[endpoint|00001012920000]] ''/z/{ID}''. - -For an example, take a look at the ZJSON encoding of this page, which is available via the ""Info"" sub-page of this zettel: - -* [[//z/00001012920503?enc=zjson&part=zettel]], -* [[//z/00001012920503?enc=zjson&part=meta]], -* [[//z/00001012920503?enc=zjson&part=content]]. - -If transferred via HTTP, the content type will be ''application/json''. - -A full zettel encoding results in a JSON object with two keys: ''"meta"'' and ''"content"''. -Both values are the same as if you have requested just the appropriate [[part|00001012920800]]. - -=== Encoding of metadata -Metadata encoding results in a JSON object, where each metadata key is mapped to the same JSON object name. -The associated value is itself a JSON object with two names. -The first name ``""`` references the [[metadata key type|00001006030000]]. -Depending on the key type, the other name denotes the value of the metadata element. -The meaning of these names is [[well defined|00001012920582]], as well as the [[mapping of key types to used object names|00001012920584]]. - -=== Encoding of zettel content -The content encoding results in a JSON array of objects, where each objects represents a Zettelmarkup element. - -Every [!zettelmarkup|Zettelmarkup] element is encoded as a JSON object. -These objects always contain the empty name ''""'' with a string value describing the type of Zettelmarkup element. -Depending on the type, other one letter names denotes the details of the element. -The meaning of these names is [[well defined|00001012920588]]. Index: docs/manual/00001012920516.zettel ================================================================== --- docs/manual/00001012920516.zettel +++ docs/manual/00001012920516.zettel @@ -2,17 +2,15 @@ title: Sexpr Encoding role: manual tags: #api #manual #reference #zettelstore syntax: zmk created: 20220422181104 -modified: 20230109104812 +modified: 20230125222210 A zettel representation that is a [[s-expression|https://en.wikipedia.org/wiki/S-expression]] (also known as symbolic expression). -It is an alternative to the [[ZJSON encoding|00001012920503]][^ZJSON will be deprecated in v0.11]. -Both encodings are (relatively) easy to parse and contain all relevant information of a zettel, metadata and content. - +It is (relatively) easy to parse and contain all relevant information of a zettel, metadata and content. For example, take a look at the Sexpr encoding of this page, which is available via the ""Info"" sub-page of this zettel: * [[//z/00001012920516?enc=sexpr&part=zettel]], * [[//z/00001012920516?enc=sexpr&part=meta]], * [[//z/00001012920516?enc=sexpr&part=content]]. DELETED docs/manual/00001012920582.zettel Index: docs/manual/00001012920582.zettel ================================================================== --- docs/manual/00001012920582.zettel +++ docs/manual/00001012920582.zettel @@ -1,16 +0,0 @@ -id: 00001012920582 -title: ZJSON Encoding: List of Valid Metadata Value Objects Names -role: manual -tags: #api #manual #reference #zettelstore -syntax: zmk -modified: 20230109104713 - -**Note**: ZJSON encoding will be deprecated in v0.11 ---- -Every Metadata value element is mapped to a JSON object with some well defined names / keys. - -|=Name | JSON Value | Meaning -| ''"\"'' | string | The type of the Zettelmarkup element. -| ''"i"'' | array | A sequence of [[inline-structured|00001007040000]] elements. -| ''"s"'' | string | The first / major string value of an element. -| ''"y"'' | array | A set of string values. DELETED docs/manual/00001012920584.zettel Index: docs/manual/00001012920584.zettel ================================================================== --- docs/manual/00001012920584.zettel +++ docs/manual/00001012920584.zettel @@ -1,30 +0,0 @@ -id: 00001012920584 -title: ZJSON Encoding: Mapping of Metadata Key Types to Object Names -role: manual -tags: #api #manual #reference #zettelstore -syntax: zmk -modified: 20230109104703 - -**Note**: ZJSON encoding will be deprecated in v0.11 ---- -Every [[Metadata key|00001006030000]] is mapped to an [[object name|00001012920582]] where its value is encoded. - -|=Type | JSON Object Name | Remark -| [[Credential|00001006031000]] | ''"s"'' | A string with the decrypted credential. -| [[EString|00001006031500]] | ''"s"'' | A possibly empty string. -| [[Identifier|00001006032000]] | ''"s"'' | A string containing a [[zettel identifier|00001006050000]]. -| [[IdentifierSet|00001006032500]] | ''"y"'' | An array of strings containing [[zettel identifier|00001006050000]]. -| [[Number|00001006033000]] | ''"s"'' | A string containing a numeric value. -| [[String|00001006033500]] | ''"s"'' | A non-empty string. -| [[TagSet|00001006034000]] | ''"y"'' | An array of string containing zettel tags. -| [[Timestamp|00001006034500]] | ''"s"'' | A string containing a timestamp in the format YYYYMMDDHHmmSS. -| [[URL|00001006035000]] | ''"s"'' | A string containing an URL. -| [[Word|00001006035500]] | ''"s"'' | A string containing a word (no space characters) -| [[WordSet|00001006036000]] | ''"y"'' | An array of strings containing words. -| [[Zettelmarkup|00001006036500]] | ''"i"'' | A sequence of [[inline-structured|00001007040000]] elements. - -Please note, that metadata is weakly typed. -Every metadata key expects a certain type. -But the user is free to enter something different. -For example, even if the metadata type is ""number"", its value could still be ""abc"". -However, the mapping itself is always valid. DELETED docs/manual/00001012920588.zettel Index: docs/manual/00001012920588.zettel ================================================================== --- docs/manual/00001012920588.zettel +++ docs/manual/00001012920588.zettel @@ -1,27 +0,0 @@ -id: 00001012920588 -title: ZJSON Encoding: List of Valid Zettelmarkup Element Objects Names -role: manual -tags: #api #manual #reference #zettelstore -syntax: zmk -modified: 20230109104648 - -**Note**: ZJSON encoding will be deprecated in v0.11 ---- - -Every [[Zettelmarkup|00001007000000]] element is mapped to a JSON object with some well defined names / keys. - -|=Name | JSON Value | Meaning -| ''"\"'' | string | The type of the Zettelmarkup element. -| ''"a"'' | object | Additional attributes of the element. -| ''"b"'' | array | A sequence of [[block-structured|00001007030000]] elements. -| ''"c"'' | array | A sequence of a sequence of (sub-) list elements or [[inline-structured|00001007040000]] elements. Used for nested lists. -| ''"d"'' | array | A sequence of description list elements, where each element is an object of a definition term and a list of descriptions. -| ''"e"'' | array | A sequence of descriptions: a JSON array of simple description, which is itself a JSON array of block structured elements. -| ''"i"'' | array | A sequence of [[inline-structured|00001007040000]] elements. -| ''"j"'' | object | An objects describing a BLOB element. -| ''"n"'' | number | A numeric value, e.g. for specifying the [[heading|00001007030300]] level. -| ''"o"'' | string | A base64 encoded binary value. Used in some BLOB elements. -| ''"p"'' | array | A sequence of two elements: a sequence of [[table|00001007031000]] header value, followed by a sequence of sequence of table row values. -| ''"q"'' | string | A second string value, if ''""s""'' is already used. -| ''"s"'' | string | The first / major string value of an element. -| ''"v"'' | string | A third string value, if ''""q""'' is already used. Index: encoder/encoder_blob_test.go ================================================================== --- encoder/encoder_blob_test.go +++ encoder/encoder_blob_test.go @@ -38,11 +38,10 @@ 0x55, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x62, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x36, 0x37, 0x7c, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, }, expect: expectMap{ - encoderZJSON: `[{"":"BLOB","q":[{"":"Text","s":"PNG"}],"s":"png","o":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg=="}]`, encoderHTML: `
Hello, world
", encoderMD: "Hello, world", encoderSexpr: `((PARA (TEXT "Hello,") (SPACE) (TEXT "world")))`, encoderText: "Hello, world", encoderZmk: useZmk, @@ -37,11 +35,10 @@ }, { descr: "Simple block comment", zmk: "%%%\nNo\nrender\n%%%", expect: expectMap{ - encoderZJSON: `[{"":"CommentBlock","s":"No\nrender"}]`, encoderHTML: ``, encoderMD: "", encoderSexpr: `((VERBATIM-COMMENT () "No\nrender"))`, encoderText: ``, encoderZmk: useZmk, @@ -49,11 +46,10 @@ }, { descr: "Rendered block comment", zmk: "%%%{-}\nRender\n%%%", expect: expectMap{ - encoderZJSON: `[{"":"CommentBlock","a":{"-":""},"s":"Render"}]`, encoderHTML: "", encoderMD: "", encoderSexpr: `((VERBATIM-COMMENT (("-" "")) "Render"))`, encoderText: ``, encoderZmk: useZmk, @@ -61,11 +57,10 @@ }, { descr: "Simple Heading", zmk: `=== Top`, expect: expectMap{ - encoderZJSON: `[{"":"Heading","n":1,"s":"top","i":[{"":"Text","s":"Top"}]}]`, encoderHTML: "T1
T3
T6
Text *abc
", encoderMD: "Text\n*abc", encoderSexpr: `((PARA (TEXT "Text") (SOFT) (TEXT "*abc")))`, encoderText: `Text *abc`, encoderZmk: useZmk, @@ -133,11 +123,10 @@ }, { descr: "A list after paragraph", zmk: "Text\n# abc", expect: expectMap{ - encoderZJSON: `[{"":"Para","i":[{"":"Text","s":"Text"}]},{"":"Ordered","c":[[{"":"Para","i":[{"":"Text","s":"abc"}]}]]}]`, encoderHTML: "Text
", encoderMD: "> ToBeOrNotToBe", encoderSexpr: `((QUOTATION ((TEXT "ToBeOrNotToBe"))))`, encoderText: "ToBeOrNotToBe", encoderZmk: useZmk, @@ -157,11 +145,10 @@ }, { descr: "Simple Quote Block", zmk: "<<<\nToBeOrNotToBe\n<<< Romeo", expect: expectMap{ - encoderZJSON: `[{"":"Excerpt","b":[{"":"Para","i":[{"":"Text","s":"ToBeOrNotToBe"}]}],"i":[{"":"Text","s":"Romeo"}]}]`, encoderHTML: "ToBeOrNotToBe
", encoderMD: "> ToBeOrNotToBe", encoderSexpr: `((REGION-QUOTE () ((PARA (TEXT "ToBeOrNotToBe"))) ((TEXT "Romeo"))))`, encoderText: "ToBeOrNotToBe\nRomeo", encoderZmk: useZmk, @@ -169,11 +156,10 @@ }, { descr: "Quote Block with multiple paragraphs", zmk: "<<<\nToBeOr\n\nNotToBe\n<<< Romeo", expect: expectMap{ - encoderZJSON: `[{"":"Excerpt","b":[{"":"Para","i":[{"":"Text","s":"ToBeOr"}]},{"":"Para","i":[{"":"Text","s":"NotToBe"}]}],"i":[{"":"Text","s":"Romeo"}]}]`, encoderHTML: "ToBeOrNotToBe
Romeo
", encoderMD: "> ToBeOr\n\n> NotToBe", encoderSexpr: `((REGION-QUOTE () ((PARA (TEXT "ToBeOr")) (PARA (TEXT "NotToBe"))) ((TEXT "Romeo"))))`, encoderText: "ToBeOr\nNotToBe\nRomeo", encoderZmk: useZmk, @@ -189,11 +175,10 @@ Paragraph Spacy Para """ Author`, expect: expectMap{ - encoderZJSON: "[{\"\":\"Poem\",\"b\":[{\"\":\"Para\",\"i\":[{\"\":\"Text\",\"s\":\"A\"},{\"\":\"Space\",\"s\":\"\u00a0\"},{\"\":\"Text\",\"s\":\"line\"},{\"\":\"Hard\"},{\"\":\"Space\",\"s\":\"\u00a0\u00a0\"},{\"\":\"Text\",\"s\":\"another\"},{\"\":\"Space\",\"s\":\"\u00a0\"},{\"\":\"Text\",\"s\":\"line\"},{\"\":\"Hard\"},{\"\":\"Text\",\"s\":\"Back\"}]},{\"\":\"Para\",\"i\":[{\"\":\"Text\",\"s\":\"Paragraph\"}]},{\"\":\"Para\",\"i\":[{\"\":\"Space\",\"s\":\"\u00a0\u00a0\u00a0\u00a0\"},{\"\":\"Text\",\"s\":\"Spacy\"},{\"\":\"Space\",\"s\":\"\u00a0\u00a0\"},{\"\":\"Text\",\"s\":\"Para\"}]}],\"i\":[{\"\":\"Text\",\"s\":\"Author\"}]}]", encoderHTML: "ToBeOr
NotToBe
Romeo
A\u00a0line
\u00a0\u00a0another\u00a0line
Back
Paragraph
\u00a0\u00a0\u00a0\u00a0Spacy\u00a0\u00a0Para
AuthorA simple span and much more
Hello\nWorld
",
encoderMD: " Hello\n World",
encoderSexpr: `((VERBATIM-CODE () "Hello\nWorld"))`,
encoderText: "Hello\nWorld",
encoderZmk: useZmk,
@@ -229,11 +212,10 @@
},
{
descr: "Simple Verbatim Code with visible spaces",
zmk: "```{-}\nHello World\n```",
expect: expectMap{
- encoderZJSON: `[{"":"CodeBlock","a":{"-":""},"s":"Hello World"}]`,
encoderHTML: "Hello\u2423World
",
encoderMD: " Hello World",
encoderSexpr: `((VERBATIM-CODE (("-" "")) "Hello World"))`,
encoderText: "Hello World",
encoderZmk: useZmk,
@@ -241,11 +223,10 @@
},
{
descr: "Simple Verbatim Eval",
zmk: "~~~\nHello\nWorld\n~~~",
expect: expectMap{
- encoderZJSON: `[{"":"EvalBlock","s":"Hello\nWorld"}]`,
encoderHTML: "Hello\nWorld
",
encoderMD: "",
encoderSexpr: `((VERBATIM-EVAL () "Hello\nWorld"))`,
encoderText: "Hello\nWorld",
encoderZmk: useZmk,
@@ -253,11 +234,10 @@
},
{
descr: "Simple Verbatim Math",
zmk: "$$$\nHello\n\\LaTeX\n$$$",
expect: expectMap{
- encoderZJSON: `[{"":"MathBlock","s":"Hello\n\\LaTeX"}]`,
encoderHTML: "Hello\n\\LaTeX
",
encoderMD: "",
encoderSexpr: `((VERBATIM-MATH () "Hello\n\\LaTeX"))`,
encoderText: "Hello\n\\LaTeX",
encoderZmk: useZmk,
@@ -265,11 +245,10 @@
},
{
descr: "Simple Description List",
zmk: "; Zettel\n: Paper\n: Note\n; Zettelkasten\n: Slip box",
expect: expectMap{
- encoderZJSON: `[{"":"Description","d":[{"i":[{"":"Text","s":"Zettel"}],"e":[[{"":"Para","i":[{"":"Text","s":"Paper"}]}],[{"":"Para","i":[{"":"Text","s":"Note"}]}]]},{"i":[{"":"Text","s":"Zettelkasten"}],"e":[[{"":"Para","i":[{"":"Text","s":"Slip"},{"":"Space"},{"":"Text","s":"box"}]}]]}]}]`,
encoderHTML: "c1 | c2 | c3 |
d1 | d3 |
h1 | h2 | h3 |
c1 | c2 | c3 |
f1 | f2 | =f3 |
Text1
quotes", encoderMD: "
quotes", encoderSexpr: `((FORMAT-QUOTE () (TEXT "quotes")))`, encoderText: `quotes`, encoderZmk: useZmk, @@ -133,11 +123,10 @@ }, { descr: "Quotes formatting (german)", zmk: `""quotes""{lang=de}`, expect: expectMap{ - encoderZJSON: `[{"":"Quote","a":{"lang":"de"},"i":[{"":"Text","s":"quotes"}]}]`, encoderHTML: `
quotes`, encoderMD: "
quotes", encoderSexpr: `((FORMAT-QUOTE (("lang" "de")) (TEXT "quotes")))`, encoderText: `quotes`, encoderZmk: `""quotes""{lang="de"}`, @@ -145,11 +134,10 @@ }, { descr: "Span formatting", zmk: `::span::`, expect: expectMap{ - encoderZJSON: `[{"":"Span","i":[{"":"Text","s":"span"}]}]`, encoderHTML: `span`, encoderMD: "span", encoderSexpr: `((FORMAT-SPAN () (TEXT "span")))`, encoderText: `span`, encoderZmk: useZmk, @@ -157,11 +145,10 @@ }, { descr: "Code formatting", zmk: "``code``", expect: expectMap{ - encoderZJSON: `[{"":"Code","s":"code"}]`, encoderHTML: `
code
`,
encoderMD: "`code`",
encoderSexpr: `((LITERAL-CODE () "code"))`,
encoderText: `code`,
encoderZmk: useZmk,
@@ -169,11 +156,10 @@
},
{
descr: "Code formatting with visible space",
zmk: "``x y``{-}",
expect: expectMap{
- encoderZJSON: `[{"":"Code","a":{"-":""},"s":"x y"}]`,
encoderHTML: "x\u2423y
",
encoderMD: "`x y`",
encoderSexpr: `((LITERAL-CODE (("-" "")) "x y"))`,
encoderText: `x y`,
encoderZmk: useZmk,
@@ -181,11 +167,10 @@
},
{
descr: "HTML in Code formatting",
zmk: "``