@@ -318,6 +318,7 @@ protected function _createEnviron($name, $mode, $environ = null) // {{{
318
318
assert (($ mode & ($ mode - 1 )) === 0 ); // mode must be a power of 2
319
319
320
320
$ math = false ;
321
+ $ optArgs = array ();
321
322
$ args = array ();
322
323
323
324
if (isset ($ this ->_environs [$ name ])) {
@@ -342,12 +343,23 @@ protected function _createEnviron($name, $mode, $environ = null) // {{{
342
343
// or displaymath), if so, prepare math node instead of environ node
343
344
$ math = isset ($ spec ['math ' ]) && $ spec ['math ' ];
344
345
346
+ $ parseArgs = isset ($ spec ['parseArgs ' ]) ? $ spec ['parseArgs ' ] : true ;
347
+
348
+ $ numOptArgs = isset ($ spec ['numOptArgs ' ]) ? intval ($ spec ['numOptArgs ' ]) : 0 ;
349
+ while (count ($ optArgs ) < $ numOptArgs ) {
350
+ if (false !== ($ arg = $ this ->_parseOptArg ($ mode , $ environ , $ parseArgs ))) {
351
+ $ optArgs [] = $ arg ;
352
+ } else {
353
+ break ;
354
+ }
355
+ }
356
+
345
357
// parse args, will be placed as environs first children, with
346
358
// no spaces between them, btw: \begin{tabular}c is a perfectly
347
359
// correct specification for a single-column table.
348
360
$ nargs = isset ($ spec ['numArgs ' ]) ? intval ($ spec ['numArgs ' ]) : 0 ;
349
361
while (count ($ args ) < $ nargs ) {
350
- if (false === ($ arg = $ this ->_parseArg ($ mode , $ environ ))) {
362
+ if (false === ($ arg = $ this ->_parseArg ($ mode , $ environ, $ parseArgs ))) {
351
363
$ arg = $ this ->_createNode (self ::TYPE_GROUP , $ mode );
352
364
}
353
365
$ arg ->setProp ('arg ' , true );
@@ -364,6 +376,10 @@ protected function _createEnviron($name, $mode, $environ = null) // {{{
364
376
$ node ->math = $ math ;
365
377
}
366
378
379
+ foreach ($ optArgs as $ arg ) {
380
+ $ node ->appendChild ($ arg );
381
+ }
382
+
367
383
foreach ($ args as $ arg ) {
368
384
$ node ->appendChild ($ arg );
369
385
}
0 commit comments