mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	more tweaking and testing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									9c0ffbb88c
								
							
						
					
					
						commit
						7fe24c06fc
					
				| @ -587,9 +587,16 @@ module.BaseParser = { | |||||||
| 	// 	<item> ::=
 | 	// 	<item> ::=
 | ||||||
| 	// 		<string>
 | 	// 		<string>
 | ||||||
| 	// 		| { data: <ast> }
 | 	// 		| { data: <ast> }
 | ||||||
|  | 	// 		| <func>
 | ||||||
|  | 	//
 | ||||||
|  | 	// 	<func>(state)
 | ||||||
|  | 	// 		-> <ast>
 | ||||||
|  | 	//
 | ||||||
|  | 	//
 | ||||||
|  | 	// NOTE: <func>(..) is called in the context of page...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX should this also resolve e.data???
 | 	// XXX should this also resolve e.data???
 | ||||||
| 	/* XXX EXPERIMENTAL... | 	//* XXX EXPERIMENTAL...
 | ||||||
| 	resolve: function(page, ast, state={}){ | 	resolve: function(page, ast, state={}){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 		ast = ast  | 		ast = ast  | ||||||
| @ -598,6 +605,7 @@ module.BaseParser = { | |||||||
| 			this.expand(page, ast, state) | 			this.expand(page, ast, state) | ||||||
| 			: ast | 			: ast | ||||||
| 
 | 
 | ||||||
|  | 		// NOTE: this expects .flat() on the containing array...
 | ||||||
| 		var handleItem = function(e){ | 		var handleItem = function(e){ | ||||||
| 			// expand delayed sections...
 | 			// expand delayed sections...
 | ||||||
| 			e = typeof(e) == 'function' ? | 			e = typeof(e) == 'function' ? | ||||||
| @ -618,24 +626,12 @@ module.BaseParser = { | |||||||
| 			} else { | 			} else { | ||||||
| 				return [e] } } | 				return [e] } } | ||||||
| 
 | 
 | ||||||
| 		// XXX do we need this???
 | 		return ast instanceof Array ? | ||||||
| 		var issync = ast instanceof Array  | 				ast.map(handleItem) | ||||||
| 			&& ast.reduce(function(e, res){ | 					.flat() | ||||||
| 				return res === false ? |  | ||||||
| 					res |  | ||||||
| 					: e instanceof Promise }, true) |  | ||||||
| 
 |  | ||||||
| 			// NOTE: we need to await for ast here as we need stage 2 of 
 | 			// NOTE: we need to await for ast here as we need stage 2 of 
 | ||||||
| 			// 		parsing to happen AFTER everything else completes...
 | 			// 		parsing to happen AFTER everything else completes...
 | ||||||
| 			// XXX
 | 			// XXX
 | ||||||
| 		return issync ? |  | ||||||
| 				Promise.all(ast) |  | ||||||
| 					.then(function(ast){ |  | ||||||
| 						return ast.map(handleItem) |  | ||||||
| 							.flat() }) |  | ||||||
| 			: ast instanceof Array ? |  | ||||||
| 				ast.map(handleItem) |  | ||||||
| 					.flat() |  | ||||||
| 			: ast.then(function(ast){ | 			: ast.then(function(ast){ | ||||||
| 					return ast.map(handleItem) | 					return ast.map(handleItem) | ||||||
| 						.flat() }) | 						.flat() }) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user