itextomml 1.3.20 → 1.3.21
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.
- data/README +4 -0
- data/ext/itex2MML.h +3 -3
- data/ext/itex2MML_ruby.c +47 -83
- data/ext/lex.yy.c +35 -90
- data/ext/y.tab.c +1 -1
- data/lib/itextomml.rb +0 -66
- data/test/test_itextomml.rb +73 -0
- metadata +6 -5
data/README
CHANGED
@@ -6,6 +6,10 @@ A summary of the LaTeX syntax supported in itex can be found at
|
|
6
6
|
|
7
7
|
http://golem.ph.utexas.edu/~distler/blog/itex2MMLcommands.html
|
8
8
|
|
9
|
+
The source repository for the itex2MML project may be found at
|
10
|
+
|
11
|
+
http://golem.ph.utexas.edu/~distler/code/itexToMML/changes
|
12
|
+
|
9
13
|
The Ruby module provides four public methods
|
10
14
|
|
11
15
|
require 'itextomml'
|
data/ext/itex2MML.h
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
/* itex2MML 1.3.
|
2
|
-
* itex2MML.h last modified
|
1
|
+
/* itex2MML 1.3.21
|
2
|
+
* itex2MML.h last modified 4/4/2010
|
3
3
|
*/
|
4
4
|
|
5
5
|
#ifndef ITEX2MML_H
|
6
6
|
#define ITEX2MML_H
|
7
7
|
|
8
|
-
#define ITEX2MML_VERSION "1.3.
|
8
|
+
#define ITEX2MML_VERSION "1.3.21"
|
9
9
|
|
10
10
|
#ifdef __cplusplus
|
11
11
|
extern "C" {
|
data/ext/itex2MML_ruby.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* ----------------------------------------------------------------------------
|
2
2
|
* This file was automatically generated by SWIG (http://www.swig.org).
|
3
|
-
* Version 1.3.
|
3
|
+
* Version 1.3.35
|
4
4
|
*
|
5
5
|
* This file is not intended to be easily readable and contains a number of
|
6
6
|
* coding conventions designed to improve portability and efficiency. Do not make
|
@@ -9,7 +9,6 @@
|
|
9
9
|
* ----------------------------------------------------------------------------- */
|
10
10
|
|
11
11
|
#define SWIGRUBY
|
12
|
-
|
13
12
|
/* -----------------------------------------------------------------------------
|
14
13
|
* This section contains generic SWIG labels for method/variable
|
15
14
|
* declarations/attributes, and other compiler dependent labels.
|
@@ -52,12 +51,6 @@
|
|
52
51
|
# endif
|
53
52
|
#endif
|
54
53
|
|
55
|
-
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
56
|
-
# if defined(_MSC_VER)
|
57
|
-
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
58
|
-
# endif
|
59
|
-
#endif
|
60
|
-
|
61
54
|
#ifndef SWIGUNUSEDPARM
|
62
55
|
# ifdef __cplusplus
|
63
56
|
# define SWIGUNUSEDPARM(p)
|
@@ -161,12 +154,6 @@
|
|
161
154
|
# endif
|
162
155
|
#endif
|
163
156
|
|
164
|
-
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
165
|
-
# if defined(_MSC_VER)
|
166
|
-
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
167
|
-
# endif
|
168
|
-
#endif
|
169
|
-
|
170
157
|
#ifndef SWIGUNUSEDPARM
|
171
158
|
# ifdef __cplusplus
|
172
159
|
# define SWIGUNUSEDPARM(p)
|
@@ -231,7 +218,7 @@
|
|
231
218
|
/* -----------------------------------------------------------------------------
|
232
219
|
* swigrun.swg
|
233
220
|
*
|
234
|
-
* This file contains generic
|
221
|
+
* This file contains generic CAPI SWIG runtime support for pointer
|
235
222
|
* type checking.
|
236
223
|
* ----------------------------------------------------------------------------- */
|
237
224
|
|
@@ -250,11 +237,11 @@
|
|
250
237
|
|
251
238
|
/*
|
252
239
|
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
|
253
|
-
creating a static or dynamic library from the
|
254
|
-
In 99.9% of the cases,
|
240
|
+
creating a static or dynamic library from the swig runtime code.
|
241
|
+
In 99.9% of the cases, swig just needs to declare them as 'static'.
|
255
242
|
|
256
|
-
But only do this if strictly necessary, ie, if you have problems
|
257
|
-
with your compiler or
|
243
|
+
But only do this if is strictly necessary, ie, if you have problems
|
244
|
+
with your compiler or so.
|
258
245
|
*/
|
259
246
|
|
260
247
|
#ifndef SWIGRUNTIME
|
@@ -281,14 +268,14 @@
|
|
281
268
|
/*
|
282
269
|
Flags/methods for returning states.
|
283
270
|
|
284
|
-
The
|
271
|
+
The swig conversion methods, as ConvertPtr, return and integer
|
285
272
|
that tells if the conversion was successful or not. And if not,
|
286
273
|
an error code can be returned (see swigerrors.swg for the codes).
|
287
274
|
|
288
275
|
Use the following macros/flags to set or process the returning
|
289
276
|
states.
|
290
277
|
|
291
|
-
In old versions
|
278
|
+
In old swig versions, you usually write code as:
|
292
279
|
|
293
280
|
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
|
294
281
|
// success code
|
@@ -296,7 +283,7 @@
|
|
296
283
|
//fail code
|
297
284
|
}
|
298
285
|
|
299
|
-
Now you can be more explicit:
|
286
|
+
Now you can be more explicit as:
|
300
287
|
|
301
288
|
int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
|
302
289
|
if (SWIG_IsOK(res)) {
|
@@ -305,7 +292,7 @@
|
|
305
292
|
// fail code
|
306
293
|
}
|
307
294
|
|
308
|
-
|
295
|
+
that seems to be the same, but now you can also do
|
309
296
|
|
310
297
|
Type *ptr;
|
311
298
|
int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
|
@@ -323,7 +310,7 @@
|
|
323
310
|
|
324
311
|
I.e., now SWIG_ConvertPtr can return new objects and you can
|
325
312
|
identify the case and take care of the deallocation. Of course that
|
326
|
-
also
|
313
|
+
requires also to SWIG_ConvertPtr to return new result values, as
|
327
314
|
|
328
315
|
int SWIG_ConvertPtr(obj, ptr,...) {
|
329
316
|
if (<obj is ok>) {
|
@@ -341,7 +328,7 @@
|
|
341
328
|
|
342
329
|
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
|
343
330
|
more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
|
344
|
-
|
331
|
+
swig errors code.
|
345
332
|
|
346
333
|
Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
|
347
334
|
allows to return the 'cast rank', for example, if you have this
|
@@ -355,8 +342,9 @@
|
|
355
342
|
fooi(1) // cast rank '0'
|
356
343
|
|
357
344
|
just use the SWIG_AddCast()/SWIG_CheckState()
|
358
|
-
*/
|
359
345
|
|
346
|
+
|
347
|
+
*/
|
360
348
|
#define SWIG_OK (0)
|
361
349
|
#define SWIG_ERROR (-1)
|
362
350
|
#define SWIG_IsOK(r) (r >= 0)
|
@@ -381,6 +369,7 @@
|
|
381
369
|
#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
|
382
370
|
#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
|
383
371
|
|
372
|
+
|
384
373
|
/* Cast-Rank Mode */
|
385
374
|
#if defined(SWIG_CASTRANK_MODE)
|
386
375
|
# ifndef SWIG_TypeRank
|
@@ -403,6 +392,8 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
|
|
403
392
|
#endif
|
404
393
|
|
405
394
|
|
395
|
+
|
396
|
+
|
406
397
|
#include <string.h>
|
407
398
|
|
408
399
|
#ifdef __cplusplus
|
@@ -499,58 +490,40 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
|
|
499
490
|
}
|
500
491
|
|
501
492
|
|
493
|
+
/* think of this as a c++ template<> or a scheme macro */
|
494
|
+
#define SWIG_TypeCheck_Template(comparison, ty) \
|
495
|
+
if (ty) { \
|
496
|
+
swig_cast_info *iter = ty->cast; \
|
497
|
+
while (iter) { \
|
498
|
+
if (comparison) { \
|
499
|
+
if (iter == ty->cast) return iter; \
|
500
|
+
/* Move iter to the top of the linked list */ \
|
501
|
+
iter->prev->next = iter->next; \
|
502
|
+
if (iter->next) \
|
503
|
+
iter->next->prev = iter->prev; \
|
504
|
+
iter->next = ty->cast; \
|
505
|
+
iter->prev = 0; \
|
506
|
+
if (ty->cast) ty->cast->prev = iter; \
|
507
|
+
ty->cast = iter; \
|
508
|
+
return iter; \
|
509
|
+
} \
|
510
|
+
iter = iter->next; \
|
511
|
+
} \
|
512
|
+
} \
|
513
|
+
return 0
|
514
|
+
|
502
515
|
/*
|
503
516
|
Check the typename
|
504
517
|
*/
|
505
518
|
SWIGRUNTIME swig_cast_info *
|
506
519
|
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
|
507
|
-
|
508
|
-
swig_cast_info *iter = ty->cast;
|
509
|
-
while (iter) {
|
510
|
-
if (strcmp(iter->type->name, c) == 0) {
|
511
|
-
if (iter == ty->cast)
|
512
|
-
return iter;
|
513
|
-
/* Move iter to the top of the linked list */
|
514
|
-
iter->prev->next = iter->next;
|
515
|
-
if (iter->next)
|
516
|
-
iter->next->prev = iter->prev;
|
517
|
-
iter->next = ty->cast;
|
518
|
-
iter->prev = 0;
|
519
|
-
if (ty->cast) ty->cast->prev = iter;
|
520
|
-
ty->cast = iter;
|
521
|
-
return iter;
|
522
|
-
}
|
523
|
-
iter = iter->next;
|
524
|
-
}
|
525
|
-
}
|
526
|
-
return 0;
|
520
|
+
SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
|
527
521
|
}
|
528
522
|
|
529
|
-
/*
|
530
|
-
Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
|
531
|
-
*/
|
523
|
+
/* Same as previous function, except strcmp is replaced with a pointer comparison */
|
532
524
|
SWIGRUNTIME swig_cast_info *
|
533
|
-
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *
|
534
|
-
|
535
|
-
swig_cast_info *iter = ty->cast;
|
536
|
-
while (iter) {
|
537
|
-
if (iter->type == from) {
|
538
|
-
if (iter == ty->cast)
|
539
|
-
return iter;
|
540
|
-
/* Move iter to the top of the linked list */
|
541
|
-
iter->prev->next = iter->next;
|
542
|
-
if (iter->next)
|
543
|
-
iter->next->prev = iter->prev;
|
544
|
-
iter->next = ty->cast;
|
545
|
-
iter->prev = 0;
|
546
|
-
if (ty->cast) ty->cast->prev = iter;
|
547
|
-
ty->cast = iter;
|
548
|
-
return iter;
|
549
|
-
}
|
550
|
-
iter = iter->next;
|
551
|
-
}
|
552
|
-
}
|
553
|
-
return 0;
|
525
|
+
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
|
526
|
+
SWIG_TypeCheck_Template(iter->type == from, into);
|
554
527
|
}
|
555
528
|
|
556
529
|
/*
|
@@ -838,15 +811,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
|
|
838
811
|
#ifdef read
|
839
812
|
# undef read
|
840
813
|
#endif
|
841
|
-
#ifdef bind
|
842
|
-
# undef bind
|
843
|
-
#endif
|
844
|
-
#ifdef close
|
845
|
-
# undef close
|
846
|
-
#endif
|
847
|
-
#ifdef connect
|
848
|
-
# undef connect
|
849
|
-
#endif
|
850
814
|
|
851
815
|
|
852
816
|
/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
|
@@ -1803,7 +1767,7 @@ static VALUE mItex2MML;
|
|
1803
1767
|
#define SWIG_RUBY_THREAD_END_BLOCK
|
1804
1768
|
|
1805
1769
|
|
1806
|
-
#define SWIGVERSION
|
1770
|
+
#define SWIGVERSION 0x010335
|
1807
1771
|
#define SWIG_VERSION SWIGVERSION
|
1808
1772
|
|
1809
1773
|
|
@@ -1876,7 +1840,7 @@ SWIG_ruby_failed(void)
|
|
1876
1840
|
}
|
1877
1841
|
|
1878
1842
|
|
1879
|
-
/*@SWIG:/
|
1843
|
+
/*@SWIG:/sw/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
|
1880
1844
|
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
|
1881
1845
|
{
|
1882
1846
|
VALUE obj = args[0];
|
@@ -1952,12 +1916,12 @@ SWIGINTERN VALUE
|
|
1952
1916
|
_wrap_itex2MML_filter(int argc, VALUE *argv, VALUE self) {
|
1953
1917
|
char *arg1 = (char *) 0 ;
|
1954
1918
|
unsigned long arg2 ;
|
1919
|
+
int result;
|
1955
1920
|
int res1 ;
|
1956
1921
|
char *buf1 = 0 ;
|
1957
1922
|
int alloc1 = 0 ;
|
1958
1923
|
unsigned long val2 ;
|
1959
1924
|
int ecode2 = 0 ;
|
1960
|
-
int result;
|
1961
1925
|
VALUE vresult = Qnil;
|
1962
1926
|
|
1963
1927
|
if ((argc < 2) || (argc > 2)) {
|
@@ -1987,12 +1951,12 @@ SWIGINTERN VALUE
|
|
1987
1951
|
_wrap_itex2MML_html_filter(int argc, VALUE *argv, VALUE self) {
|
1988
1952
|
char *arg1 = (char *) 0 ;
|
1989
1953
|
unsigned long arg2 ;
|
1954
|
+
int result;
|
1990
1955
|
int res1 ;
|
1991
1956
|
char *buf1 = 0 ;
|
1992
1957
|
int alloc1 = 0 ;
|
1993
1958
|
unsigned long val2 ;
|
1994
1959
|
int ecode2 = 0 ;
|
1995
|
-
int result;
|
1996
1960
|
VALUE vresult = Qnil;
|
1997
1961
|
|
1998
1962
|
if ((argc < 2) || (argc > 2)) {
|
data/ext/lex.yy.c
CHANGED
@@ -6,29 +6,10 @@
|
|
6
6
|
|
7
7
|
/* A lexical scanner generated by flex */
|
8
8
|
|
9
|
-
#define yy_create_buffer itex2MML_yy_create_buffer
|
10
|
-
#define yy_delete_buffer itex2MML_yy_delete_buffer
|
11
|
-
#define yy_flex_debug itex2MML_yy_flex_debug
|
12
|
-
#define yy_init_buffer itex2MML_yy_init_buffer
|
13
|
-
#define yy_flush_buffer itex2MML_yy_flush_buffer
|
14
|
-
#define yy_load_buffer_state itex2MML_yy_load_buffer_state
|
15
|
-
#define yy_switch_to_buffer itex2MML_yy_switch_to_buffer
|
16
|
-
#define yyin itex2MML_yyin
|
17
|
-
#define yyleng itex2MML_yyleng
|
18
|
-
#define yylex itex2MML_yylex
|
19
|
-
#define yylineno itex2MML_yylineno
|
20
|
-
#define yyout itex2MML_yyout
|
21
|
-
#define yyrestart itex2MML_yyrestart
|
22
|
-
#define yytext itex2MML_yytext
|
23
|
-
#define yywrap itex2MML_yywrap
|
24
|
-
#define yyalloc itex2MML_yyalloc
|
25
|
-
#define yyrealloc itex2MML_yyrealloc
|
26
|
-
#define yyfree itex2MML_yyfree
|
27
|
-
|
28
9
|
#define FLEX_SCANNER
|
29
10
|
#define YY_FLEX_MAJOR_VERSION 2
|
30
11
|
#define YY_FLEX_MINOR_VERSION 5
|
31
|
-
#define YY_FLEX_SUBMINOR_VERSION
|
12
|
+
#define YY_FLEX_SUBMINOR_VERSION 33
|
32
13
|
#if YY_FLEX_SUBMINOR_VERSION > 0
|
33
14
|
#define FLEX_BETA
|
34
15
|
#endif
|
@@ -50,7 +31,7 @@
|
|
50
31
|
|
51
32
|
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
|
52
33
|
|
53
|
-
#if
|
34
|
+
#if __STDC_VERSION__ >= 199901L
|
54
35
|
|
55
36
|
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
|
56
37
|
* if you want the limit (max/min) macros for int types.
|
@@ -113,12 +94,11 @@ typedef unsigned int flex_uint32_t;
|
|
113
94
|
|
114
95
|
#else /* ! __cplusplus */
|
115
96
|
|
116
|
-
|
117
|
-
#if defined (__STDC__)
|
97
|
+
#if __STDC__
|
118
98
|
|
119
99
|
#define YY_USE_CONST
|
120
100
|
|
121
|
-
#endif /*
|
101
|
+
#endif /* __STDC__ */
|
122
102
|
#endif /* ! __cplusplus */
|
123
103
|
|
124
104
|
#ifdef YY_USE_CONST
|
@@ -172,12 +152,7 @@ typedef unsigned int flex_uint32_t;
|
|
172
152
|
typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
173
153
|
#endif
|
174
154
|
|
175
|
-
|
176
|
-
#define YY_TYPEDEF_YY_SIZE_T
|
177
|
-
typedef size_t yy_size_t;
|
178
|
-
#endif
|
179
|
-
|
180
|
-
extern yy_size_t itex2MML_yyleng;
|
155
|
+
extern int itex2MML_yyleng;
|
181
156
|
|
182
157
|
extern FILE *itex2MML_yyin, *itex2MML_yyout;
|
183
158
|
|
@@ -203,6 +178,16 @@ extern FILE *itex2MML_yyin, *itex2MML_yyout;
|
|
203
178
|
|
204
179
|
#define unput(c) yyunput( c, (yytext_ptr) )
|
205
180
|
|
181
|
+
/* The following is because we cannot portably get our hands on size_t
|
182
|
+
* (without autoconf's help, which isn't available because we want
|
183
|
+
* flex-generated scanners to compile on their own).
|
184
|
+
*/
|
185
|
+
|
186
|
+
#ifndef YY_TYPEDEF_YY_SIZE_T
|
187
|
+
#define YY_TYPEDEF_YY_SIZE_T
|
188
|
+
typedef unsigned int yy_size_t;
|
189
|
+
#endif
|
190
|
+
|
206
191
|
#ifndef YY_STRUCT_YY_BUFFER_STATE
|
207
192
|
#define YY_STRUCT_YY_BUFFER_STATE
|
208
193
|
struct yy_buffer_state
|
@@ -220,7 +205,7 @@ struct yy_buffer_state
|
|
220
205
|
/* Number of characters read into yy_ch_buf, not including EOB
|
221
206
|
* characters.
|
222
207
|
*/
|
223
|
-
|
208
|
+
int yy_n_chars;
|
224
209
|
|
225
210
|
/* Whether we "own" the buffer - i.e., we know we created it,
|
226
211
|
* and can realloc() it to grow it, and should free() it to
|
@@ -290,8 +275,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
|
|
290
275
|
|
291
276
|
/* yy_hold_char holds the character lost when itex2MML_yytext is formed. */
|
292
277
|
static char yy_hold_char;
|
293
|
-
static
|
294
|
-
|
278
|
+
static int yy_n_chars; /* number of characters read into yy_ch_buf */
|
279
|
+
int itex2MML_yyleng;
|
295
280
|
|
296
281
|
/* Points to current character in buffer. */
|
297
282
|
static char *yy_c_buf_p = (char *) 0;
|
@@ -319,7 +304,7 @@ static void itex2MML_yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
|
|
319
304
|
|
320
305
|
YY_BUFFER_STATE itex2MML_yy_scan_buffer (char *base,yy_size_t size );
|
321
306
|
YY_BUFFER_STATE itex2MML_yy_scan_string (yyconst char *yy_str );
|
322
|
-
YY_BUFFER_STATE itex2MML_yy_scan_bytes (yyconst char *bytes,
|
307
|
+
YY_BUFFER_STATE itex2MML_yy_scan_bytes (yyconst char *bytes,int len );
|
323
308
|
|
324
309
|
void *itex2MML_yyalloc (yy_size_t );
|
325
310
|
void *itex2MML_yyrealloc (void *,yy_size_t );
|
@@ -2159,7 +2144,7 @@ int itex2MML_lineno = 1;
|
|
2159
2144
|
|
2160
2145
|
int itex2MML_rowposn = 0;
|
2161
2146
|
int itex2MML_displaymode = 0;
|
2162
|
-
#line
|
2147
|
+
#line 2148 "lex.yy.c"
|
2163
2148
|
|
2164
2149
|
#define INITIAL 0
|
2165
2150
|
#define MATH 1
|
@@ -2189,35 +2174,6 @@ int itex2MML_displaymode = 0;
|
|
2189
2174
|
|
2190
2175
|
static int yy_init_globals (void );
|
2191
2176
|
|
2192
|
-
/* Accessor methods to globals.
|
2193
|
-
These are made visible to non-reentrant scanners for convenience. */
|
2194
|
-
|
2195
|
-
int itex2MML_yylex_destroy (void );
|
2196
|
-
|
2197
|
-
int itex2MML_yyget_debug (void );
|
2198
|
-
|
2199
|
-
void itex2MML_yyset_debug (int debug_flag );
|
2200
|
-
|
2201
|
-
YY_EXTRA_TYPE itex2MML_yyget_extra (void );
|
2202
|
-
|
2203
|
-
void itex2MML_yyset_extra (YY_EXTRA_TYPE user_defined );
|
2204
|
-
|
2205
|
-
FILE *itex2MML_yyget_in (void );
|
2206
|
-
|
2207
|
-
void itex2MML_yyset_in (FILE * in_str );
|
2208
|
-
|
2209
|
-
FILE *itex2MML_yyget_out (void );
|
2210
|
-
|
2211
|
-
void itex2MML_yyset_out (FILE * out_str );
|
2212
|
-
|
2213
|
-
yy_size_t itex2MML_yyget_leng (void );
|
2214
|
-
|
2215
|
-
char *itex2MML_yyget_text (void );
|
2216
|
-
|
2217
|
-
int itex2MML_yyget_lineno (void );
|
2218
|
-
|
2219
|
-
void itex2MML_yyset_lineno (int line_number );
|
2220
|
-
|
2221
2177
|
/* Macros after this point can all be overridden by user definitions in
|
2222
2178
|
* section 1.
|
2223
2179
|
*/
|
@@ -2260,7 +2216,7 @@ static int input (void );
|
|
2260
2216
|
/* This used to be an fputs(), but since the string might contain NUL's,
|
2261
2217
|
* we now use fwrite().
|
2262
2218
|
*/
|
2263
|
-
#define ECHO fwrite( itex2MML_yytext, itex2MML_yyleng, 1, itex2MML_yyout )
|
2219
|
+
#define ECHO (void) fwrite( itex2MML_yytext, itex2MML_yyleng, 1, itex2MML_yyout )
|
2264
2220
|
#endif
|
2265
2221
|
|
2266
2222
|
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
@@ -2271,7 +2227,7 @@ static int input (void );
|
|
2271
2227
|
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
|
2272
2228
|
{ \
|
2273
2229
|
int c = '*'; \
|
2274
|
-
|
2230
|
+
size_t n; \
|
2275
2231
|
for ( n = 0; n < max_size && \
|
2276
2232
|
(c = getc( itex2MML_yyin )) != EOF && c != '\n'; ++n ) \
|
2277
2233
|
buf[n] = (char) c; \
|
@@ -2359,7 +2315,7 @@ YY_DECL
|
|
2359
2315
|
if (itex2MML_rowposn==2) itex2MML_rowposn=1;
|
2360
2316
|
|
2361
2317
|
|
2362
|
-
#line
|
2318
|
+
#line 2319 "lex.yy.c"
|
2363
2319
|
|
2364
2320
|
if ( !(yy_init) )
|
2365
2321
|
{
|
@@ -4856,7 +4812,7 @@ YY_RULE_SETUP
|
|
4856
4812
|
#line 965 "itex2MML.l"
|
4857
4813
|
ECHO;
|
4858
4814
|
YY_BREAK
|
4859
|
-
#line
|
4815
|
+
#line 4816 "lex.yy.c"
|
4860
4816
|
case YY_STATE_EOF(INITIAL):
|
4861
4817
|
case YY_STATE_EOF(MATH):
|
4862
4818
|
case YY_STATE_EOF(ATTRIBUTELIST):
|
@@ -5054,7 +5010,7 @@ static int yy_get_next_buffer (void)
|
|
5054
5010
|
|
5055
5011
|
else
|
5056
5012
|
{
|
5057
|
-
|
5013
|
+
int num_to_read =
|
5058
5014
|
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
5059
5015
|
|
5060
5016
|
while ( num_to_read <= 0 )
|
@@ -5068,7 +5024,7 @@ static int yy_get_next_buffer (void)
|
|
5068
5024
|
|
5069
5025
|
if ( b->yy_is_our_buffer )
|
5070
5026
|
{
|
5071
|
-
|
5027
|
+
int new_size = b->yy_buf_size * 2;
|
5072
5028
|
|
5073
5029
|
if ( new_size <= 0 )
|
5074
5030
|
b->yy_buf_size += b->yy_buf_size / 8;
|
@@ -5123,14 +5079,6 @@ static int yy_get_next_buffer (void)
|
|
5123
5079
|
else
|
5124
5080
|
ret_val = EOB_ACT_CONTINUE_SCAN;
|
5125
5081
|
|
5126
|
-
if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
|
5127
|
-
/* Extend the array by 50%, plus the number we really need. */
|
5128
|
-
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
|
5129
|
-
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) itex2MML_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
|
5130
|
-
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
|
5131
|
-
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
|
5132
|
-
}
|
5133
|
-
|
5134
5082
|
(yy_n_chars) += number_to_move;
|
5135
5083
|
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
|
5136
5084
|
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
|
@@ -5209,7 +5157,7 @@ static int yy_get_next_buffer (void)
|
|
5209
5157
|
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
|
5210
5158
|
{ /* need to shift things up to make room */
|
5211
5159
|
/* +2 for EOB chars. */
|
5212
|
-
register
|
5160
|
+
register int number_to_move = (yy_n_chars) + 2;
|
5213
5161
|
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
|
5214
5162
|
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
|
5215
5163
|
register char *source =
|
@@ -5258,7 +5206,7 @@ static int yy_get_next_buffer (void)
|
|
5258
5206
|
|
5259
5207
|
else
|
5260
5208
|
{ /* need more input */
|
5261
|
-
|
5209
|
+
int offset = (yy_c_buf_p) - (yytext_ptr);
|
5262
5210
|
++(yy_c_buf_p);
|
5263
5211
|
|
5264
5212
|
switch ( yy_get_next_buffer( ) )
|
@@ -5534,7 +5482,7 @@ void itex2MML_yypop_buffer_state (void)
|
|
5534
5482
|
*/
|
5535
5483
|
static void itex2MML_yyensure_buffer_stack (void)
|
5536
5484
|
{
|
5537
|
-
|
5485
|
+
int num_to_alloc;
|
5538
5486
|
|
5539
5487
|
if (!(yy_buffer_stack)) {
|
5540
5488
|
|
@@ -5546,9 +5494,7 @@ static void itex2MML_yyensure_buffer_stack (void)
|
|
5546
5494
|
(yy_buffer_stack) = (struct yy_buffer_state**)itex2MML_yyalloc
|
5547
5495
|
(num_to_alloc * sizeof(struct yy_buffer_state*)
|
5548
5496
|
);
|
5549
|
-
|
5550
|
-
YY_FATAL_ERROR( "out of dynamic memory in itex2MML_yyensure_buffer_stack()" );
|
5551
|
-
|
5497
|
+
|
5552
5498
|
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
|
5553
5499
|
|
5554
5500
|
(yy_buffer_stack_max) = num_to_alloc;
|
@@ -5566,8 +5512,6 @@ static void itex2MML_yyensure_buffer_stack (void)
|
|
5566
5512
|
((yy_buffer_stack),
|
5567
5513
|
num_to_alloc * sizeof(struct yy_buffer_state*)
|
5568
5514
|
);
|
5569
|
-
if ( ! (yy_buffer_stack) )
|
5570
|
-
YY_FATAL_ERROR( "out of dynamic memory in itex2MML_yyensure_buffer_stack()" );
|
5571
5515
|
|
5572
5516
|
/* zero only the new slots.*/
|
5573
5517
|
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
|
@@ -5612,7 +5556,7 @@ YY_BUFFER_STATE itex2MML_yy_scan_buffer (char * base, yy_size_t size )
|
|
5612
5556
|
|
5613
5557
|
/** Setup the input buffer state to scan a string. The next call to itex2MML_yylex() will
|
5614
5558
|
* scan from a @e copy of @a str.
|
5615
|
-
* @param
|
5559
|
+
* @param str a NUL-terminated string to scan
|
5616
5560
|
*
|
5617
5561
|
* @return the newly allocated buffer state object.
|
5618
5562
|
* @note If you want to scan bytes that may contain NUL values, then use
|
@@ -5631,11 +5575,12 @@ YY_BUFFER_STATE itex2MML_yy_scan_string (yyconst char * yystr )
|
|
5631
5575
|
*
|
5632
5576
|
* @return the newly allocated buffer state object.
|
5633
5577
|
*/
|
5634
|
-
YY_BUFFER_STATE itex2MML_yy_scan_bytes (yyconst char * yybytes,
|
5578
|
+
YY_BUFFER_STATE itex2MML_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
|
5635
5579
|
{
|
5636
5580
|
YY_BUFFER_STATE b;
|
5637
5581
|
char *buf;
|
5638
|
-
yy_size_t n
|
5582
|
+
yy_size_t n;
|
5583
|
+
int i;
|
5639
5584
|
|
5640
5585
|
/* Get memory for full buffer, including space for trailing EOB's. */
|
5641
5586
|
n = _yybytes_len + 2;
|
@@ -5717,7 +5662,7 @@ FILE *itex2MML_yyget_out (void)
|
|
5717
5662
|
/** Get the length of the current token.
|
5718
5663
|
*
|
5719
5664
|
*/
|
5720
|
-
|
5665
|
+
int itex2MML_yyget_leng (void)
|
5721
5666
|
{
|
5722
5667
|
return itex2MML_yyleng;
|
5723
5668
|
}
|
data/ext/y.tab.c
CHANGED
@@ -5266,7 +5266,7 @@ int itex2MML_do_html_filter (const char * buffer, unsigned long length, const in
|
|
5266
5266
|
}
|
5267
5267
|
++ptr2;
|
5268
5268
|
}
|
5269
|
-
if (itex2MML_write)
|
5269
|
+
if (itex2MML_write && ptr2 > ptr1)
|
5270
5270
|
(*itex2MML_write) (ptr1, ptr2 - ptr1);
|
5271
5271
|
|
5272
5272
|
if (ptr2 == end) goto _finish;
|
data/lib/itextomml.rb
CHANGED
@@ -103,69 +103,3 @@ module Itex2MML
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
## Unit Tests ##
|
107
|
-
if __FILE__ == $0
|
108
|
-
require 'test/unit'
|
109
|
-
|
110
|
-
class Itex2MMLTest < Test::Unit::TestCase
|
111
|
-
|
112
|
-
def test_inline_html
|
113
|
-
itex = Itex2MML::Parser.new
|
114
|
-
assert_equal("Inline: <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.html_filter('Inline: $\sin(x)$'))
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_inline
|
118
|
-
itex = Itex2MML::Parser.new
|
119
|
-
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter('Inline: $\sin(x)$'))
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_inline_inline
|
123
|
-
itex = Itex2MML::Parser.new
|
124
|
-
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.inline_filter('\sin(x)'))
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_block_html
|
128
|
-
itex = Itex2MML::Parser.new
|
129
|
-
assert_equal("Block: <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.html_filter('Block: $$\sin(x)$$'))
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_block
|
133
|
-
itex = Itex2MML::Parser.new
|
134
|
-
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter('Block: $$\sin(x)$$'))
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_block_block
|
138
|
-
itex = Itex2MML::Parser.new
|
139
|
-
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.block_filter('\sin(x)'))
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_inline_utf8
|
143
|
-
itex = Itex2MML::Parser.new
|
144
|
-
s = "".respond_to?(:force_encoding) ? "\u00F3" : "\303\263"
|
145
|
-
assert_equal("ecuasi"+ s + "n <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'>" +
|
146
|
-
"<mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>",
|
147
|
-
itex.html_filter("ecuasi\303\263n $\\sin(x)$"))
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_inline_utf8_inline
|
151
|
-
itex = Itex2MML::Parser.new
|
152
|
-
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter("ecuasi\303\263n $\\sin(x)$"))
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_utf8_in_svg_foreignObject
|
156
|
-
itex = Itex2MML::Parser.new
|
157
|
-
s = "".respond_to?(:force_encoding) ? "\u2032" : "\342\200\262"
|
158
|
-
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>g" +
|
159
|
-
"</mi><mo>′</mo><mo>=</mo><semantics><annotation-xml encoding=\"SVG1.1\"><svg w" +
|
160
|
-
"idth='40' height='40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3." +
|
161
|
-
"org/1999/xlink'><foreignObject height='19' width='20' font-size='16' y='0' x='0'><ma" +
|
162
|
-
"th display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g</mi><mo>" +
|
163
|
-
s + "</mo></math></foreignObject></svg></annotation-xml></semantics></math>",
|
164
|
-
itex.filter("$g' = \\begin{svg}<svg width='40' height='40' xmlns='http://www.w3.org/20" +
|
165
|
-
"00/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><foreignObject height='19' width='" +
|
166
|
-
"20' font-size='16' y='0' x='0'><math display='inline' xmlns='http://www.w3.org/1998/M" +
|
167
|
-
"ath/MathML'><mi>g</mi><mo>\342\200\262</mo></math></foreignObject></svg>\\end{svg}$"))
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Authors: Justin Bonnar <jbonnar@berkeley.edu>
|
2
|
+
# Jacques Distler <distler@golem.ph.utexas.edu>
|
3
|
+
#
|
4
|
+
# Placed in the Public Domain
|
5
|
+
|
6
|
+
$:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../lib" ) )
|
7
|
+
$:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext" ) )
|
8
|
+
require 'itextomml'
|
9
|
+
|
10
|
+
## Unit Tests ##
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
class Itex2MMLTest < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_inline_html
|
16
|
+
itex = Itex2MML::Parser.new
|
17
|
+
assert_equal("Inline: <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.html_filter('Inline: $\sin(x)$'))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_inline
|
21
|
+
itex = Itex2MML::Parser.new
|
22
|
+
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter('Inline: $\sin(x)$'))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_inline_inline
|
26
|
+
itex = Itex2MML::Parser.new
|
27
|
+
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.inline_filter('\sin(x)'))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_block_html
|
31
|
+
itex = Itex2MML::Parser.new
|
32
|
+
assert_equal("Block: <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.html_filter('Block: $$\sin(x)$$'))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_block
|
36
|
+
itex = Itex2MML::Parser.new
|
37
|
+
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter('Block: $$\sin(x)$$'))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_block_block
|
41
|
+
itex = Itex2MML::Parser.new
|
42
|
+
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.block_filter('\sin(x)'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_inline_utf8
|
46
|
+
itex = Itex2MML::Parser.new
|
47
|
+
s = "".respond_to?(:force_encoding) ? "\u00F3" : "\303\263"
|
48
|
+
assert_equal("ecuasi"+ s + "n <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'>" +
|
49
|
+
"<mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>",
|
50
|
+
itex.html_filter("ecuasi\303\263n $\\sin(x)$"))
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_inline_utf8_inline
|
54
|
+
itex = Itex2MML::Parser.new
|
55
|
+
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter("ecuasi\303\263n $\\sin(x)$"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_utf8_in_svg_foreignObject
|
59
|
+
itex = Itex2MML::Parser.new
|
60
|
+
s = "".respond_to?(:force_encoding) ? "\u2032" : "\342\200\262"
|
61
|
+
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>g" +
|
62
|
+
"</mi><mo>′</mo><mo>=</mo><semantics><annotation-xml encoding=\"SVG1.1\"><svg w" +
|
63
|
+
"idth='40' height='40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3." +
|
64
|
+
"org/1999/xlink'><foreignObject height='19' width='20' font-size='16' y='0' x='0'><ma" +
|
65
|
+
"th display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g</mi><mo>" +
|
66
|
+
s + "</mo></math></foreignObject></svg></annotation-xml></semantics></math>",
|
67
|
+
itex.filter("$g' = \\begin{svg}<svg width='40' height='40' xmlns='http://www.w3.org/20" +
|
68
|
+
"00/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><foreignObject height='19' width='" +
|
69
|
+
"20' font-size='16' y='0' x='0'><math display='inline' xmlns='http://www.w3.org/1998/M" +
|
70
|
+
"ath/MathML'><mi>g</mi><mo>\342\200\262</mo></math></foreignObject></svg>\\end{svg}$"))
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 21
|
9
|
+
version: 1.3.21
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jacques Distler
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-05 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- ext/itex2MML.h
|
34
34
|
- ext/y.tab.h
|
35
35
|
- lib/itextomml.rb
|
36
|
+
- test/test_itextomml.rb
|
36
37
|
- README
|
37
38
|
has_rdoc: true
|
38
39
|
homepage: http://golem.ph.utexas.edu/~distler/blog/itex2MML.html
|
@@ -65,5 +66,5 @@ rubygems_version: 1.3.6
|
|
65
66
|
signing_key:
|
66
67
|
specification_version: 3
|
67
68
|
summary: Native Ruby bindings to itex2MML.
|
68
|
-
test_files:
|
69
|
-
|
69
|
+
test_files:
|
70
|
+
- test/test_itextomml.rb
|