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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2018-2022, Troy D. Hanson https://troydhanson.github.io/uthash/
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
12
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
13
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
14
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
15
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
16
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
18
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
19
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
20
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
21
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#ifndef UTSTACK_H
|
|
25
|
+
#define UTSTACK_H
|
|
26
|
+
|
|
27
|
+
#define UTSTACK_VERSION 2.3.0
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* This file contains macros to manipulate a singly-linked list as a stack.
|
|
31
|
+
*
|
|
32
|
+
* To use utstack, your structure must have a "next" pointer.
|
|
33
|
+
*
|
|
34
|
+
* ----------------.EXAMPLE -------------------------
|
|
35
|
+
* struct item {
|
|
36
|
+
* int id;
|
|
37
|
+
* struct item *next;
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* struct item *stack = NULL;
|
|
41
|
+
*
|
|
42
|
+
* int main() {
|
|
43
|
+
* int count;
|
|
44
|
+
* struct item *tmp;
|
|
45
|
+
* struct item *item = malloc(sizeof *item);
|
|
46
|
+
* item->id = 42;
|
|
47
|
+
* STACK_COUNT(stack, tmp, count); assert(count == 0);
|
|
48
|
+
* STACK_PUSH(stack, item);
|
|
49
|
+
* STACK_COUNT(stack, tmp, count); assert(count == 1);
|
|
50
|
+
* STACK_POP(stack, item);
|
|
51
|
+
* free(item);
|
|
52
|
+
* STACK_COUNT(stack, tmp, count); assert(count == 0);
|
|
53
|
+
* }
|
|
54
|
+
* --------------------------------------------------
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
#define STACK_TOP(head) (head)
|
|
58
|
+
|
|
59
|
+
#define STACK_EMPTY(head) (!(head))
|
|
60
|
+
|
|
61
|
+
#define STACK_PUSH(head,add) \
|
|
62
|
+
STACK_PUSH2(head,add,next)
|
|
63
|
+
|
|
64
|
+
#define STACK_PUSH2(head,add,next) \
|
|
65
|
+
do { \
|
|
66
|
+
(add)->next = (head); \
|
|
67
|
+
(head) = (add); \
|
|
68
|
+
} while (0)
|
|
69
|
+
|
|
70
|
+
#define STACK_POP(head,result) \
|
|
71
|
+
STACK_POP2(head,result,next)
|
|
72
|
+
|
|
73
|
+
#define STACK_POP2(head,result,next) \
|
|
74
|
+
do { \
|
|
75
|
+
(result) = (head); \
|
|
76
|
+
(head) = (head)->next; \
|
|
77
|
+
} while (0)
|
|
78
|
+
|
|
79
|
+
#define STACK_COUNT(head,el,counter) \
|
|
80
|
+
STACK_COUNT2(head,el,counter,next) \
|
|
81
|
+
|
|
82
|
+
#define STACK_COUNT2(head,el,counter,next) \
|
|
83
|
+
do { \
|
|
84
|
+
(counter) = 0; \
|
|
85
|
+
for ((el) = (head); el; (el) = (el)->next) { ++(counter); } \
|
|
86
|
+
} while (0)
|
|
87
|
+
|
|
88
|
+
#endif /* UTSTACK_H */
|
|
@@ -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,26 +26,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
26
26
|
#ifndef UTSTRING_H
|
|
27
27
|
#define UTSTRING_H
|
|
28
28
|
|
|
29
|
-
#define UTSTRING_VERSION 2.0
|
|
30
|
-
|
|
31
|
-
#ifdef __GNUC__
|
|
32
|
-
#define _UNUSED_ __attribute__ ((__unused__))
|
|
33
|
-
#else
|
|
34
|
-
#define _UNUSED_
|
|
35
|
-
#endif
|
|
29
|
+
#define UTSTRING_VERSION 2.3.0
|
|
36
30
|
|
|
37
31
|
#include <stdlib.h>
|
|
38
32
|
#include <string.h>
|
|
39
33
|
#include <stdio.h>
|
|
40
34
|
#include <stdarg.h>
|
|
41
35
|
|
|
42
|
-
#
|
|
43
|
-
#define
|
|
36
|
+
#ifdef __GNUC__
|
|
37
|
+
#define UTSTRING_UNUSED __attribute__((__unused__))
|
|
38
|
+
#else
|
|
39
|
+
#define UTSTRING_UNUSED
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#ifdef oom
|
|
43
|
+
#error "The name of macro 'oom' has been changed to 'utstring_oom'. Please update your code."
|
|
44
|
+
#define utstring_oom() oom()
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#ifndef utstring_oom
|
|
48
|
+
#define utstring_oom() exit(-1)
|
|
44
49
|
#endif
|
|
45
50
|
|
|
46
51
|
typedef struct {
|
|
47
|
-
char *d;
|
|
48
|
-
size_t n; /*
|
|
52
|
+
char *d; /* pointer to allocated buffer */
|
|
53
|
+
size_t n; /* allocated capacity */
|
|
49
54
|
size_t i; /* index of first unused byte */
|
|
50
55
|
} UT_string;
|
|
51
56
|
|
|
@@ -54,7 +59,9 @@ do { \
|
|
|
54
59
|
if (((s)->n - (s)->i) < (size_t)(amt)) { \
|
|
55
60
|
char *utstring_tmp = (char*)realloc( \
|
|
56
61
|
(s)->d, (s)->n + (amt)); \
|
|
57
|
-
if (utstring_tmp
|
|
62
|
+
if (!utstring_tmp) { \
|
|
63
|
+
utstring_oom(); \
|
|
64
|
+
} \
|
|
58
65
|
(s)->d = utstring_tmp; \
|
|
59
66
|
(s)->n += (amt); \
|
|
60
67
|
} \
|
|
@@ -81,9 +88,11 @@ do { \
|
|
|
81
88
|
|
|
82
89
|
#define utstring_new(s) \
|
|
83
90
|
do { \
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
(s) = (UT_string*)malloc(sizeof(UT_string)); \
|
|
92
|
+
if (!(s)) { \
|
|
93
|
+
utstring_oom(); \
|
|
94
|
+
} \
|
|
95
|
+
utstring_init(s); \
|
|
87
96
|
} while(0)
|
|
88
97
|
|
|
89
98
|
#define utstring_renew(s) \
|
|
@@ -117,11 +126,11 @@ do { \
|
|
|
117
126
|
(dst)->d[(dst)->i]='\0'; \
|
|
118
127
|
} while(0)
|
|
119
128
|
|
|
120
|
-
#define utstring_len(s) ((
|
|
129
|
+
#define utstring_len(s) ((s)->i)
|
|
121
130
|
|
|
122
131
|
#define utstring_body(s) ((s)->d)
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
UTSTRING_UNUSED static void utstring_printf_va(UT_string *s, const char *fmt, va_list ap) {
|
|
125
134
|
int n;
|
|
126
135
|
va_list cp;
|
|
127
136
|
for (;;) {
|
|
@@ -148,7 +157,7 @@ _UNUSED_ static void utstring_printf_va(UT_string *s, const char *fmt, va_list a
|
|
|
148
157
|
static void utstring_printf(UT_string *s, const char *fmt, ...)
|
|
149
158
|
__attribute__ (( format( printf, 2, 3) ));
|
|
150
159
|
#endif
|
|
151
|
-
|
|
160
|
+
UTSTRING_UNUSED static void utstring_printf(UT_string *s, const char *fmt, ...) {
|
|
152
161
|
va_list ap;
|
|
153
162
|
va_start(ap,fmt);
|
|
154
163
|
utstring_printf_va(s,fmt,ap);
|
|
@@ -159,7 +168,7 @@ _UNUSED_ static void utstring_printf(UT_string *s, const char *fmt, ...) {
|
|
|
159
168
|
* begin substring search functions *
|
|
160
169
|
******************************************************************************/
|
|
161
170
|
/* Build KMP table from left to right. */
|
|
162
|
-
|
|
171
|
+
UTSTRING_UNUSED static void _utstring_BuildTable(
|
|
163
172
|
const char *P_Needle,
|
|
164
173
|
size_t P_NeedleLen,
|
|
165
174
|
long *P_KMP_Table)
|
|
@@ -199,7 +208,7 @@ _UNUSED_ static void _utstring_BuildTable(
|
|
|
199
208
|
|
|
200
209
|
|
|
201
210
|
/* Build KMP table from right to left. */
|
|
202
|
-
|
|
211
|
+
UTSTRING_UNUSED static void _utstring_BuildTableR(
|
|
203
212
|
const char *P_Needle,
|
|
204
213
|
size_t P_NeedleLen,
|
|
205
214
|
long *P_KMP_Table)
|
|
@@ -239,7 +248,7 @@ _UNUSED_ static void _utstring_BuildTableR(
|
|
|
239
248
|
|
|
240
249
|
|
|
241
250
|
/* Search data from left to right. ( Multiple search mode. ) */
|
|
242
|
-
|
|
251
|
+
UTSTRING_UNUSED static long _utstring_find(
|
|
243
252
|
const char *P_Haystack,
|
|
244
253
|
size_t P_HaystackLen,
|
|
245
254
|
const char *P_Needle,
|
|
@@ -272,7 +281,7 @@ _UNUSED_ static long _utstring_find(
|
|
|
272
281
|
|
|
273
282
|
|
|
274
283
|
/* Search data from right to left. ( Multiple search mode. ) */
|
|
275
|
-
|
|
284
|
+
UTSTRING_UNUSED static long _utstring_findR(
|
|
276
285
|
const char *P_Haystack,
|
|
277
286
|
size_t P_HaystackLen,
|
|
278
287
|
const char *P_Needle,
|
|
@@ -306,7 +315,7 @@ _UNUSED_ static long _utstring_findR(
|
|
|
306
315
|
|
|
307
316
|
|
|
308
317
|
/* Search data from left to right. ( One time search mode. ) */
|
|
309
|
-
|
|
318
|
+
UTSTRING_UNUSED static long utstring_find(
|
|
310
319
|
UT_string *s,
|
|
311
320
|
long P_StartPosition, /* Start from 0. -1 means last position. */
|
|
312
321
|
const char *P_Needle,
|
|
@@ -352,7 +361,7 @@ _UNUSED_ static long utstring_find(
|
|
|
352
361
|
|
|
353
362
|
|
|
354
363
|
/* Search data from right to left. ( One time search mode. ) */
|
|
355
|
-
|
|
364
|
+
UTSTRING_UNUSED static long utstring_findR(
|
|
356
365
|
UT_string *s,
|
|
357
366
|
long P_StartPosition, /* Start from 0. -1 means last position. */
|
|
358
367
|
const char *P_Needle,
|
|
@@ -1,58 +1,15 @@
|
|
|
1
|
-
#!/bin/
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
2
4
|
|
|
3
5
|
mkdir -p build
|
|
4
|
-
cd build
|
|
6
|
+
cd build || exit 1
|
|
5
7
|
cmake ..
|
|
6
8
|
make
|
|
7
9
|
ctest -V
|
|
8
10
|
|
|
9
|
-
echo 'inline'
|
|
10
|
-
echo '\sin y' | ./mtex2MML --inline | grep "display='inline'" || exit 1
|
|
11
|
-
echo ''
|
|
12
|
-
|
|
13
|
-
echo 'display'
|
|
14
|
-
echo '\sin y' | ./mtex2MML --display | grep "display='block'" || exit 1
|
|
15
|
-
echo ''
|
|
16
|
-
|
|
17
|
-
echo 'inline print-mtex'
|
|
18
|
-
echo '\sin y' | ./mtex2MML --inline --print-mtex | grep '$\\sin y\$'|| exit 1
|
|
19
|
-
echo ''
|
|
20
|
-
|
|
21
|
-
echo 'display print-mtex'
|
|
22
|
-
echo '\sin y' | ./mtex2MML --display --print-mtex | grep '$$\\sin y\$\$' || exit 1
|
|
23
|
-
echo ''
|
|
24
|
-
|
|
25
|
-
echo 'dollar'
|
|
26
|
-
echo '$\sin y$' | ./mtex2MML | grep "display='inline'" || exit 1
|
|
27
|
-
|
|
28
|
-
echo 'double dollar'
|
|
29
|
-
echo '$$\sin y$$' | ./mtex2MML | grep "display='block'" || exit 1
|
|
30
|
-
|
|
31
|
-
echo 'parens'
|
|
32
|
-
echo '\(\sin y\)' | ./mtex2MML | grep "display='inline'" || exit 1
|
|
33
|
-
|
|
34
|
-
echo 'brackets'
|
|
35
|
-
echo '\[\sin y\]' | ./mtex2MML | grep "display='block'" || exit 1
|
|
36
|
-
|
|
37
|
-
echo 'dollar use-dollar'
|
|
38
|
-
echo '$\sin y$' | ./mtex2MML --use-dollar | grep "display='inline'" || exit 1
|
|
39
|
-
|
|
40
|
-
echo 'double dollar use-double'
|
|
41
|
-
echo '$$\sin y$$' | ./mtex2MML --use-double | grep "display='block'" || exit 1
|
|
42
|
-
|
|
43
|
-
echo 'parens use-parens'
|
|
44
|
-
echo '\(\sin y\)' | ./mtex2MML --use-parens | grep "display='inline'" || exit 1
|
|
45
|
-
|
|
46
|
-
echo 'brackets use-brackets'
|
|
47
|
-
echo '\[\sin y\]' | ./mtex2MML --use-brackets | grep "display='block'" || exit 1
|
|
48
|
-
|
|
49
|
-
echo 'env use-env'
|
|
50
|
-
echo '\\begin{align}3x + 9y &= -12\\end{align}' | ./mtex2MML --use-env | grep "display='block'" || exit 1
|
|
51
|
-
|
|
52
|
-
echo 'DONE with command check'
|
|
53
|
-
|
|
54
11
|
if [ -n "$CI" ]; then
|
|
55
|
-
if [ "$(
|
|
12
|
+
if [[ "$(uname -s)" == "Linux" ]] ; then
|
|
56
13
|
make memcheck
|
|
57
14
|
fi
|
|
58
15
|
fi
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
echo 'inline'
|
|
6
|
+
echo '\sin y' | ./mtex2MML --inline | grep "display='inline'" || exit 1
|
|
7
|
+
echo ''
|
|
8
|
+
|
|
9
|
+
echo 'display'
|
|
10
|
+
echo '\sin y' | ./mtex2MML --display | grep "display='block'" || exit 1
|
|
11
|
+
echo ''
|
|
12
|
+
|
|
13
|
+
echo 'inline print-mtex'
|
|
14
|
+
echo '\sin y' | ./mtex2MML --inline --print-mtex | grep '$\\sin y\$'|| exit 1
|
|
15
|
+
echo ''
|
|
16
|
+
|
|
17
|
+
echo 'display print-mtex'
|
|
18
|
+
echo '\sin y' | ./mtex2MML --display --print-mtex | grep '$$\\sin y\$\$' || exit 1
|
|
19
|
+
echo ''
|
|
20
|
+
|
|
21
|
+
echo 'dollar'
|
|
22
|
+
echo '$\sin y$' | ./mtex2MML | grep "display='inline'" || exit 1
|
|
23
|
+
|
|
24
|
+
echo 'double dollar'
|
|
25
|
+
echo '$$\sin y$$' | ./mtex2MML | grep "display='block'" || exit 1
|
|
26
|
+
|
|
27
|
+
echo 'parens'
|
|
28
|
+
echo '\(\sin y\)' | ./mtex2MML | grep "display='inline'" || exit 1
|
|
29
|
+
|
|
30
|
+
echo 'brackets'
|
|
31
|
+
echo '\[\sin y\]' | ./mtex2MML | grep "display='block'" || exit 1
|
|
32
|
+
|
|
33
|
+
echo 'dollar use-dollar'
|
|
34
|
+
echo '$\sin y$' | ./mtex2MML --use-dollar | grep "display='inline'" || exit 1
|
|
35
|
+
|
|
36
|
+
echo 'double dollar use-double'
|
|
37
|
+
echo '$$\sin y$$' | ./mtex2MML --use-double | grep "display='block'" || exit 1
|
|
38
|
+
|
|
39
|
+
echo 'parens use-parens'
|
|
40
|
+
echo '\(\sin y\)' | ./mtex2MML --use-parens | grep "display='inline'" || exit 1
|
|
41
|
+
|
|
42
|
+
echo 'brackets use-brackets'
|
|
43
|
+
echo '\[\sin y\]' | ./mtex2MML --use-brackets | grep "display='block'" || exit 1
|
|
44
|
+
|
|
45
|
+
echo 'env use-env'
|
|
46
|
+
echo '\\begin{align}3x + 9y &= -12\\end{align}' | ./mtex2MML --use-env | grep "display='block'" || exit 1
|
|
47
|
+
|
|
48
|
+
echo 'DONE with command check'
|
|
@@ -93,6 +93,10 @@ int mtex2MML_identify_eqn_number(envType environment_type, char *line)
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
static int div_ceil(int a, int b) {
|
|
97
|
+
return (a/b) + !!(a%b);
|
|
98
|
+
}
|
|
99
|
+
|
|
96
100
|
void mtex2MML_env_replacements(UT_array **environment_data_stack, encaseType **encase, const char *environment)
|
|
97
101
|
{
|
|
98
102
|
/* TODO: these next detections are gross, but substack and cases are rather special */
|
|
@@ -254,7 +258,7 @@ void mtex2MML_env_replacements(UT_array **environment_data_stack, encaseType **e
|
|
|
254
258
|
rather than a label per row. in that case, jam a label
|
|
255
259
|
in the middle. */
|
|
256
260
|
if (environment_type == ENV_GATHER || environment_type == ENV_MULTLINE) {
|
|
257
|
-
insertion_idx =
|
|
261
|
+
insertion_idx = div_ceil(utarray_len(eqn_number_stack), 2);
|
|
258
262
|
eqn = 1;
|
|
259
263
|
utarray_insert(eqn_number_stack, &eqn, insertion_idx);
|
|
260
264
|
utarray_pop_back(eqn_number_stack);
|