-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathjax.sc
executable file
·39 lines (36 loc) · 2.04 KB
/
mathjax.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env -S scala-cli project.scala
// ------------------------------------------------------------------------------
// Render some maths on screen for demo purposes.
// Run with ./mathjax.sc
// ------------------------------------------------------------------------------
import org.terminal21.client.*
import org.terminal21.client.components.*
import org.terminal21.client.components.mathjax.*
Sessions
.withNewSession("mathjax", "MathJax Example")
.andLibraries(MathJaxLib /* note we need to register the MathJaxLib in order to use it */ )
.connect: session =>
given ConnectedSession = session
Controller
.noModel(
Seq(
MathJax(
expression = """When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$"""
),
MathJax(
expression = """
|when \(a \ne 0\), there are two solutions to \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\)
|Aenean vel velit a lacus lacinia pulvinar. Morbi eget ex et tellus aliquam molestie sit amet eu diam.
|Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tellus enim, tempor non efficitur et, rutrum efficitur metus.
|Nulla scelerisque, mauris sit amet accumsan iaculis, elit ipsum suscipit lorem, sed fermentum nunc purus non tellus.
|Aenean congue accumsan tempor. \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\) maecenas vitae commodo tortor. Aliquam erat volutpat. Etiam laoreet malesuada elit sed vestibulum.
|Etiam consequat congue fermentum. Vivamus dapibus scelerisque ipsum eu tempus. Integer non pulvinar nisi.
|Morbi ultrices sem quis nisl convallis, ac cursus nunc condimentum. Orci varius natoque penatibus et magnis dis parturient montes,
|nascetur ridiculus mus.
|""".stripMargin
)
)
)
.render()
// since this is a read-only UI, we can exit the app but leave the session open on the UI for the user to examine the data.
session.leaveSessionOpenAfterExiting()