File tree Expand file tree Collapse file tree 4 files changed +68
-61
lines changed
Expand file tree Collapse file tree 4 files changed +68
-61
lines changed Original file line number Diff line number Diff line change @@ -89,20 +89,16 @@ export default class Stack {
8989 const item = NodeUtil . isNode ( node ) ?
9090 this . _factory . create ( 'mml' , node ) : node ;
9191 item . global = this . global ;
92- const top = this . stack . length ? this . Top ( ) . checkItem ( item ) : true ;
93- if ( ! top ) {
92+ const [ top , success ] =
93+ this . stack . length ? this . Top ( ) . checkItem ( item ) : [ null , true ] ;
94+ if ( ! success ) {
9495 continue ;
9596 }
96- if ( top instanceof Array ) {
97+ if ( top ) {
9798 this . Pop ( ) ;
9899 this . Push ( ...top ) ;
99100 continue ;
100101 }
101- if ( top instanceof BaseItem ) {
102- this . Pop ( ) ;
103- this . Push ( top ) ;
104- continue ;
105- }
106102 this . stack . push ( item ) ;
107103 if ( item . env ) {
108104 Object . assign ( item . env , this . env ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export type Prop = string | number | boolean | MmlNode | PropList;
3636
3737export type PropList = { [ key : string ] : Prop } ;
3838
39- export type CheckType = boolean | StackItem | ( MmlNode | StackItem ) [ ] ;
39+ export type CheckType = [ ( MmlNode | StackItem ) [ ] , boolean ] ;
4040
4141
4242export interface NodeStack {
@@ -317,6 +317,17 @@ export interface StackItemClass {
317317 */
318318export abstract class BaseItem extends MmlStack implements StackItem {
319319
320+ /**
321+ * The fail value.
322+ * @type {CheckType }
323+ */
324+ protected static fail : CheckType = [ null , false ] ;
325+
326+ /**
327+ * The success value.
328+ * @type {CheckType }
329+ */
330+ protected static success : CheckType = [ null , true ] ;
320331
321332 /**
322333 * A list of basic errors.
@@ -428,7 +439,7 @@ export abstract class BaseItem extends MmlStack implements StackItem {
428439 }
429440 if ( item . isKind ( 'cell' ) && this . isOpen ) {
430441 if ( item . getProperty ( 'linebreak' ) ) {
431- return false ;
442+ return BaseItem . fail ;
432443 }
433444 // @test Ampersand-error
434445 throw new TexError ( 'Misplaced' , 'Misplaced %1' , item . getName ( ) ) ;
@@ -440,10 +451,10 @@ export abstract class BaseItem extends MmlStack implements StackItem {
440451 throw new TexError ( id , message , item . getName ( ) ) ;
441452 }
442453 if ( ! item . isFinal ) {
443- return true ;
454+ return BaseItem . success ;
444455 }
445456 this . Push ( item . First ) ;
446- return false ;
457+ return BaseItem . fail ;
447458 }
448459
449460
You can’t perform that action at this time.
0 commit comments