allow attributes on thematic breaks
This commit is contained in:
		
					parent
					
						
							
								670763dd93
							
						
					
				
			
			
				commit
				
					
						82adc631d9
					
				
			
		
					 2 changed files with 14 additions and 4 deletions
				
			
		
							
								
								
									
										10
									
								
								src/html.rs
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/html.rs
									
										
									
									
									
								
							| 
						 | 
					@ -409,12 +409,20 @@ impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<'s, I, W> {
 | 
				
			||||||
                    Atom::Ellipsis => self.out.write_str("…")?,
 | 
					                    Atom::Ellipsis => self.out.write_str("…")?,
 | 
				
			||||||
                    Atom::EnDash => self.out.write_str("–")?,
 | 
					                    Atom::EnDash => self.out.write_str("–")?,
 | 
				
			||||||
                    Atom::EmDash => self.out.write_str("—")?,
 | 
					                    Atom::EmDash => self.out.write_str("—")?,
 | 
				
			||||||
                    Atom::ThematicBreak => self.out.write_str("\n<hr>")?,
 | 
					 | 
				
			||||||
                    Atom::NonBreakingSpace => self.out.write_str(" ")?,
 | 
					                    Atom::NonBreakingSpace => self.out.write_str(" ")?,
 | 
				
			||||||
                    Atom::Hardbreak => self.out.write_str("<br>\n")?,
 | 
					                    Atom::Hardbreak => self.out.write_str("<br>\n")?,
 | 
				
			||||||
                    Atom::Softbreak => self.out.write_char('\n')?,
 | 
					                    Atom::Softbreak => self.out.write_char('\n')?,
 | 
				
			||||||
                    Atom::Escape | Atom::Blankline => unreachable!("filtered out"),
 | 
					                    Atom::Escape | Atom::Blankline => unreachable!("filtered out"),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 | 
					                Event::ThematicBreak(attrs) => {
 | 
				
			||||||
 | 
					                    self.out.write_str("\n<hr")?;
 | 
				
			||||||
 | 
					                    for (a, v) in attrs.iter() {
 | 
				
			||||||
 | 
					                        write!(self.out, r#" {}=""#, a)?;
 | 
				
			||||||
 | 
					                        self.write_escape(v)?;
 | 
				
			||||||
 | 
					                        self.out.write_char('"')?;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    self.out.write_str(">")?;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if self.encountered_footnote {
 | 
					        if self.encountered_footnote {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,6 +26,8 @@ pub enum Event<'s> {
 | 
				
			||||||
    Str(CowStr<'s>),
 | 
					    Str(CowStr<'s>),
 | 
				
			||||||
    /// An atomic element.
 | 
					    /// An atomic element.
 | 
				
			||||||
    Atom(Atom<'s>),
 | 
					    Atom(Atom<'s>),
 | 
				
			||||||
 | 
					    /// A thematic break, typically a horizontal rule.
 | 
				
			||||||
 | 
					    ThematicBreak(Attributes<'s>),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, PartialEq, Eq)]
 | 
					#[derive(Debug, PartialEq, Eq)]
 | 
				
			||||||
| 
						 | 
					@ -248,8 +250,6 @@ pub enum Atom<'s> {
 | 
				
			||||||
    EnDash,
 | 
					    EnDash,
 | 
				
			||||||
    /// An em dash.
 | 
					    /// An em dash.
 | 
				
			||||||
    EmDash,
 | 
					    EmDash,
 | 
				
			||||||
    /// A thematic break, typically a horizontal rule.
 | 
					 | 
				
			||||||
    ThematicBreak,
 | 
					 | 
				
			||||||
    /// A space that must not break a line.
 | 
					    /// A space that must not break a line.
 | 
				
			||||||
    NonBreakingSpace,
 | 
					    NonBreakingSpace,
 | 
				
			||||||
    /// A newline that may or may not break a line in the output.
 | 
					    /// A newline that may or may not break a line in the output.
 | 
				
			||||||
| 
						 | 
					@ -674,7 +674,9 @@ impl<'s> Parser<'s> {
 | 
				
			||||||
            let event = match ev.kind {
 | 
					            let event = match ev.kind {
 | 
				
			||||||
                tree::EventKind::Atom(a) => match a {
 | 
					                tree::EventKind::Atom(a) => match a {
 | 
				
			||||||
                    block::Atom::Blankline => Event::Atom(Atom::Blankline),
 | 
					                    block::Atom::Blankline => Event::Atom(Atom::Blankline),
 | 
				
			||||||
                    block::Atom::ThematicBreak => Event::Atom(Atom::ThematicBreak),
 | 
					                    block::Atom::ThematicBreak => {
 | 
				
			||||||
 | 
					                        Event::ThematicBreak(self.block_attributes.take())
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    block::Atom::Attributes => {
 | 
					                    block::Atom::Attributes => {
 | 
				
			||||||
                        self.block_attributes.parse(content);
 | 
					                        self.block_attributes.parse(content);
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue