private ListItemBlock createFootnoteBlock ( String content , int counter , MacroTransformationContext context ) throws MacroExecutionException { List < Block > parsedContent ; try { parsedContent = this . contentParser . parse ( content , context , false , true ) . getChildren ( ) ; } catch ( MacroExecutionException e ) { parsedContent = Collections . < Block > singletonList ( new WordBlock ( content ) ) ; } Block result = new WordBlock ( "^" ) ; DocumentResourceReference reference = new DocumentResourceReference ( null ) ; reference . setAnchor ( FOOTNOTE_REFERENCE_ID_PREFIX + counter ) ; result = new LinkBlock ( Collections . singletonList ( result ) , reference , false ) ; result . setParameter ( ID_ATTRIBUTE_NAME , FOOTNOTE_ID_PREFIX + counter ) ; result . setParameter ( CLASS_ATTRIBUTE_NAME , "footnoteBackRef" ) ; result = new ListItemBlock ( Collections . singletonList ( result ) ) ; result . addChild ( new SpaceBlock ( ) ) ; result . addChildren ( parsedContent ) ; return ( ListItemBlock ) result ; }
Generate the footnote block a numbered list item containing a backlink to the footnote s reference and the actual footnote text parsed into XDOM .