aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-16 16:18:01 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-16 16:18:01 -0400
commit171595fad190608322c57fd418add6698ea5e791 (patch)
tree9bbaecd291a4668fc7bc070b9836f14f1a7a6f25
parente5f432d4c913b31922da5b2855237d37ceef0432 (diff)
Update docs
-rw-r--r--docs/langs.md16
1 files changed, 9 insertions, 7 deletions
diff --git a/docs/langs.md b/docs/langs.md
index b9f98789..7e1bd7ef 100644
--- a/docs/langs.md
+++ b/docs/langs.md
@@ -11,11 +11,13 @@ where a different type of string is needed.
```tomo
lang HTML:
func escape(t:Text)->HTML:
- t = t:replace("&", "&amp;")
- t = t:replace("<", "&lt;")
- t = t:replace(">", "&gt;")
- t = t:replace('"', "&quot;")
- t = t:replace("'", "&#39;")
+ t = t:replace_all({
+ $/&/: "&amp;",
+ $/</: "&lt;",
+ $/>/: "&gt;",
+ $/"/: "&quot",
+ $/'/: "&#39;",
+ })
return HTML.from_unsafe_text(t)
func paragraph(content:HTML)->HTML:
@@ -73,12 +75,12 @@ instead of building a global function called `execute()` that takes a
```tomo
lang Sh:
func escape(text:Text)->Sh:
- return Sh.from_unsafe_text("'$(text:replace("'", "''"))'")
+ return Sh.from_unsafe_text("'" ++ text:replace($/'/, "''") ++ "'")
func execute(sh:Sh)->Text:
...
-dir := Text.read_line("List which dir? ")
+dir := ask("List which dir? ")
cmd := $Sh@(ls -l @dir)
result := cmd:execute()
```