Skip to content

Commit 9879a97

Browse files
committed
Wrap the README and update slightly
1 parent 5550ab2 commit 9879a97

File tree

1 file changed

+101
-26
lines changed

1 file changed

+101
-26
lines changed

README.md

Lines changed: 101 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,52 @@
33

44
A repository with examples using [MathJax version 4](https://github.com/mathjax/MathJax-src) in node applications.
55

6-
See the [MathJax Web Demos](https://github.com/mathjax/MathJax-demos-web) for examples of how to use MathJax in web pages. See the [MathJax documentation](https://docs.mathjax.org/) for complete details of how to use MathJax in web browsers and node. In particular, the [Examples in Node](https://docs.mathjax.org/en/latest/server/examples.html) page contains a list of the most important examples for node applications; the [Examples in a Browser](https://docs.mathjax.org/en/latest/web/examples.html) page lists other examples that may be useful; though they target web pages, the same techniques can be employed in node.
6+
See the [MathJax Web
7+
Demos](https://github.com/mathjax/MathJax-demos-web) for examples of
8+
how to use MathJax in web pages. See the [MathJax
9+
documentation](https://docs.mathjax.org/) for complete details of how
10+
to use MathJax in web browsers and node. In particular, the [Examples
11+
in Node](https://docs.mathjax.org/en/latest/server/examples.html) page
12+
contains a list of the most important examples for node applications;
13+
the [Examples in a
14+
Browser](https://docs.mathjax.org/en/latest/web/examples.html) page
15+
lists other examples that may be useful; though they target web pages,
16+
the same techniques can be employed in node.
717

818
## The Example files
919

10-
This repository contains a number of examples of command-line tools that exhibit the features of MathJax. The tools provide a number of command-line options, which you can discover by using the `--help` option when running them. Most of the examples include the ability to generate speech strings for the output, for example, via the `--speech` or ``--braille` options, and the language can be specified using `--sre locale de`, for example to get a German localization.
11-
12-
The tools accept one or more mathematical expressions as their arguments, or you can use the `--file` option to specify an HTML file that will be processed in full. If you don't give a file name, then the file is taken from standard input. Similarly, if you don't give any expressions, then they are taken from standard in, with a blank line separating expressions.
13-
14-
The tools come in two forms, one using ESM modules in the [`mjs`](mjs) directory, and one using CommonJS modules in the [`cjs`](cjs) folder, so you can see examples of both types. These directories are further subdivided into groups based on the mechanism by which MathJax is used: [`simple`](mjs/simple) uses a node-only mechanism that makes it easy to start experimenting with MathJax, but can't be used in web applications; [`component`](mjs/component) uses the MathJax Component framework to access MathJax's components via a configuration object like the one used in web browsers; [`direct`](mjs/direct) uses direct calls to the MathJax modules, without using MathJax components (so dynamic loading of TeX extensions is not supported for example); and finally, [`mixed`](mjs/mixed) combines direct calls with MathJax Components for the best of both worlds.
15-
16-
All four groups include examples of conversion from the various input formats to the various output formats, and include the following executables:
20+
This repository contains a number of examples of command-line tools
21+
that exhibit the features of MathJax. The tools provide a number of
22+
command-line options, which you can discover by using the `--help`
23+
option when running them. Most of the examples include the ability to
24+
generate speech strings for the output, for example, via the
25+
`--speech` or ``--braille` options, and the language can be specified
26+
using `--sre locale de`, for example to get a German localization.
27+
28+
The tools accept one or more mathematical expressions as their
29+
arguments, or you can use the `--file` option to specify an HTML file
30+
that will be processed in full. If you don't give a file name, then
31+
the file is taken from standard input. Similarly, if you don't give
32+
any expressions, then they are taken from standard in, with a blank
33+
line separating expressions.
34+
35+
The tools come in two forms, one using ESM modules in the [`mjs`](mjs)
36+
directory, and one using CommonJS modules in the [`cjs`](cjs) folder,
37+
so you can see examples of both types. These directories are further
38+
subdivided into groups based on the mechanism by which MathJax is
39+
used: [`simple`](mjs/simple) uses a node-only mechanism that makes it
40+
easy to start experimenting with MathJax, but can't be used in web
41+
applications; [`component`](mjs/component) uses the MathJax Component
42+
framework to access MathJax's components via a configuration object
43+
like the one used in web browsers; [`direct`](mjs/direct) uses direct
44+
calls to the MathJax modules, without using MathJax components (so
45+
dynamic loading of TeX extensions is not supported for example); and
46+
finally, [`mixed`](mjs/mixed) combines direct calls with MathJax
47+
Components for the best of both worlds.
48+
49+
All four groups include examples of conversion from the various input
50+
formats to the various output formats, and include the following
51+
executables:
1752

1853
* `tex2chtml`
1954
* `tex2svg`
@@ -26,38 +61,78 @@ All four groups include examples of conversion from the various input formats to
2661
* `am2svg`
2762
* `typeset`
2863

29-
The first nine convert from the format listed before the `2` to the format listed after it, and represent all combinations of the three input formats with three output formats. The `mml2mml` example is useful for reformatting a MathML string, or for converting it to use the Mathematical Alphanumerics block of Unicode characters rather than `mathvariant` attributes with ASCII characters, as required by MathML-Core, for instance.
30-
31-
The `typeset` tool allows you to convert from any input format to any output format, so is a "swiss army knife" example that gives you access to all the options within a common command.
32-
33-
Use the `--help` option to get a list of all the possible options for each tool.
34-
35-
The [`custom-tex-extension`](custom-tex-extension) directory contains an example of how to create your own custom TeX extension and load it as a component. See that directory for more details.
36-
37-
The [`puppeteer`](puppeteer) directory contains an example of how to call the [Puppeteer](https://developers.google.com/web/tools/puppeteer) library to use a headless Chrome instance to do server-side conversion of mathematics using MathJax. This is useful in situations where you are using characters that are not included in the main MathJax fonts, or including HTML within TeX or MathML expressions, as Chrome will be able to measure the sizes of these so that they can be displayed more reliably.
38-
39-
Finally, the [`jsdom`](jsdom) and [`linkedom`](linkedom) directories include examples of how to use those DOM libraries instead of MathJax's usual `LiteDOM` library as a replacement for the browser DOM.
64+
The first nine convert from the format listed before the `2` to the
65+
format listed after it, and represent all combinations of the three
66+
input formats with three output formats. The `mml2mml` example is
67+
useful for reformatting a MathML string, or for converting it to use
68+
the Mathematical Alphanumerics block of Unicode characters rather than
69+
`mathvariant` attributes with ASCII characters, as required by
70+
MathML-Core, for instance.
71+
72+
The `typeset` tool allows you to convert from any input format to any
73+
output format, so is a "swiss army knife" example that gives you
74+
access to all the options within a common command.
75+
76+
Use the `--help` option to get a list of all the possible options for
77+
each tool.
78+
79+
The [`custom-tex-extension`](custom-tex-extension) directory contains
80+
an example of how to create your own custom TeX extension and load it
81+
as a component. See that directory for more details.
82+
83+
The [`puppeteer`](puppeteer) directory contains an example of how to
84+
call the
85+
[Puppeteer](https://developers.google.com/web/tools/puppeteer) library
86+
to use a headless Chrome instance to do server-side conversion of
87+
mathematics using MathJax. This is useful in situations where you are
88+
using characters that are not included in the main MathJax fonts, or
89+
including HTML within TeX or MathML expressions, as Chrome will be
90+
able to measure the sizes of these so that they can be displayed more
91+
reliably.
92+
93+
Finally, the [`jsdom`](jsdom) and [`linkedom`](linkedom) directories
94+
include examples of how to use those DOM libraries instead of
95+
MathJax's usual `LiteDOM` library as a replacement for the browser
96+
DOM.
4097

4198
## The Utility Libraries
4299

43-
The tools in the `mjs` and `cjs` directories share a lot of common code, and that shared code has been moved to separate utility files in the [`util`](mjs/util) sub-directories of those directories. There is one for each of the input and output formats (the `Mml.js` file contains the code for both input and output in MathML format), and a main `Util.js` file that holds code common to all the tools. The `Direct.js` and `Mixed.js` utilities have code specific to those mechanisms of accessing MathJax, and the `Typeset.js` file handles the special needs of the `typeset` tool.
44-
45-
These utilities form the heart of the command-line tools, and it is in them that you will see the real details of how to work with MathJax; the individual tool files basically just load the needed libraries or MathJax modules, set up the configuration needed, and call the utility libraries to handle the details or getting the command-line arguments, setting up the needed configuration options, converting the expression or files, filtering the results according to the options given, and printing the results.
100+
The tools in the `mjs` and `cjs` directories share a lot of common
101+
code, and that shared code has been moved to separate utility files in
102+
the [`util`](mjs/util) sub-directories of those directories. There is
103+
one for each of the input and output formats (the `Mml.js` file
104+
contains the code for both input and output in MathML format), and a
105+
main `Util.js` file that holds code common to all the tools. The
106+
`Direct.js` and `Mixed.js` utilities have code specific to those
107+
mechanisms of accessing MathJax, and the `Typeset.js` file handles the
108+
special needs of the `typeset` tool.
109+
110+
These utilities form the heart of the command-line tools, and it is in
111+
them that you will see the real details of how to work with MathJax;
112+
the individual tool files basically just load the needed libraries or
113+
MathJax modules, set up the configuration needed, and call the utility
114+
libraries to handle the details or getting the command-line arguments,
115+
setting up the needed configuration options, converting the expression
116+
or files, filtering the results according to the options given, and
117+
printing the results.
46118

47119
## Installation
48120

49-
In order to try out these examples, clone this repository, enter the directory, and install the dependencies:
121+
In order to try out these examples, clone this repository, enter the
122+
directory, and install the dependencies:
50123

51124
``` bash
52125
git clone https://github.com/mathjax/MathJax-demos-node.git MathJax-demos-node
53126
cd MathJax-demos-node
54127
npm install
55128
```
56129

57-
To run the tools, use
130+
To run the tools, cd to the directory containing the tools and use
58131

59-
``` bash
132+
```
60133
node <example-name> [options] [expressions...]
61134
```
62135

63-
where `<example-name>` is the name of the example file, like `tex2svg`. Use the `--help` options to get more details about the options and arguments that each tool needs.
136+
where `<example-name>` is the name of the example file, like
137+
`tex2svg`. Use the `--help` options to get more details about the
138+
options and arguments that each tool needs.

0 commit comments

Comments
 (0)