lib: make code block language non option
no distinction between empty language and None
This commit is contained in:
		
					parent
					
						
							
								e79f767604
							
						
					
				
			
			
				commit
				
					
						0484ee2011
					
				
			
		
					 2 changed files with 7 additions and 9 deletions
				
			
		
							
								
								
									
										10
									
								
								src/html.rs
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/html.rs
									
										
									
									
									
								
							|  | @ -267,12 +267,12 @@ impl<'s> Writer<'s> { | ||||||
|                         write!(out, r#" style="text-align: {};">"#, a)?; |                         write!(out, r#" style="text-align: {};">"#, a)?; | ||||||
|                     } |                     } | ||||||
|                     Container::CodeBlock { language } => { |                     Container::CodeBlock { language } => { | ||||||
|                         if let Some(l) = language { |                         if language.is_empty() { | ||||||
|                             out.write_str(r#"><code class="language-"#)?; |  | ||||||
|                             write_attr(l, &mut out)?; |  | ||||||
|                             out.write_str(r#"">"#)?; |  | ||||||
|                         } else { |  | ||||||
|                             out.write_str("><code>")?; |                             out.write_str("><code>")?; | ||||||
|  |                         } else { | ||||||
|  |                             out.write_str(r#"><code class="language-"#)?; | ||||||
|  |                             write_attr(language, &mut out)?; | ||||||
|  |                             out.write_str(r#"">"#)?; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     Container::Image(..) => { |                     Container::Image(..) => { | ||||||
|  |  | ||||||
|  | @ -290,7 +290,7 @@ pub enum Container<'s> { | ||||||
|     /// A block with raw markup for a specific output format.
 |     /// A block with raw markup for a specific output format.
 | ||||||
|     RawBlock { format: &'s str }, |     RawBlock { format: &'s str }, | ||||||
|     /// A block with code in a specific language.
 |     /// A block with code in a specific language.
 | ||||||
|     CodeBlock { language: Option<&'s str> }, |     CodeBlock { language: &'s str }, | ||||||
|     /// An inline divider element.
 |     /// An inline divider element.
 | ||||||
|     Span, |     Span, | ||||||
|     /// An inline link, the first field is either a destination URL or an unresolved tag.
 |     /// An inline link, the first field is either a destination URL or an unresolved tag.
 | ||||||
|  | @ -902,9 +902,7 @@ impl<'s> Parser<'s> { | ||||||
|                                     if let Some(format) = content.strip_prefix('=') { |                                     if let Some(format) = content.strip_prefix('=') { | ||||||
|                                         Container::RawBlock { format } |                                         Container::RawBlock { format } | ||||||
|                                     } else { |                                     } else { | ||||||
|                                         Container::CodeBlock { |                                         Container::CodeBlock { language: content } | ||||||
|                                             language: (!content.is_empty()).then(|| content), |  | ||||||
|                                         } |  | ||||||
|                                     } |                                     } | ||||||
|                                 } |                                 } | ||||||
|                                 block::Leaf::TableCell(alignment) => Container::TableCell { |                                 block::Leaf::TableCell(alignment) => Container::TableCell { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue