mathematical 1.6.18 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -16
- data/Rakefile +80 -17
- data/ext/mathematical/CMakeLists.txt +23 -43
- data/ext/mathematical/extconf.rb +70 -24
- data/ext/mathematical/lasem_overrides.c +4 -8
- data/ext/mathematical/mathematical.c +7 -9
- data/ext/mathematical/mtex2MML/CMakeLists.txt +5 -5
- data/ext/mathematical/mtex2MML/README.md +19 -19
- data/ext/mathematical/mtex2MML/deps/uthash/package.json +2 -1
- data/ext/mathematical/mtex2MML/deps/uthash/utarray.h +35 -22
- data/ext/mathematical/mtex2MML/deps/uthash/uthash.h +524 -458
- data/ext/mathematical/mtex2MML/deps/uthash/utlist.h +255 -74
- data/ext/mathematical/mtex2MML/deps/uthash/utringbuffer.h +14 -14
- data/ext/mathematical/mtex2MML/deps/uthash/utstack.h +88 -0
- data/ext/mathematical/mtex2MML/deps/uthash/utstring.h +34 -25
- data/ext/mathematical/mtex2MML/script/cibuild +5 -48
- data/ext/mathematical/mtex2MML/script/test-quick +48 -0
- data/ext/mathematical/mtex2MML/src/environment.c +5 -1
- data/ext/mathematical/mtex2MML/tests/mathjax.c +591 -591
- data/ext/pulldown-latex/Cargo.lock +1833 -0
- data/fonts/cmex10.ttf +0 -0
- data/fonts/cmmi10.ttf +0 -0
- data/fonts/cmr10.ttf +0 -0
- data/fonts/cmsy10.ttf +0 -0
- data/fonts/eufm10.ttf +0 -0
- data/fonts/fonts.conf +11 -0
- data/fonts/msam10.ttf +0 -0
- data/fonts/msbm10.ttf +0 -0
- data/lib/mathematical/version.rb +1 -1
- data/lib/mathematical.rb +16 -1
- data/mathematical.gemspec +7 -3
- metadata +42 -14
- data/ext/mathematical/mtex2MML/appveyor.yml +0 -35
|
@@ -42,26 +42,26 @@ Both a static and dynamic library are created as part of the `cmake` build proce
|
|
|
42
42
|
|
|
43
43
|
The library exposes the following methods:
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
- `char * mtex2MML_parse(const char * str, unsigned long strlen, const int options)`: Converts a single TeX equation in `str` to MathML. Returns just the MathML equation, as a string.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
- `char * mtex2MML_global_parse(const char * str, unsigned long strlen, const int options, int global_start)`: The same as `mtex2MML_parse`, but allows you to provide a starting integer for equation numbering. Returns just the MathML equation, as a string.
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
- `int mtex2MML_filter(const char * str, unsigned long strlen, const int options)`: Given a string with a mix of TeX math and non-math elements, this returns a single string containing just the converted math elements. Equations are automatically numbered. Returns a `status` indicating success (`0`) or failure. You must access the resulting string with `mtex2MML_output`.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
- `int mtex2MML_text_filter(const char * str, unsigned long strlen, const int options)`: Given a string with a mix of TeX math and non-math elements, this converts all the math and leaves the rest of the string unmodified. Equations are automatically numbered. Returns a `status` indicating success (`0`) or failure. You must access the resulting string with `mtex2MML_output`. HTML within a math equation are normalized (eg. `<` becomes `<`).
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
- `int mtex2MML_strict_filter(const char * str, unsigned long strlen, const int options)`: Given a string with a mix of TeX math and non-math elements, this converts all the math and leaves the rest of the string unmodified. Equations are automatically numbered. Returns a `status` indicating success (`0`) or failure. You must access the resulting string with `mtex2MML_output`. HTML tags are removed completely.
|
|
54
54
|
|
|
55
55
|
The `options` argument determines which types of delimiters are to be used:
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
- `MTEX2MML_DELIMITER_DEFAULT` is the default, using `$..$` for inline and `$$..$$` for display.
|
|
58
|
+
- `MTEX2MML_DELIMITER_DOLLAR` uses single dollar signs: `$..$` for inline.
|
|
59
|
+
- `MTEX2MML_DELIMITER_DOUBLE` uses double dollar signs: `$$..$$` for display.
|
|
60
|
+
- `MTEX2MML_DELIMITER_PARENS` uses parenthesis: `\(..\)` for inline.
|
|
61
|
+
- `MTEX2MML_DELIMITER_BRACKETS` uses brackets: `\[..\]` for display.
|
|
62
|
+
- `MTEX2MML_DELIMITER_ENVIRONMENTS` supports bare `\\begin..\\end` environments.
|
|
63
63
|
|
|
64
|
-
[The
|
|
64
|
+
[The _tests/basic.c_](tests/basic.c) and [the _tests/delimiters.c_](tests/delimiters.c) suites provides a demonstrate of how these methods can be used.
|
|
65
65
|
|
|
66
66
|
### As a command
|
|
67
67
|
|
|
@@ -77,16 +77,16 @@ Use `mtex2MML -h` to get documentation on the options.
|
|
|
77
77
|
|
|
78
78
|
A `0` status indicates a success, while anything else indicates a failure, [as per the Bison documentation](http://www.gnu.org/software/bison/manual/html_node/Parser-Function.html). If a token cannot be parsed, or if the tokenization is nested too deep, the library will bail with a non-zero status code. An error message is also printed to STDERR.
|
|
79
79
|
|
|
80
|
-
[The
|
|
80
|
+
[The _tests/maliciousness.c_ suite](tests/maliciousness.c) has a demonstration on how to perform error handling.
|
|
81
81
|
|
|
82
82
|
## Building
|
|
83
83
|
|
|
84
84
|
To build mtex2MML, you need:
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
- [CMake](http://www.cmake.org/download/) (at least version 2.8.7)
|
|
87
|
+
- [Bison](https://www.gnu.org/software/bison/)
|
|
88
|
+
- [Flex](http://flex.sourceforge.net/)
|
|
89
|
+
- [Python3](https://www.python.org/) (just for the tests)
|
|
90
90
|
|
|
91
91
|
### OS X (brew or macports), Ubuntu and Arch Linux
|
|
92
92
|
|
|
@@ -120,8 +120,8 @@ ctest -V
|
|
|
120
120
|
|
|
121
121
|
mtex2MML has a test suite that mimics the one found in [MathJax](https://github.com/mathjax/MathJax-test), with a few exceptions:
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
- Files marked as `.xtex` have features that are not implemented, but probably should be in the future.
|
|
124
|
+
- Files marked as `.no_tex` have features that probably won't be implemented.
|
|
125
125
|
|
|
126
126
|
During the test run, the suite will list the percentage of features that still need coverage.
|
|
127
127
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2008-
|
|
2
|
+
Copyright (c) 2008-2022, Troy D. Hanson https://troydhanson.github.io/uthash/
|
|
3
3
|
All rights reserved.
|
|
4
4
|
|
|
5
5
|
Redistribution and use in source and binary forms, with or without
|
|
@@ -26,21 +26,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
26
26
|
#ifndef UTARRAY_H
|
|
27
27
|
#define UTARRAY_H
|
|
28
28
|
|
|
29
|
-
#define UTARRAY_VERSION 2.0
|
|
30
|
-
|
|
31
|
-
#ifdef __GNUC__
|
|
32
|
-
#define _UNUSED_ __attribute__ ((__unused__))
|
|
33
|
-
#else
|
|
34
|
-
#define _UNUSED_
|
|
35
|
-
#endif
|
|
29
|
+
#define UTARRAY_VERSION 2.3.0
|
|
36
30
|
|
|
37
31
|
#include <stddef.h> /* size_t */
|
|
38
32
|
#include <string.h> /* memset, etc */
|
|
39
33
|
#include <stdlib.h> /* exit */
|
|
40
|
-
#include "../../src/string_dup.h"
|
|
41
34
|
|
|
42
|
-
#
|
|
43
|
-
#define
|
|
35
|
+
#ifdef __GNUC__
|
|
36
|
+
#define UTARRAY_UNUSED __attribute__((__unused__))
|
|
37
|
+
#else
|
|
38
|
+
#define UTARRAY_UNUSED
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
#ifndef utarray_oom
|
|
42
|
+
#define utarray_oom() exit(-1)
|
|
44
43
|
#endif
|
|
45
44
|
|
|
46
45
|
typedef void (ctor_f)(void *dst, const void *src);
|
|
@@ -79,7 +78,9 @@ typedef struct {
|
|
|
79
78
|
|
|
80
79
|
#define utarray_new(a,_icd) do { \
|
|
81
80
|
(a) = (UT_array*)malloc(sizeof(UT_array)); \
|
|
82
|
-
if ((a) == NULL)
|
|
81
|
+
if ((a) == NULL) { \
|
|
82
|
+
utarray_oom(); \
|
|
83
|
+
} \
|
|
83
84
|
utarray_init(a,_icd); \
|
|
84
85
|
} while(0)
|
|
85
86
|
|
|
@@ -93,7 +94,9 @@ typedef struct {
|
|
|
93
94
|
char *utarray_tmp; \
|
|
94
95
|
while (((a)->i+(by)) > (a)->n) { (a)->n = ((a)->n ? (2*(a)->n) : 8); } \
|
|
95
96
|
utarray_tmp=(char*)realloc((a)->d, (a)->n*(a)->icd.sz); \
|
|
96
|
-
if (utarray_tmp == NULL)
|
|
97
|
+
if (utarray_tmp == NULL) { \
|
|
98
|
+
utarray_oom(); \
|
|
99
|
+
} \
|
|
97
100
|
(a)->d=utarray_tmp; \
|
|
98
101
|
} \
|
|
99
102
|
} while(0)
|
|
@@ -119,7 +122,7 @@ typedef struct {
|
|
|
119
122
|
#define utarray_len(a) ((a)->i)
|
|
120
123
|
|
|
121
124
|
#define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL)
|
|
122
|
-
#define _utarray_eltptr(a,j) ((a)->d + ((a)->icd.sz * (j)))
|
|
125
|
+
#define _utarray_eltptr(a,j) ((void*)((a)->d + ((a)->icd.sz * (j))))
|
|
123
126
|
|
|
124
127
|
#define utarray_insert(a,p,j) do { \
|
|
125
128
|
if ((j) > (a)->i) utarray_resize(a,j); \
|
|
@@ -217,23 +220,33 @@ typedef struct {
|
|
|
217
220
|
#define utarray_find(a,v,cmp) bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp)
|
|
218
221
|
|
|
219
222
|
#define utarray_front(a) (((a)->i) ? (_utarray_eltptr(a,0)) : NULL)
|
|
220
|
-
#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : (((
|
|
221
|
-
#define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e)
|
|
223
|
+
#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : (((a)->i != utarray_eltidx(a,e)+1) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL))
|
|
224
|
+
#define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) != 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL))
|
|
222
225
|
#define utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL)
|
|
223
|
-
#define utarray_eltidx(a,e) (((char*)(e)
|
|
226
|
+
#define utarray_eltidx(a,e) (((char*)(e) - (a)->d) / (a)->icd.sz)
|
|
224
227
|
|
|
225
228
|
/* last we pre-define a few icd for common utarrays of ints and strings */
|
|
226
229
|
static void utarray_str_cpy(void *dst, const void *src) {
|
|
227
|
-
char
|
|
228
|
-
|
|
230
|
+
char *const *srcc = (char *const *)src;
|
|
231
|
+
char **dstc = (char**)dst;
|
|
232
|
+
if (*srcc == NULL) {
|
|
233
|
+
*dstc = NULL;
|
|
234
|
+
} else {
|
|
235
|
+
*dstc = (char*)malloc(strlen(*srcc) + 1);
|
|
236
|
+
if (*dstc == NULL) {
|
|
237
|
+
utarray_oom();
|
|
238
|
+
} else {
|
|
239
|
+
strcpy(*dstc, *srcc);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
229
242
|
}
|
|
230
243
|
static void utarray_str_dtor(void *elt) {
|
|
231
244
|
char **eltc = (char**)elt;
|
|
232
245
|
if (*eltc != NULL) free(*eltc);
|
|
233
246
|
}
|
|
234
|
-
static const UT_icd ut_str_icd
|
|
235
|
-
static const UT_icd ut_int_icd
|
|
236
|
-
static const UT_icd ut_ptr_icd
|
|
247
|
+
static const UT_icd ut_str_icd UTARRAY_UNUSED = {sizeof(char*),NULL,utarray_str_cpy,utarray_str_dtor};
|
|
248
|
+
static const UT_icd ut_int_icd UTARRAY_UNUSED = {sizeof(int),NULL,NULL,NULL};
|
|
249
|
+
static const UT_icd ut_ptr_icd UTARRAY_UNUSED = {sizeof(void*),NULL,NULL,NULL};
|
|
237
250
|
|
|
238
251
|
|
|
239
252
|
#endif /* UTARRAY_H */
|