Clochur/example/manual.clc

216 lines
6.4 KiB
Text
Raw Normal View History

2021-06-19 17:33:24 +08:00
[def-syntax q [[_] [str "\""]]]
[script "packages/font-fallback"]
[script "packages/grid"]
2021-06-28 00:22:37 +08:00
[script "packages/image"]
2021-06-28 23:35:14 +08:00
[script "packages/url"]
2021-06-19 17:33:24 +08:00
2021-06-20 23:12:03 +08:00
[define section-var 1]
[define sub-section-var 1]
2021-06-28 23:35:14 +08:00
[define image-var 1]
2021-06-20 23:12:03 +08:00
[define section-title ""]
2021-06-28 23:35:14 +08:00
[define image-desc ""]
2021-06-20 23:12:03 +08:00
% custom macro
[def-syntax section
2021-06-28 00:22:37 +08:00
[[_ x][str-append-many
2021-06-20 23:12:03 +08:00
[set! section-title [str-append [str-append [str section-var] [str ". " ]] [str x]]]
[font [[size "20pt"][weight "800"]] section-title]
[set! section-var [+ section-var 1]]
[set! sub-section-var 1]
]]]
% custom macro
[def-syntax subsection
2021-06-28 00:22:37 +08:00
[[_ x][str-append-many
2021-06-20 23:12:03 +08:00
[set! section-title [str-append [str-append [str sub-section-var] [str ". " ]] [str x]]]
[font [[size "16pt"][weight "600"]] section-title]
[set! sub-section-var [+ sub-section-var 1]]
]]]
2021-06-19 17:33:24 +08:00
2021-06-28 23:35:14 +08:00
[def-syntax image-desc
[[_ x][str-append-many
[set! image-desc [str-append-many [str image-var] [str ". " ] [str x]]]
[call center [italic image-desc]]
[set! sub-section-var [+ sub-section-var 1]]
]]]
2021-06-19 17:33:24 +08:00
[docu-para [[class "book"][papersize "b5"]]]
[docu
[call grid [[spacing "15pt"]]]
[call font:add-fallback [[family "Noto Serif CJK TC"]]]
[font-size "30pt" "Huan-gîng 使用 Clochur!"]
[font-size "20pt" "Welcome to use"] [font [[family "sligeach_orig"][size "20pt"]] "Clóċur"][font-size "20pt" ", a toy editor, toy intepreter and a toy typesetting-engine frontend."]
2021-06-28 23:35:14 +08:00
Author: Yoxem Chen (aka Tan, Kian-ting) <[call href [[src "mailto:yoxem.tem98@nctu.edu.tw"]] "yoxem.tem98@nctu.edu.tw"]>
Website: [call href [[src "https://www.github.com/Yoxem/Clochur"]] "https://www.github.com/Yoxem/Clochur"]
2021-06-20 23:12:03 +08:00
[section "What is Clochur?"]
2021-06-19 17:33:24 +08:00
2021-06-20 23:12:03 +08:00
2021-06-28 23:35:14 +08:00
Clochur, or printed as "\""[font-family "sligeach_orig" "Clóċur"]"\"" in Irish language ([italic "\"CLOW-kur\""] Clóċur as Roman type, which means [q]typesetting[q]), is a toy-lisp typesetting language with a intepreter written in Python 3, and with a simple editor written in PyQt5 and QScintilla.
2021-06-19 17:33:24 +08:00
It generate a XML that is readable for SILE, which is a typesetting engine written in Lua,
and it generate PDF with SILE.
The functions that it has (although may be buggy or needed to be tested) is:
- Macro expansion.
- call SILE command.
- count basic arithmetic expression.
[str "- lambda function"], function definition.
2021-06-20 23:12:03 +08:00
2021-06-28 23:35:14 +08:00
[subsection "Why it's called Clochur?"]
The author has (unofficially) learned Irish language (for a while and uncontinuously), so use the name.
[subsection "How is the language? It seems that it uses brackets insteads of parathesis."]
The langauge is inspired by SILE and Scheme, even though it has some different characteristics. To make the code neat and consider that parathesis is used more often than bracket, so it's more suitable to use bracket for syntatical usage.
It's a toy language, so many of the function of Scheme, is not used here (for example call/cc), and there is no "\"let\"" to support local variables. However, you can call SILE function and using the packages of it with "\"call\"" and "\"script\"" respectively.
[subsection "Does it support Taiwanese (Hokkien)/Hakka/Mandarin/Japanese/Korean or any other language that I want?"]
2021-06-29 23:40:10 +08:00
SILE supports utf-8, and Clochur will generate a XML that is readable to SILE, as long as any language that SILE can support, Clochur will support. If you find any bug, please tell me.
2021-06-28 23:35:14 +08:00
2021-06-20 23:12:03 +08:00
[section "Simple manual"]
2021-06-28 00:22:37 +08:00
[subsection "Editor interface"]
[call img [[src "total-interface.png"] [height "200px"]]]
2021-06-28 23:35:14 +08:00
[image-desc "The interface of Clochur"]
Clochur is not a WYSIWYG editor, you have to type the lisp language by your self. Nevertheless, it's not a pure text-editor, it contains a PDF viewer powered by PDF.js, If you have edited you code, you can click the green right arrow botton on the first toolbar to convert it to XML file, then generate and show PDF file from it.
[call img [[src "toolbars.png"] [height "60pt"]]]
[image-desc "The toolbars of Clochur"]
The description of the botton of the 1st toolbar is shown below (from left to right):
- Create a file (create a new window)
- Open a file
- Save a file
- Save as...
- Convert to PDF
- Redo
- Undo
- Cut
- Copy
- Paste
The description of the botton of the 2nd toolbar is shown below (from left to right):
- apply "bold" macro to the selected text
- apply "italic" macro to the selected text
- apply "underline" macro to the selected text
- "font" list
- 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.\""
2021-06-28 00:22:37 +08:00
[subsection "Arimetic calculation and variable and function definition"]
[subsection "Font formatting"]
[subsection "Call SILE function and packages"]
2021-06-20 23:12:03 +08:00
[subsection "Macro"]
2021-06-28 00:22:37 +08:00
Using [font-family "Noto Sans Mono CJK TC" "def-syntax"], you can add your macro to sile. the example is a "custom-section" macro:
[call noindent][font-family "Noto Sans Mono CJK TC" "[def-syntax subsection"]
[call noindent][font-family "Noto Sans Mono CJK TC" "[[_ x][str-append"]
[call noindent][font-family "Noto Sans Mono CJK TC" "[set! section-title [str-append [str-append [str sub-section-var] [str \". \" ]] [str x]]]"]
2021-06-20 23:12:03 +08:00
2021-06-28 00:22:37 +08:00
[call noindent][font-family "Noto Sans Mono CJK TC" "[font [[size \"16pt\"][weight \"600\"]] section-title]"]
2021-06-20 23:24:44 +08:00
2021-06-28 00:22:37 +08:00
[call noindent][font-family "Noto Sans Mono CJK TC" "set! sub-section-var [+ sub-section-var 1]]]]]"]
2021-06-20 23:24:44 +08:00
2021-06-28 00:22:37 +08:00
[str "underline
2021-06-20 23:24:44 +08:00
bold
italic
font-size
font-family
font
begin
cons
car
cdr
ls-ref
ls
begin
script
docu-para
call
xml-to-string
2021-06-28 00:22:37 +08:00
2021-06-20 23:24:44 +08:00
SILE
print
set!
def-syntax
define function, closure, lambda
str
str-append
2021-06-28 00:22:37 +08:00
str-append-many" ]]