block: specify footnote label in event
instead of using span
This commit is contained in:
		
					parent
					
						
							
								116245367a
							
						
					
				
			
			
				commit
				
					
						6cebdfcc0c
					
				
			
		
					 2 changed files with 9 additions and 7 deletions
				
			
		
							
								
								
									
										14
									
								
								src/block.rs
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								src/block.rs
									
										
									
									
									
								
							| 
						 | 
					@ -94,7 +94,7 @@ pub enum Container<'s> {
 | 
				
			||||||
    ListItem(ListItemKind),
 | 
					    ListItem(ListItemKind),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Span is footnote tag.
 | 
					    /// Span is footnote tag.
 | 
				
			||||||
    Footnote,
 | 
					    Footnote { label: &'s str },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Span is empty, before first '|' character.
 | 
					    /// Span is empty, before first '|' character.
 | 
				
			||||||
    Table,
 | 
					    Table,
 | 
				
			||||||
| 
						 | 
					@ -275,7 +275,9 @@ impl<'s> TreeParser<'s> {
 | 
				
			||||||
                } => Block::Leaf(LinkDefinition {
 | 
					                } => Block::Leaf(LinkDefinition {
 | 
				
			||||||
                    label: span.of(self.src),
 | 
					                    label: span.of(self.src),
 | 
				
			||||||
                }),
 | 
					                }),
 | 
				
			||||||
                Kind::Definition { footnote: true, .. } => Block::Container(Footnote),
 | 
					                Kind::Definition { footnote: true, .. } => Block::Container(Footnote {
 | 
				
			||||||
 | 
					                    label: span.of(self.src),
 | 
				
			||||||
 | 
					                }),
 | 
				
			||||||
                Kind::Blockquote => Block::Container(Blockquote),
 | 
					                Kind::Blockquote => Block::Container(Blockquote),
 | 
				
			||||||
                Kind::ListItem { ty, .. } => Block::Container(ListItem(match ty {
 | 
					                Kind::ListItem { ty, .. } => Block::Container(ListItem(match ty {
 | 
				
			||||||
                    ListType::Task => ListItemKind::Task {
 | 
					                    ListType::Task => ListItemKind::Task {
 | 
				
			||||||
| 
						 | 
					@ -1530,11 +1532,11 @@ mod test {
 | 
				
			||||||
    fn parse_footnote() {
 | 
					    fn parse_footnote() {
 | 
				
			||||||
        test_parse!(
 | 
					        test_parse!(
 | 
				
			||||||
            "[^tag]: description\n",
 | 
					            "[^tag]: description\n",
 | 
				
			||||||
            (Enter(Container(Footnote)), "tag"),
 | 
					            (Enter(Container(Footnote { label: "tag" })), "tag"),
 | 
				
			||||||
            (Enter(Leaf(Paragraph)), ""),
 | 
					            (Enter(Leaf(Paragraph)), ""),
 | 
				
			||||||
            (Inline, "description"),
 | 
					            (Inline, "description"),
 | 
				
			||||||
            (Exit(Leaf(Paragraph)), ""),
 | 
					            (Exit(Leaf(Paragraph)), ""),
 | 
				
			||||||
            (Exit(Container(Footnote)), "tag"),
 | 
					            (Exit(Container(Footnote { label: "tag" })), "tag"),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1552,12 +1554,12 @@ mod test {
 | 
				
			||||||
            (Inline, "[^a]"),
 | 
					            (Inline, "[^a]"),
 | 
				
			||||||
            (Exit(Leaf(Paragraph)), ""),
 | 
					            (Exit(Leaf(Paragraph)), ""),
 | 
				
			||||||
            (Atom(Blankline), "\n"),
 | 
					            (Atom(Blankline), "\n"),
 | 
				
			||||||
            (Enter(Container(Footnote)), "a"),
 | 
					            (Enter(Container(Footnote { label: "a" })), "a"),
 | 
				
			||||||
            (Enter(Leaf(Paragraph)), ""),
 | 
					            (Enter(Leaf(Paragraph)), ""),
 | 
				
			||||||
            (Inline, "note"),
 | 
					            (Inline, "note"),
 | 
				
			||||||
            (Exit(Leaf(Paragraph)), ""),
 | 
					            (Exit(Leaf(Paragraph)), ""),
 | 
				
			||||||
            (Atom(Blankline), "\n"),
 | 
					            (Atom(Blankline), "\n"),
 | 
				
			||||||
            (Exit(Container(Footnote)), "a"),
 | 
					            (Exit(Container(Footnote { label: "a" })), "a"),
 | 
				
			||||||
            (Enter(Leaf(Paragraph)), ""),
 | 
					            (Enter(Leaf(Paragraph)), ""),
 | 
				
			||||||
            (Inline, "para"),
 | 
					            (Inline, "para"),
 | 
				
			||||||
            (Exit(Leaf(Paragraph)), ""),
 | 
					            (Exit(Leaf(Paragraph)), ""),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -918,7 +918,7 @@ impl<'s> Parser<'s> {
 | 
				
			||||||
                        block::Node::Container(c) => match c {
 | 
					                        block::Node::Container(c) => match c {
 | 
				
			||||||
                            block::Container::Blockquote => Container::Blockquote,
 | 
					                            block::Container::Blockquote => Container::Blockquote,
 | 
				
			||||||
                            block::Container::Div => Container::Div { class: content },
 | 
					                            block::Container::Div => Container::Div { class: content },
 | 
				
			||||||
                            block::Container::Footnote => Container::Footnote { label: content },
 | 
					                            block::Container::Footnote { label } => Container::Footnote { label },
 | 
				
			||||||
                            block::Container::List {
 | 
					                            block::Container::List {
 | 
				
			||||||
                                kind: block::ListKind { ty, tight },
 | 
					                                kind: block::ListKind { ty, tight },
 | 
				
			||||||
                                marker,
 | 
					                                marker,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue