Updated docs.
h3rald h3rald@h3rald.com
Mon, 31 Jul 2023 07:33:58 +0200
5 files changed,
126 insertions(+),
43 deletions(-)
M
next-release.md
→
next-release.md
@@ -1,7 +1,7 @@
### New Features -* Implemented new `xml` module to work with XML content. -* Fixed month index in `timeinfo` and `to-timestamp` symbols (each month number was increased by 1). Fixes #186. +* Implemented new `xml` module to work with XML content (addresses #21). +* Fixed month index in `timeinfo` and `to-timestamp` symbols (each month number was increased by 1); addresses #186. * `--dev` is not automatically set when running min interactively. ### Fixes and Improvements
M
site/contents/_defs_.md
→
site/contents/_defs_.md
@@ -62,7 +62,8 @@ {{m => _min_}}
{{xelement => [dict:xml-element](class:kwd)}} {{xcomment => [dict:xml-comment](class:kwd)}} {{xentity => [dict:xml-entity](class:kwd)}} -{{xtext => [dict:xml-cdata](class:kwd)}} +{{xcdata => [dict:xml-cdata](class:kwd)}} +{{xtext => [dict:xml-text](class:kwd)}} {{xentity => [dict:xml-entity](class:kwd)}} {{xnode => [xml-node](class:kwd)}}
M
site/contents/reference-xml.md
→
site/contents/reference-xml.md
@@ -1,61 +1,96 @@
----- content-type: "page" -title: "dict Module" +title: "xml Module" ----- {@ _defs_.md || 0 @} -{#sig||/||dget#} +{#op||from-xml||{{sl}}||{{xnode}}|| +> Returns an {{xnode}} representing an XML string representing an element or fragment. +> +> > %sidebar% +> > Example +> > +> > The following program: +> > +> > "<a href='https://min-lang.org'>min web site</a>" from-xml +> > returns the following: +> > +> > { +> > {"https://min-lang.org" :href} :attributes +> > ({"min web site" :text ;xml-text}) :children +> > "a" :tag +> > ;xml-element +> > } + #} -{#sig||%||dset#} +{#op||to-xml||{{xnode}}||{{s}}|| +Returns a {{s}} representing an XML node. #} -{#op||ddup||{{d1}}||{{d2}}|| -Returns a copy of {{d1}}. #} +{#op||xcdata||{{sl}}||{{xcdata}}|| +Returns a {{xcdata}} representing an XML CDATA section. #} -{#op||ddel||{{d}} {{sl}}||{{d}}|| -Removes {{sl}} from {{d1}} and returns {{d1}}. #} +{#op||xcomment||{{sl}}||{{xcomment}}|| +Returns a {{xcomment}} representing an XML comment. #} -{#op||dget||{{d}} {{sl}}||{{any}}|| -Returns the value of key {{sl}} from dictionary {{d}}. #} +{#op||xelement||{{sl}}||{{xelement}}|| +Returns a {{xelement}} representing an XML element (it will be an empty element with no attributes or children). #} -{#op||dget-raw||{{d}} {{sl}}||{{rawval}}|| -Returns the value of key {{sl}} from dictionary {{d}}, wrapped in a {{rawval}}. #} +{#op||xentity||{{sl}}||{{xentity}}|| +Returns a {{xentity}} representing an XML entity. #} -{#op||dhas?||{{d}} {{sl}}||{{b}}|| -> Returns {{t}} if dictionary {{d}} contains the key {{sl}}, {{f}} otherwise. +{#op||xquery||{{xelement}} {{sl}}||{{xelement}}|| +> Returns an {{xelement}} representing the first element matching CSS the selector {{sl}}. > > > %sidebar% > > Example > > -> > The following program returns {{t}}: -> > -> > {true :a1 "aaa" :a2 false :a3} 'a2 dhas? +> > The following program: +> > +> > "<ul> +> > <li class='test'>first</li> +> > <li class='other'>second</li> +> > <li class='test'>third</li> +> > </ul>" +> > from-xml ".test" xquery +> > Returns the following: +> > +> > { +> > {"test" :class} :attributes +> > ({"first" :text ;xml-text}) :children +> > "li" :tag +> > ;xml-element +> > } #} -{#op||dkeys||{{d}}||({{s}}{{0p}})|| -Returns a quotation containing all the keys of dictionary {{d}}. #} - -{#op||dpick||{{d1}} {{q}}||{{d2}}|| -> Returns a new dictionary {{d2}} containing the elements of {{d1}} whose keys are included in {{q}}. +{#op||xqueryall||{{xelement}} {{sl}}||{{xelement}}|| +> Returns a list of {{xelement}} dictionaries representing all the elements matching CSS the selector {{sl}}. > > > %sidebar% > > Example > > -> > The following program returns `{4 :a 7 :d}`: -> > -> > {5 :q 4 :a 6 :c 7 :d "d" :a} ("a" "d") dpick +> > The following program: +> > +> > "<ul> +> > <li class='test'>first</li> +> > <li class='other'>second</li> +> > <li class='test'>third</li> +> > </ul>" +> > from-xml ".test" xqueryall +> > Returns the following: +> > +> > ({ +> > {"test" :class} :attributes +> > ({"first" :text ;xml-text}) :children +> > "li" :tag +> > ;xml-element +> > } +> > { +> > {"test" :class} :attributes +> > ({"third" :text ;xml-text}) :children +> > "li" :tag +> > ;xml-element +> > }) #} -{#op||dpairs||{{d}}||({{a0p}})|| -Returns a quotation containing all the keys (odd items) and values (even items) of dictionary {{d}}. #} - -{#op||dset||{{d}} {{any}} {{sl}}||{{d}}|| -Sets the value of the {{sl}} of {{d1}} to {{any}}, and returns the modified dictionary {{d}}. #} - -{#op||dset-sym||{{d}} {{sl}} {{sl}}||{{d}}|| -Sets the value of the {{sl}} of {{d1}} to {{sl}} (treating it as a symbol), and returns the modified dictionary {{d}}. #} - -{#op||dtype||{{d}}||{{s}}|| -Returns a string set to the type of {{d}} (empty if the dictionary has no type). #} - -{#op||dvalues||{{d}}||({{a0p}})|| -Returns a quotation containing all the values of dictionary {{d}}. #} +{#op||xtext||{{sl}}||{{xtext}}|| +Returns a {{xtext}} representing an XML text node. #}
M
site/contents/reference.md
→
site/contents/reference.md
@@ -38,7 +38,8 @@ {#link-module||net#}
: Provides basic supports for sockets (some features are not supported on Windows systems). {#link-module||http#} : Provides operators to perform HTTP requests, download files and create basic HTTP servers. - +{#link-module||xml#} +: Provides operators for parsing, creating and querying XML/HTML code using CSS selectors. ## Notation@@ -159,6 +160,7 @@ "it-id" :Accept-Language
"httpbin.org" :Host } :headers ;optional "test body" :body ;optional + ;{{req}} } {{res}} : A response dictionary, representing an HTTP response returned by some of the operators exposed by the {#link-module||http#}:@@ -170,7 +172,49 @@ {
"application/json" :Content-Type } :headers ;optional "{\"test\": \"This is a test\"}" :body + ;{{res}} + } +{{xelement}} +: A dictionary representing an XML or HTML element, exposed by the {#link-module||xml#} + + { + {"https://min-lang.org" :href} :attributes + ({"min web site" :text ;xml-text}) :children + "a" :tag + ;xml-element } +{{xcomment}} +: A dictionary representing an XML comment. + + { + "This is a comment" :text + ;{{xcomment}} + } +{{xcdata}} +: A dictionary representing XML CDATA text. + + { + "This is some text" :text + ;{{xcdata}} + } +{{xentity}} +: A dictionary representing an XML entity. + + { + "amp" :text + ;{{xentity}} + } +{{xtext}} +: A dictionary representing XML text. + + { + "This is some text" :text + ;{{xtext}} + } +{{xnode}} +: A typealias to identify all XML dictionary types. + + "{{xelement}}|{{xtext}}|{{xcomment}}|{{xentity}}|{{xcdata}}" ### Suffixes
M
site/rules.min
→
site/rules.min
@@ -83,7 +83,10 @@ ) ^download-latest-min-exes
;Main -download-latest-min-exes +((('wget "" !=) ('zip which "" !=)) &&) + (download-latest-min-exes) +when + "Processing contents..." notice! contents (