File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
src/generators/jsx-ast/utils Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,23 @@ import { TAG_TRANSFORMS } from '../constants.mjs';
99 */
1010const transformer = tree => {
1111 visit ( tree , 'element' , node => {
12- node . tagName =
13- node . tagName in TAG_TRANSFORMS
14- ? TAG_TRANSFORMS [ node . tagName ]
15- : node . tagName ;
12+ node . tagName = TAG_TRANSFORMS [ node . tagName ] || node . tagName ;
1613 } ) ;
14+
15+ // Are there footnotes?
16+ if ( tree . children . at ( - 1 ) . tagName === 'section' ) {
17+ const section = tree . children . pop ( ) ;
18+ // If so, move it into the proper location
19+ // Root -> Article -> Main content
20+ tree . children [ 2 ] ?. children [ 1 ] ?. children [ 0 ] ?. children ?. push (
21+ ...section . children
22+ ) ;
23+ }
1724} ;
1825
1926/**
2027 * Transforms elements in a syntax tree by replacing tag names according to the mapping.
28+ *
29+ * Also moves any generated root section into its proper location in the AST.
2130 */
2231export default ( ) => transformer ;
You can’t perform that action at this time.
0 commit comments