wxMaxima
Loading...
Searching...
No Matches
Functions
TypstMarkup.h File Reference

The building blocks of the Typst export (GH #2687). More...

#include <wx/string.h>
Include dependency graph for TypstMarkup.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

wxString wxm::typst::String (const wxString &text)
 A Typst string literal: "text", with backslashes, quotes and newlines escaped.
 
wxString wxm::typst::MathText (const wxString &text)
 A piece of text in maths: bare if Typst reads it as what it shows, else a string.
 
bool wxm::typst::IsAtom (const wxString &math)
 True if Typst reads this piece of maths as one unit.
 
bool wxm::typst::IsParenGroup (const wxString &math)
 True if math is one group in round parentheses from start to end.
 
wxString wxm::typst::Script (const wxString &math)
 Makes a piece of maths usable as a script: x^Script(...)
 
wxString wxm::typst::Arg (const wxString &math)
 Makes a piece of maths usable as an argument of a function like sqrt()
 
wxString wxm::typst::Attach (const wxString &base, const wxString &sup, const wxString &sub={}, const wxString &preSup={}, const wxString &preSub={})
 A base with scripts attached.
 
wxString wxm::typst::Join (const wxString &a, const wxString &b)
 Two pieces of maths, separated by a space if both are there.
 
wxString wxm::typst::Markup (const wxString &text, bool keepBullets=false)
 Escapes text for Typst markup (prose, not maths)
 
wxString wxm::typst::RawBlock (const wxString &code, const wxString &lang={})
 A raw (verbatim) block, fenced with more backticks than the code contains.
 

Detailed Description

The building blocks of the Typst export (GH #2687).

Typst's maths syntax looks like LaTeX's with the backslashes taken out, but it reads differently in a few places that an exporter has to get right, and that each cell's ToTypst() would otherwise have to get right on its own:

GUI-free, so test_TypstMarkup can pin it directly.

Function Documentation

◆ Arg()

wxString wxm::typst::Arg ( const wxString &  math)

Makes a piece of maths usable as an argument of a function like sqrt()

Escapes the commas and semicolons that are not inside a bracket, a string or a function call of their own, as those would separate arguments.

◆ Attach()

wxString wxm::typst::Attach ( const wxString &  base,
const wxString &  sup,
const wxString &  sub = {},
const wxString &  preSup = {},
const wxString &  preSub = {} 
)

A base with scripts attached.

Parameters
baseThe base
supThe superscript, or empty
subThe subscript, or empty
preSupA superscript in front of the base, or empty
preSubA subscript in front of the base, or empty

Written as base_sub^sup where that is enough, as attach() where the base is more than one unit or there are scripts in front.

◆ IsAtom()

bool wxm::typst::IsAtom ( const wxString &  math)

True if Typst reads this piece of maths as one unit.

A single character (or escaped character), a number, a name like pi or dots.h, a string, or a group in matching delimiters from start to end.

◆ Markup()

wxString wxm::typst::Markup ( const wxString &  text,
bool  keepBullets = false 
)

Escapes text for Typst markup (prose, not maths)

Parameters
textThe text
keepBulletsLeave a line's leading "* " alone, so the markdown pass that follows can still see the bullet.

◆ MathText()

wxString wxm::typst::MathText ( const wxString &  text)

A piece of text in maths: bare if Typst reads it as what it shows, else a string.

Text containing a word of two or more letters becomes a String() (Typst would read the word as a variable name). Otherwise every character Typst maths treats specially is escaped with a backslash.

◆ RawBlock()

wxString wxm::typst::RawBlock ( const wxString &  code,
const wxString &  lang = {} 
)

A raw (verbatim) block, fenced with more backticks than the code contains.

Parameters
codeThe text
langThe language tag, or empty

◆ Script()

wxString wxm::typst::Script ( const wxString &  math)

Makes a piece of maths usable as a script: x^Script(...)

Atoms stay as they are, anything else is put in parentheses – which Typst then removes again, so a parenthesized group gets a second pair.