Scripta.API provides the functions you will need for an application that compiles source text in L0, microLaTeX, or XMarkdown to HTML.
windowWidth: set this to agree with the width of the window in pixels in which the rendered text is displayed.
counter: This is updated on each edit. For technical reasons (virtual Dom) this is needed for the text to display properly.
selectedId and selectedSlug: useful for interactive editing.
scale: a fudge factor
compile (displaySettings 0) "Pythagorean formula: $a^2 + b^2 = c^2$" where
we define
displaySettings : Int -> Scripta.API.DisplaySettings
displaySettings counter =
{ windowWidth = 500
, counter = counter
, selectedId = "--"
, selectedSlug = Nothing
, scale = 0.8
}The counter field must be updated on each edit.
This is needed for the rendered text to be
properly updated. See the demo app in
folder Example1.
Compilation can be sped up by keeping track of which blocks
of source text have changed and ony reparsing those blocks.
An EditRecord is used to keep track of what has changed
and what has not. In this setup, the EditRecord is
initialized with the source text using the init function.
On each document change it brought up to date by the
update function. The render function transforms
the current EditRecord into HTML.
The export and fileNameForExport are functions used to transform source
text in a given markup language to standard LaTeX. The transformed text
can be used to produce a PDF file or a tar files that contains both the
standare LaTeX source and a folder of images used in the documents.
See the code in modules PDF and Main of Example2 for more details.
The Elm app sends data to https://pdfServ.app, a small server
(165 lines of Haskell code) where it is turned into a PDF file or
tar archive where it is then accessible by a GET request.
See pdfServer2@Github.
Settings used by render
The PDF module in Example2 requires these.
Compile source text in the given language using the given display settings.