@@ -31,26 +31,30 @@ def run(self, **kwargs: Any) -> None:
3131 ):
3232 parent = foot_node .parent
3333 # second children of footnote node is the content text
34- text = foot_node .children [1 ].astext ()
34+ foot_node_content = foot_node .children [1 ].children
3535
3636 sidenote = SideNoteNode ()
3737 para = docutil_nodes .inline ()
3838 # first children of footnote node is the label
3939 label = foot_node .children [0 ].astext ()
4040
41- if text .startswith ("{-}" ):
41+ if foot_node_content [ 0 ]. astext () .startswith ("{-}" ):
4242 # marginnotes will have content starting with {-}
4343 # remove the number so it doesn't show
4444 para .attributes ["classes" ].append ("marginnote" )
45- para .append (docutil_nodes .Text (text .replace ("{-}" , "" )))
45+ foot_node_content [0 ] = docutil_nodes .Text (
46+ foot_node_content [0 ].replace ("{-}" , "" )
47+ )
48+ para .children = foot_node_content
4649
4750 sidenote .attributes ["names" ].append (f"marginnote-role-{ label } " )
4851 else :
4952 # sidenotes are the default behavior if no {-}
5053 # in this case we keep the number
5154 superscript = docutil_nodes .superscript ("" , label )
5255 para .attributes ["classes" ].append ("sidenote" )
53- para .extend ([superscript , docutil_nodes .Text (text )])
56+ parachildren = [superscript ] + foot_node_content
57+ para .children = parachildren
5458
5559 sidenote .attributes ["names" ].append (f"sidenote-role-{ label } " )
5660 sidenote .append (superscript )
0 commit comments