From 171595fad190608322c57fd418add6698ea5e791 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 16 Sep 2024 16:18:01 -0400 Subject: [PATCH] Update docs --- docs/langs.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/langs.md b/docs/langs.md index b9f9878..7e1bd7e 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() ```