src/wasm_minimal_protocol/export_typst

Source   Edit  

proc (a1, a2, ..., an) -> if failed (int32)

Types

NameConvention = enum
  ncAsIs,                   ## export with the same name as Nim proc
  ncKebab                    ## export with kebab-case name
Source   Edit  

Consts

exportNimDocToTypst {.booldefine.} = true
Source   Edit  
ncTypst = ncKebab
Source   Edit  

Macros

macro export_typst_bytes(def: typed)
Source   Edit  
macro export_typst_bytes(name: static[string]; def: typed)
Source   Edit  
macro export_typst_conv(name: static[NameConvention]; def: typed)
Source   Edit  
macro export_typst_from(def: proc; export_name: static[NameConvention])
Source   Edit  
macro export_typst_from(def: proc; export_name: static[string] = ExportNameAsIs)

Example:

import std/editdistance as libed
export_typst_from editDistance, "nim-edit-distance"
export_typst_from editDistance, ncTypst  # export as `edit-distance`
import std/unidecode
export_typst_from unidecode.unidecode
# unidecode("εŒ—δΊ¬") == "Bei Jing "
Source   Edit  
macro export_typst_from(def; export_name: static[NameConvention]; typ: typedesc)
Source   Edit  
macro export_typst_from(def; export_name: static[string]; typ: typedesc)
Source   Edit  
macro export_typst_from(def; typ: typedesc)
Source   Edit  
macro export_typst_from_func(def: proc; export_name: static[NameConvention])
Source   Edit  
macro export_typst_from_func(def: proc;
                             export_name: static[string] = ExportNameAsIs)

Example:

import std/editdistance as libed
export_typst_from editDistance, "nim-edit-distance"
export_typst_from editDistance, ncTypst  # export as `edit-distance`
import std/unidecode
export_typst_from unidecode.unidecode
# unidecode("εŒ—δΊ¬") == "Bei Jing "
Source   Edit  
macro export_typst_from_func(def; export_name: static[NameConvention];
                             typ: typedesc)
Source   Edit  
macro export_typst_from_func(def; export_name: static[string]; typ: typedesc)
Source   Edit  
macro export_typst_from_func(def; typ: typedesc)
Source   Edit  

Templates

template dispatchTypst(typstCallback: string) {.pragma.}
typstCallback is a typst function name Source   Edit  
template export_typst(def)

Example:

func hello: string{.export_typst.} = "hello"
Source   Edit  
template export_typst(name; def)

Example:

func hello: string{.export_typst: "hello-from-nim".} = "hello"
Source   Edit  
template export_typst_as(name: static[string]; def: typed)
Source   Edit  
template export_typst_bytes_as(name: static[string]; def: typed)
Source   Edit  
template formatTypstResult(f: string) {.pragma.}
f shall contains $1 to reference the original return value Source   Edit