mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	cleanup and some fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									b711a2937e
								
							
						
					
					
						commit
						effeac728b
					
				| @ -780,6 +780,7 @@ object.Constructor('Page', BasePage, { | ||||
| 		// NOTE: the filter argument has the same semantics as the filter 
 | ||||
| 		// 		macro with one exception, when used in quote, the body is 
 | ||||
| 		// 		not expanded...
 | ||||
| 		// NOTE: the filter argument uses the same filters as @filter(..)
 | ||||
| 		//
 | ||||
| 		// XXX need a way to escape macros -- i.e. include </quote> in a quoted text...
 | ||||
| 		quote: Macro( | ||||
| @ -817,19 +818,19 @@ object.Constructor('Page', BasePage, { | ||||
| 				// NOTE: since the body of quote(..) only has filters applied 
 | ||||
| 				// 		to it doing the first stage of .filter(..) as late 
 | ||||
| 				// 		as the second stage here will have no ill effect...
 | ||||
| 				return function(state){ | ||||
| 				// NOTE: this uses the same filters as @filter(..)
 | ||||
| 				return async function(state){ | ||||
| 					// add global quote-filters...
 | ||||
| 					filters = | ||||
| 						(state.quote_filters  | ||||
| 								&& !(filters ?? []).includes(this.ISOLATED_FILTERS)) ? | ||||
| 							[...state.quote_filters, ...(filters ?? [])] | ||||
| 							: filters | ||||
| 					if(filters){ | ||||
| 						filters = Object.fromEntries(Object.entries(filters)) | ||||
| 						return this.macros.filter | ||||
| 							.call(this, filters, text, state, false) | ||||
| 							.call(this, state) } | ||||
| 					return text } }), | ||||
| 					return filters ? | ||||
| 						await this.__parser__.callMacro( | ||||
| 								this, 'filter', filters, text, state, false) | ||||
| 							.call(this, state) | ||||
| 						: text } }), | ||||
| 		// very similar to @filter(..) but will affect @quote(..) filters...
 | ||||
| 		'quote-filter': function(args, body, state){ | ||||
| 			var filters = state.quote_filters =  | ||||
|  | ||||
| @ -148,8 +148,7 @@ module.BaseParser = { | ||||
| 	// NOTE: arg pre-parsing is dome by .lex(..) but at that stage we do not
 | ||||
| 	// 		yet touch the actual macros (we need them to get the .arg_spec)
 | ||||
| 	// 		so the actual parsing is done in .expand(..)
 | ||||
| 	parseArgs: function(spec, args, state){ | ||||
| 		var that = this | ||||
| 	parseArgs: function(spec, args){ | ||||
| 		// spec...
 | ||||
| 		var order = spec.slice() | ||||
| 		var bools = new Set( | ||||
| @ -179,6 +178,16 @@ module.BaseParser = { | ||||
| 					(res[e] = true) | ||||
| 					: (res[order.shift()] = e) }) | ||||
| 		return res }, | ||||
| 	// XXX should this be here or on page???
 | ||||
| 	callMacro: function(page, name, args, body, state, ...rest){ | ||||
| 		return page.macros[name].call(page,  | ||||
| 				this.parseArgs( | ||||
| 					page.macros[name].arg_spec  | ||||
| 						?? [],  | ||||
| 					args), | ||||
| 				body,  | ||||
| 				state,  | ||||
| 				...rest) }, | ||||
| 
 | ||||
| 
 | ||||
| 	// Strip comments...
 | ||||
| @ -415,16 +424,11 @@ module.BaseParser = { | ||||
| 			// nested macro -- skip...
 | ||||
| 			if(typeof(page.macros[name]) != 'function'){ | ||||
| 				continue } | ||||
| 			// args...
 | ||||
| 			args = this.parseArgs.call(page, | ||||
| 				page.macros[name].arg_spec  | ||||
| 					?? [],  | ||||
| 				args, | ||||
| 				state) | ||||
| 			// call...
 | ||||
| 
 | ||||
| 			var res =  | ||||
| 				await page.macros[name].call(page, args, body, state, value) | ||||
| 				await this.callMacro(page, name, args, body, state)  | ||||
| 					?? '' | ||||
| 
 | ||||
| 			// result...
 | ||||
| 			if(res instanceof Array  | ||||
| 					|| page.macros[name] instanceof types.Generator){ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user