Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:
- name: Install dependencies
run: |
cabal v2-update
cabal freeze --dependencies-only --enable-tests --disable-optimization -fexecutable
cat cabal.project.freeze
cabal v2-build --dependencies-only --enable-tests --disable-optimization -fexecutable all
- name: Build and test
run: |
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ tests](https://github.com/jgm/texmath/workflows/CI%20tests/badge.svg)](https://g
texmath is a Haskell library for converting between formats used to
represent mathematics. Currently it provides functions to read and
write TeX math, presentation MathML, and OMML (Office Math Markup
Language, used in Microsoft Office), and to write Gnu eqn, typst, and
[pandoc]'s native format (allowing conversion, using pandoc, to
a variety of different markup formats). The TeX reader and
writer supports basic LaTeX and AMS extensions, and it can parse
and apply LaTeX macros. The package also includes several
utility modules which may be useful for anyone looking to
manipulate either TeX math or MathML. For example, a copy of
the MathML operator dictionary is included.
Language, used in Microsoft Office), and to write Gnu eqn, typst,
StarMath (used by LibreOffice), and [pandoc]'s native format
(allowing conversion, using pandoc, to a variety of different
markup formats). The TeX reader and writer supports basic LaTeX
and AMS extensions, and it can parse and apply LaTeX macros. The
package also includes several utility modules which may be useful
for anyone looking to manipulate either TeX math or MathML. For
example, a copy of the MathML operator dictionary is included.

[pandoc]: http://github.com/jgm/pandoc

Expand Down
1 change: 1 addition & 0 deletions extra/texmath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ writers = [
, ("omml", XMLWriter writeOMML)
, ("xhtml", XMLWriter (\dt e -> inHtml (writeMathML dt e)))
, ("mathml", XMLWriter writeMathML)
, ("starmath", StringWriter writeStarMath)
, ("pandoc", PandocWriter writePandoc)]

data Options = Options {
Expand Down
4 changes: 2 additions & 2 deletions man/texmath.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ expect query parameters for `from`, `to`, `input`, and optionally
Defaults to `tex`.

`-t` *FORMAT*
: Specify output ("to") format: `tex`, `omml`,
`xhtml`, `mathml`, `pandoc`, `native`. Defaults to `mathml`.
: Specify output ("to") format: `tex`, `omml`, `xhtml`, `mathml`,
`typst`, `eqn`, `starmath`, `pandoc`, `native`. Defaults to `mathml`.

`--inline`
: Use the inline display style.
Expand Down
6 changes: 5 additions & 1 deletion server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data Params = Params
} deriving (Show)

data Format =
TeX | MathML | Eqn | OMML | Typst
TeX | MathML | Eqn | OMML | Typst | StarMath
deriving (Show, Ord, Eq)

instance FromJSON Format where
Expand All @@ -46,6 +46,7 @@ instance FromJSON Format where
"eqn" -> pure Eqn
"typst" -> pure Typst
"omml" -> pure OMML
"starmath" -> pure StarMath
_ -> fail $ "Unknown format " <> T.unpack s
parseJSON _ = fail "Expecting string format"

Expand All @@ -60,6 +61,7 @@ instance FromHttpApiData Format where
"eqn" -> pure Eqn
"typst" -> pure Typst
"omml" -> pure OMML
"starmath" -> pure StarMath
_ -> Left $ "Unknown format " <> t

-- Automatically derive code to convert to/from JSON.
Expand Down Expand Up @@ -132,12 +134,14 @@ server = convert
MathML -> readMathML
Eqn -> \_ -> Left "eqn reader not implemented"
Typst -> \_ -> Left "typst reader not implemented"
StarMath -> \_ -> Left "StarMath reader not implemented"
writer = case to params of
Eqn -> writeEqn dt
Typst -> writeTypst dt
OMML -> T.pack . ppElement . writeOMML dt
TeX -> writeTeX
MathML -> T.pack . ppElement . writeMathML dt
StarMath -> writeStarMath dt
in handleErr $ writer <$> reader txt

handleErr (Right t) = return t
Expand Down
2 changes: 2 additions & 0 deletions src/Text/TeXMath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module Text.TeXMath ( readMathML,
writeTeXWith,
addLaTeXEnvironment,
writeEqn,
writeStarMath,
writeTypst,
writeOMML,
writeMathML,
Expand All @@ -78,5 +79,6 @@ import Text.TeXMath.Writers.OMML
import Text.TeXMath.Writers.Pandoc
import Text.TeXMath.Writers.TeX
import Text.TeXMath.Writers.Eqn
import Text.TeXMath.Writers.StarMath
import Text.TeXMath.Writers.Typst
import Text.TeXMath.Types
Loading
Loading