mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	MFM: Improve search syntax
This commit is contained in:
		
							parent
							
								
									247f334334
								
							
						
					
					
						commit
						e4aa003157
					
				
					 2 changed files with 23 additions and 1 deletions
				
			
		| 
						 | 
					@ -9,7 +9,7 @@ export type TextElementSearch = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function(text: string) {
 | 
					export default function(text: string) {
 | 
				
			||||||
	const match = text.match(/^(.+?) 検索(\n|$)/);
 | 
						const match = text.match(/^(.+?) (検索|Search)(\n|$)/i);
 | 
				
			||||||
	if (!match) return null;
 | 
						if (!match) return null;
 | 
				
			||||||
	return {
 | 
						return {
 | 
				
			||||||
		type: 'search',
 | 
							type: 'search',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										22
									
								
								test/mfm.ts
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								test/mfm.ts
									
										
									
									
									
								
							| 
						 | 
					@ -93,6 +93,28 @@ describe('Text', () => {
 | 
				
			||||||
			assert.equal(tokens[0].type, 'inline-code');
 | 
								assert.equal(tokens[0].type, 'inline-code');
 | 
				
			||||||
			assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`');
 | 
								assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							it('search', () => {
 | 
				
			||||||
 | 
								const tokens1 = analyze('a b c 検索');
 | 
				
			||||||
 | 
								assert.deepEqual([
 | 
				
			||||||
 | 
									{ type: 'search', content: 'a b c 検索', query: 'a b c'}
 | 
				
			||||||
 | 
								], tokens1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								const tokens2 = analyze('a b c Search');
 | 
				
			||||||
 | 
								assert.deepEqual([
 | 
				
			||||||
 | 
									{ type: 'search', content: 'a b c Search', query: 'a b c'}
 | 
				
			||||||
 | 
								], tokens2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								const tokens3 = analyze('a b c search');
 | 
				
			||||||
 | 
								assert.deepEqual([
 | 
				
			||||||
 | 
									{ type: 'search', content: 'a b c search', query: 'a b c'}
 | 
				
			||||||
 | 
								], tokens3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								const tokens4 = analyze('a b c SEARCH');
 | 
				
			||||||
 | 
								assert.deepEqual([
 | 
				
			||||||
 | 
									{ type: 'search', content: 'a b c SEARCH', query: 'a b c'}
 | 
				
			||||||
 | 
								], tokens4);
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	describe('syntax highlighting', () => {
 | 
						describe('syntax highlighting', () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue