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';
9
9
*/
10
10
const transformer = tree => {
11
11
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 ;
16
13
} ) ;
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
+ }
17
24
} ;
18
25
19
26
/**
20
27
* 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.
21
30
*/
22
31
export default ( ) => transformer ;
You can’t perform that action at this time.
0 commit comments