add manual and modify destring in Interpreter

This commit is contained in:
Tan, Kian-ting 2021-06-29 23:35:53 +08:00
parent f65fe6f870
commit f444be2ed8
4 changed files with 37 additions and 6 deletions

View file

@ -131,11 +131,40 @@ The description of the botton of the 2nd toolbar is shown below (from left to ri
- apply the "font" shown in the "font" list to the selected text
[subsection "Basic input, [docu], and special character"]
Basically, you can type the sentence that you want to type directly in sile. However, the document should be inside a macro call "\"docu\"". For example:
[call noindent][font-family "Noto Sans Mono CJK TC" [str "[docu Hello world!]"]]
It will show
Hello world!
However, if it's a macro name (eg. "docu, font, font-family, ..."), you have to put them between 2 quotation marks"\"". eg:
[call noindent][font-family "Noto Sans Mono CJK TC" "[docu \"docu\"]"]
It will show
"docu"
To type brackets \[ & \], you should type \\\[ & \\\] respectively; and to type blackslash \\, you should type \\\\. To type quotation mark \", you should type \\\". A word or a sentence between 2 quotation marks (\") will be shown without the quotation marks. eg: [font-family "Noto Sans Mono CJK TC" "\"It will be there.\""]
will be shown as:
"It will be there."
To make the quotation mark shown, you should enclose it between quotation mark \" and using \\\". [font-family "Noto Sans Mono CJK TC" "\"\\\"It will be there.\\\"\""] will be shown as:
"\"It will be there.\""
[subsection "Arimetic calculation and variable and function definition"]
[subsection "Special character"]
[subsection "Font formatting"]

BIN
example/toolbars.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -116,11 +116,12 @@ class Interpreter:
string = str(string)
if re.match(string_pattern, string):
# reverse the escape characters
while True:
string_before = string
string = re.sub(r'\\"(.+)',r'"\1',string)
if string_before == string:
break
#while True:
# string_before = string
# string = string.replace('\\"','"')
#if string_before == string:
# break
#string = string.replace('\\"','"')
return string[1:-1]
else:
return string
@ -133,6 +134,7 @@ class Interpreter:
sexp_word = sexp["token"]
sexp_word = sexp_word.replace("\\[", "[")
sexp_word = sexp_word.replace("\\]", "]")
sexp_word = sexp_word.replace("\\\"", "\"")
sexp_word = sexp_word.replace("\\\\", "\\")
sexp_word = sexp_word.replace("&", "&")
sexp_word = sexp_word.replace("<", "&lt;")

Binary file not shown.