Skip to content

Commit

Permalink
add manual and modify destring in Interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoxem committed Jun 29, 2021
1 parent f65fe6f commit f444be2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
31 changes: 30 additions & 1 deletion example/manual.clc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Binary file added example/toolbars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions src/Clochur/Interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ def destring(self, string):
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
Expand All @@ -133,6 +134,7 @@ def remove_and_change_escaping_chars(self, sexp):
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;")
Expand Down
Binary file modified src/example.pdf
Binary file not shown.

0 comments on commit f444be2

Please sign in to comment.