doc/syntax: add more about multiline strings
@@ -93,6 +93,23 @@ Yes it is, indeed it is"#m
"Well, if this isn't a string?
Yes it is, indeed it is"
+> "Hello" ++ "World"
+"HelloWorld"
+
+> let h = "Hello" in "#{h} World"
+"Hello World"
+
+> let n = 5 in "The number #{n}."
+error: Type error
+
+> let n = 5 in "The number #{strings.from_num n}."
+"The number 5."
+```
+
+Multiline strings are useful to write indented lines. The indentation is stripped from the beginning of the first line, and first and last lines are ignored if they are empty.
+
+Example:
+```
> m#"
This line has no identation.
This line is indented.
@@ -103,18 +120,57 @@ This line has no more identation.
This line is indented.
This line is even more indented.
This line has no more indentation."
+```
-> "Hello" ++ "World"
+The only special sequence in a multiline string is the string interpolation.
+
+Examples:
+```
+> m#"Multiline\nString?"#m
+"Multiline\nString?"
+
+> m#"Multiline#{"\n"}String"#m
+"Multiline
+String"
+```
+
+A multiline string can be introduced and closed by multiple `#` signs, as long as this amount is equal. If one wants to use string interpolation, it must uses the same amount of `#`.
+
+Examples:
+```
+> m##"Hello World"##m
"Hello World"
-> let h = "Hello" in "#{h} World"
+> m#####"Hello World"#####m
"Hello World"
-> let n = 5 in "The number #{n}."
-error: Type error
+> let w = "World" in m##"Hello #{w}"##m
+"Hello #{"World"}"
-> let n = 5 in "The number #{strings.from_num n}."
-"The number 5."
+> let w = "World" in m##"Hello ##{w}"##m
+"Hello World"
+```
+
+Multiline strings are "indentation-aware". This means that one could use an indented string interpolation and the indentation would behave as expected:
+```
+> let log = m#"
+if log:
+ print("log:", s)
+"#m in m#"
+def concat(str_list, log=false):
+ res = []
+ for s in str_list:
+ #{log}
+ res.append(s)
+ return res
+"#m
+"def concat(str_list, log=false):
+ res = []
+ for s in str_list:
+ if log:
+ print("log:", s)
+ res.append(s)
+ return res"
```
## Equality Operators
