Clochur/example/manual.clc
2021-06-20 23:24:44 +08:00

104 lines
No EOL
2.3 KiB
Text

[def-syntax q [[_] [str "\""]]]
[script "packages/font-fallback"]
[script "packages/grid"]
[define section-var 1]
[define sub-section-var 1]
[define section-title ""]
% custom macro
[def-syntax section
[[_ x][begin
[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
[[_ x][begin
[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]]
]]]
[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."]
[section "What is Clochur?"]
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.
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.
[section "Simple manual"]
[subsection "Macro"]
Using 'def-syntax', you can add your macro to sile. the example is a "custom-section" macro:
[font-family "Noto Sans Mono CJK TC" "123
124"]
underline
bold
italic
font-size
font-family
font
begin
cons
car
cdr
ls-ref
ls
begin
script
docu-para
call
xml-to-string
SILE-STRING-ADD!
SILE
print
set!
def-syntax
define function, closure, lambda
str
str-append
]
% custom macro
%[set! section-title [str-append [str-append [str [str \"section-var\"]] [str \". \" ]] [str x]]]
%[font [[size \"20pt\"][weight \"800\"]] [str \"section-title\"]]
%[set! [str \"section-var\"] [+ [str \"section-var\"] 1]]