@@ -1681,16 +1681,12 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
16811681 let bracket_inl_text = last. inl_text ;
16821682
16831683 if self . options . extension . footnotes
1684- && match bracket_inl_text. next_sibling ( ) {
1685- Some ( n) => {
1686- if n. data ( ) . value . text ( ) . is_some ( ) {
1687- n. data ( ) . value . text ( ) . unwrap ( ) . as_bytes ( ) . starts_with ( b"^" )
1688- } else {
1689- false
1690- }
1691- }
1692- _ => false ,
1693- }
1684+ && bracket_inl_text. next_sibling ( ) . map_or ( false , |n| {
1685+ n. data ( )
1686+ . value
1687+ . text ( )
1688+ . map_or ( false , |t| t. as_bytes ( ) . starts_with ( b"^" ) )
1689+ } )
16941690 {
16951691 let mut text = String :: new ( ) ;
16961692 let mut sibling_iterator = bracket_inl_text. following_siblings ( ) ;
@@ -1704,6 +1700,15 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
17041700 // For example `[^_foo]` gives `^`, `_`, and `foo`. So pull them together.
17051701 // Since we're handling the closing bracket, the only siblings at this point are
17061702 // related to the footnote name.
1703+ //
1704+ // This re-construction of the original text value is an awful HACK
1705+ // we should reconsider. Can't we go back to the subject and pull
1706+ // it from there?
1707+
1708+ // If there's a non-Text/HtmlInline, such as SoftBreak, don't try to
1709+ // do anything fancy here at all.
1710+ let mut sussy = false ;
1711+
17071712 for sibling in sibling_iterator {
17081713 match sibling. data ( ) . value {
17091714 NodeValue :: Text ( ref literal) => {
@@ -1712,11 +1717,14 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
17121717 NodeValue :: HtmlInline ( ref literal) => {
17131718 text. push_str ( literal) ;
17141719 }
1715- _ => { }
1720+ _ => {
1721+ sussy = true ;
1722+ break ;
1723+ }
17161724 } ;
17171725 }
17181726
1719- if text. len ( ) > 1 {
1727+ if !sussy && text. len ( ) > 1 {
17201728 let inl = self . make_inline (
17211729 NodeValue :: FootnoteReference ( NodeFootnoteReference {
17221730 name : text[ 1 ..] . to_string ( ) ,
0 commit comments