-
Notifications
You must be signed in to change notification settings - Fork 7
Typing
Quarkdown is dynamically typed: every value that may be passed to a function argument is wrapped in a DynamicValue
object.
The dynamic value is then adapted or converted to the type expected by the signature of the native function (written in Kotlin, strongly typed) at invocation time.
If a conversion cannot be made, an error occurs.
This invoke-time adaptation reduces constraints, allowing the same value to be handled differently depending on its context.
.var {myvar} {true} .if {.myvar} My value is .uppercase {.myvar}
Output:
My value is TRUE
In this example:
-
.var
's second parameter accepts aDynamicValue
since its value can still be used as any type, thus its value is kept dynamic; -
.if
takes aBoolean
, so the dynamictrue
value kept in themyvar
variable is converted to boolean; -
.uppercase
takes aString
, so the thetrue
value is used as a string.
See the Value types section of this wiki to see all the supported types.
The following example is a simplified version of a function defined in the demo presentation, which shows a Quarkdown code snippet and its visual result right below it:
.function {sourceresult}
source:
.code {markdown}
.source
.source
Invoking:
.sourceresult ## Quarkdown Quarkdown was born in **.sum {2000} {24}**!
Output:
## Quarkdown Quarkdown was born in **.sum {2000} {24}**!Quarkdown was born in 2024!
What this example shows is how versatile Quarkdown values are. In the function declaration, the .source
argument is retrieved twice:
- In
.code
, which expects a string, so the source is read as-is and inserted in a code block; - At the top level: the Quarkdown source is automatically adapted to the context, so it's parsed as rich Markdown content.
- Syntax of a function call
- Declaring functions
- Dynamic typing
- Localization
- Including other Quarkdown files
- Importing external libraries
- Document metadata
- Theme
- Page format
- Page margin content
- Page counter
- Automatic page break
- Numbering
- Table of contents
- Stacks (row, column, grid)
- Align
- Container
- Box
- Collapsible
- Whitespace
- String
- Number
- Markdown content
- Boolean
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic