yotamDvir / elm-katex / Katex

You should use this module if this is your first time using this package, or if you don't need special configurations.

Types


type alias Latex =
Configs.Latex String String

A LaTeX instance.

Create LaTeX instance

human : String -> Latex

Use human when writing regular text.

inline : String -> Latex

Use inline when writing LaTeX code for inline math environment.

display : String -> Latex

Use display when writing LaTeX code for display math environment.

Process LaTeX instances

print : Latex -> String

Turn a LaTeX instance into a string that the KaTeX library recognizes.

generate : (Maybe Basics.Bool -> String -> a) -> Latex -> a

Generate a function over LaTeX values. The boolean value represents whether the math is in display mode, i.e.

For example, let's say you want an Html a emitting function which puts display math in a div, but inline math and human text in a span.

view : Latex -> Html a
view =
    let
        htmlGenerator isDisplayMode stringLatex =
            case isDisplayMode of
                Just True ->
                    H.div [] [ H.text stringLatex ]

                _ ->
                    H.span [] [ H.text stringLatex ]
    in
    generate htmlGenerator

Another example is the built-in print function.

print : Latex -> String
print =
    generate (\_ stringLatex -> stringLatex)