diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-16 16:18:01 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-16 16:18:01 -0400 |
| commit | 171595fad190608322c57fd418add6698ea5e791 (patch) | |
| tree | 9bbaecd291a4668fc7bc070b9836f14f1a7a6f25 | |
| parent | e5f432d4c913b31922da5b2855237d37ceef0432 (diff) | |
Update docs
| -rw-r--r-- | docs/langs.md | 16 |
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("&", "&") - t = t:replace("<", "<") - t = t:replace(">", ">") - t = t:replace('"', """) - t = t:replace("'", "'") + t = t:replace_all({ + $/&/: "&", + $/</: "<", + $/>/: ">", + $/"/: """, + $/'/: "'", + }) 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() ``` |
