all repos — min @ 0806ef74d5dfbb5368c3830daf78ee09bf43a585

A small but practical concatenative programming language.

Implemented xescape symbol.
h3rald h3rald@h3rald.com
Sun, 05 May 2024 10:57:07 +0200
commit

0806ef74d5dfbb5368c3830daf78ee09bf43a585

parent

1f3459e6ae4404c214f95697b178c0900d264e6c

4 files changed, 12 insertions(+), 0 deletions(-)

jump to
M minpkg/lib/min_xml.nimminpkg/lib/min_xml.nim

@@ -126,6 +126,10 @@ # Strip & and ;

entity = entity[1..entity.len-2] i.push entity.entityToUtf8.newVal + def.symbol("xescape") do (i: In): + let vals = i.expect("'sym") + i.push vals[0].getString.escape.newVal + def.symbol("xelement") do (i: In): let vals = i.expect("'sym") i.push i.newXDict(newElement(vals[0].getString))
M next-release.mdnext-release.md

@@ -3,4 +3,5 @@

- Added a new `color` symbol to the `io` module to enable/disable terminal color output. - Added a new `from-html` symbol to the `xml` module to parse HTML documents and fragments. - Added a new `xentity2utf8` symbol to the `xml` module to convert an XML entity to its corresponding UTF-8 string. +- Added a new `xescape` symbol to the `xml` module to convert special XML characters into the corresponding XML entities.
M site/contents/reference-xml.mdsite/contents/reference-xml.md

@@ -41,6 +41,9 @@

{#op||xentity||{{sl}}||{{xentity}}|| Returns a {{xentity}} representing an XML entity. #} +{#op||xescape||{{sl}}||{{s}}|| +Converts any `<`, `>`, `&`, `'`, and `"` present in {{sl}} into the corresponding XML entities. #} + {#op||xentity2utf8||{{dict:xentity}}||{{s}}|| > Returns the UTF-8 symbol corresponding to the specified XML entity. >
M tests/xml.mintests/xml.min

@@ -44,5 +44,9 @@ (

"&gt;" xentity xentity2utf8 ">" == ) *test/assert + ( + "This is a <i>test</i>" xescape "This is a &lt;i&gt;test&lt;/i&gt;" == + ) *test/assert + *test/report clear-stack