@@ -139,7 +139,7 @@ pub struct Subject<'a: 'd, 'r, 'o, 'd, 'i, 'c, 'p> {
139139 line_offset : usize ,
140140 flags : Flags ,
141141 pub refmap : & ' r mut RefMap ,
142- footnote_defs : & ' p FootnoteDefs < ' a > ,
142+ footnote_defs : & ' p FootnoteDefs ,
143143 delimiter_arena : & ' d mut Arena < Delimiter > ,
144144 last_delimiter : Option < NodeId > ,
145145 brackets : Vec < Bracket > ,
@@ -191,12 +191,12 @@ impl RefMap {
191191 }
192192}
193193
194- pub struct FootnoteDefs < ' a > {
195- defs : RefCell < Vec < & ' a AstNode < ' a > > > ,
194+ pub struct FootnoteDefs {
195+ defs : RefCell < Vec < AstNode > > ,
196196 counter : RefCell < usize > ,
197197}
198198
199- impl < ' a > FootnoteDefs < ' a > {
199+ impl < ' a > FootnoteDefs {
200200 pub fn new ( ) -> Self {
201201 Self {
202202 defs : RefCell :: new ( Vec :: new ( ) ) ,
@@ -210,11 +210,11 @@ impl<'a> FootnoteDefs<'a> {
210210 format ! ( "__inline_{}" , * counter)
211211 }
212212
213- pub fn add_definition ( & self , def : & ' a AstNode < ' a > ) {
213+ pub fn add_definition ( & self , def : AstNode ) {
214214 self . defs . borrow_mut ( ) . push ( def) ;
215215 }
216216
217- pub fn definitions ( & self ) -> std:: cell:: Ref < ' _ , Vec < & ' a AstNode < ' a > > > {
217+ pub fn definitions ( & self ) -> std:: cell:: Ref < ' _ , Vec < AstNode > > {
218218 self . defs . borrow ( )
219219 }
220220}
@@ -265,7 +265,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
265265 input : & ' i [ u8 ] ,
266266 line : usize ,
267267 refmap : & ' r mut RefMap ,
268- footnote_defs : & ' p FootnoteDefs < ' a > ,
268+ footnote_defs : & ' p FootnoteDefs ,
269269 delimiter_arena : & ' d mut Arena < Delimiter > ,
270270 ) -> Self {
271271 let mut s = Subject {
@@ -444,7 +444,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
444444 } else {
445445 // Just regular text
446446 self . pos += 1 ;
447- Some ( self . make_inline (
447+ Some ( self . mk_inline_node (
448448 NodeValue :: Text ( "^" . to_string ( ) ) ,
449449 self . pos - 1 ,
450450 self . pos - 1 ,
@@ -2057,7 +2057,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
20572057 }
20582058 }
20592059
2060- fn handle_inline_footnote ( & mut self ) -> Option < & ' a AstNode < ' a > > {
2060+ fn handle_inline_footnote ( & mut self ) -> Option < AstNode > {
20612061 let startpos = self . pos ;
20622062
20632063 // We're at ^, next should be [
@@ -2081,7 +2081,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
20812081 if depth != 0 {
20822082 // No matching closing bracket, treat as regular text
20832083 self . pos = startpos + 1 ;
2084- return Some ( self . make_inline ( NodeValue :: Text ( "^" . to_string ( ) ) , startpos, startpos) ) ;
2084+ return Some ( self . mk_inline_node ( NodeValue :: Text ( "^" . to_string ( ) ) , startpos, startpos) ) ;
20852085 }
20862086
20872087 // endpos is now one past the ], so adjust
@@ -2093,14 +2093,14 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
20932093 // Empty inline footnote should not parse
20942094 if content. is_empty ( ) {
20952095 self . pos = startpos + 1 ;
2096- return Some ( self . make_inline ( NodeValue :: Text ( "^" . to_string ( ) ) , startpos, startpos) ) ;
2096+ return Some ( self . mk_inline_node ( NodeValue :: Text ( "^" . to_string ( ) ) , startpos, startpos) ) ;
20972097 }
20982098
20992099 // Generate unique name
21002100 let name = self . footnote_defs . next_name ( ) ;
21012101
21022102 // Create the footnote reference node
2103- let ref_node = self . make_inline (
2103+ let ref_node = self . mk_inline_node (
21042104 NodeValue :: FootnoteReference ( NodeFootnoteReference {
21052105 name : name. clone ( ) ,
21062106 ref_num : 0 ,
@@ -2111,13 +2111,16 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
21112111 ) ;
21122112
21132113 // Parse the content as inlines
2114- let def_node = self . arena . alloc ( Node :: new ( RefCell :: new ( Ast :: new (
2115- NodeValue :: FootnoteDefinition ( NodeFootnoteDefinition {
2116- name : name. clone ( ) ,
2117- total_references : 0 ,
2118- } ) ,
2119- ( self . line , 1 ) . into ( ) ,
2120- ) ) ) ) ;
2114+ let def_node = AstNode :: new (
2115+ self . arena ,
2116+ Ast :: new (
2117+ NodeValue :: FootnoteDefinition ( NodeFootnoteDefinition {
2118+ name : name. clone ( ) ,
2119+ total_references : 0 ,
2120+ } ) ,
2121+ ( self . line , 1 ) . into ( ) ,
2122+ ) ,
2123+ ) ;
21212124
21222125 // Create a paragraph to hold the inline content
21232126 let mut para_ast = Ast :: new (
@@ -2132,19 +2135,18 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
21322135 }
21332136 }
21342137 para_ast. line_offsets = line_offsets;
2135- let para_node = self . arena . alloc ( Node :: new ( RefCell :: new ( para_ast) ) ) ;
2136- def_node. append ( para_node) ;
2138+ let para_node = def_node. append_value ( self . arena , para_ast) ;
21372139
21382140 // Parse the content recursively as inlines
2139- let delimiter_arena = Arena :: new ( ) ;
2141+ let mut delimiter_arena = Arena :: new ( ) ;
21402142 let mut subj = Subject :: new (
21412143 self . arena ,
21422144 self . options ,
21432145 content,
21442146 1 , // Use line 1 to match the paragraph's sourcepos
21452147 self . refmap ,
21462148 self . footnote_defs ,
2147- & delimiter_arena,
2149+ & mut delimiter_arena,
21482150 ) ;
21492151
21502152 while subj. parse_inline ( para_node) { }
@@ -2153,8 +2155,8 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
21532155
21542156 // Check if the parsed content is empty or contains only whitespace
21552157 // This handles whitespace-only content, null bytes, etc. generically
2156- let has_non_whitespace_content = para_node. children ( ) . any ( |child| {
2157- let child_data = child. data . borrow ( ) ;
2158+ let has_non_whitespace_content = para_node. children ( self . arena ) . any ( |child| {
2159+ let child_data = child. get ( self . arena ) ;
21582160 match & child_data. value {
21592161 NodeValue :: Text ( text) => !text. trim ( ) . is_empty ( ) ,
21602162 NodeValue :: SoftBreak | NodeValue :: LineBreak => false ,
@@ -2165,7 +2167,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'p> {
21652167 if !has_non_whitespace_content {
21662168 // Content is empty or whitespace-only after parsing, treat as literal text
21672169 self . pos = startpos + 1 ;
2168- return Some ( self . make_inline ( NodeValue :: Text ( "^" . to_string ( ) ) , startpos, startpos) ) ;
2170+ return Some ( self . mk_inline_node ( NodeValue :: Text ( "^" . to_string ( ) ) , startpos, startpos) ) ;
21692171 }
21702172
21712173 // Store the footnote definition
0 commit comments