[MFM] Improve italic syntax detection
This commit is contained in:
		
							parent
							
								
									501379c82c
								
							
						
					
					
						commit
						42cd7c8a75
					
				
					 3 changed files with 18 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -224,7 +224,16 @@ const mfm = P.createLanguage({
 | 
			
		|||
 | 
			
		||||
	//#region Italic
 | 
			
		||||
	italic: r =>
 | 
			
		||||
		P.alt(P.regexp(/<i>([\s\S]+?)<\/i>/, 1), P.regexp(/(\*|_)([a-zA-Z0-9]+?[\s\S]*?)\1/, 2))
 | 
			
		||||
		P.alt(
 | 
			
		||||
			P.regexp(/<i>([\s\S]+?)<\/i>/, 1),
 | 
			
		||||
			P((input, i) => {
 | 
			
		||||
				const text = input.substr(i);
 | 
			
		||||
				const match = text.match(/^(\*|_)([a-zA-Z0-9]+?[\s\S]*?)\1/);
 | 
			
		||||
				if (!match) return P.makeFailure(i, 'not a italic');
 | 
			
		||||
				if (input[i - 1] != null && input[i - 1].match(/[a-z0-9]/i)) return P.makeFailure(i, 'not a italic');
 | 
			
		||||
				return P.makeSuccess(i + match[0].length, match[2]);
 | 
			
		||||
			})
 | 
			
		||||
		)
 | 
			
		||||
		.map(x => createTree('italic', P.alt(
 | 
			
		||||
			r.bold,
 | 
			
		||||
			r.strike,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue