File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import org .commonmark .ext .footnotes .FootnoteDefinition ;
44import org .commonmark .ext .footnotes .FootnoteReference ;
5+ import org .commonmark .ext .footnotes .InlineFootnote ;
56import org .commonmark .node .*;
67import org .commonmark .renderer .NodeRenderer ;
78import org .commonmark .renderer .html .HtmlNodeRendererContext ;
@@ -26,13 +27,15 @@ public FootnoteMarkdownNodeRenderer(MarkdownNodeRendererContext context) {
2627
2728 @ Override
2829 public Set <Class <? extends Node >> getNodeTypes () {
29- return Set .of (FootnoteReference .class , FootnoteDefinition .class );
30+ return Set .of (FootnoteReference .class , InlineFootnote . class , FootnoteDefinition .class );
3031 }
3132
3233 @ Override
3334 public void render (Node node ) {
3435 if (node instanceof FootnoteReference ) {
3536 renderReference ((FootnoteReference ) node );
37+ } else if (node instanceof InlineFootnote ) {
38+ renderInline ((InlineFootnote ) node );
3639 } else if (node instanceof FootnoteDefinition ) {
3740 renderDefinition ((FootnoteDefinition ) node );
3841 }
@@ -45,6 +48,12 @@ private void renderReference(FootnoteReference ref) {
4548 writer .raw ("]" );
4649 }
4750
51+ private void renderInline (InlineFootnote inlineFootnote ) {
52+ writer .raw ("^[" );
53+ renderChildren (inlineFootnote );
54+ writer .raw ("]" );
55+ }
56+
4857 private void renderDefinition (FootnoteDefinition def ) {
4958 writer .raw ("[^" );
5059 writer .raw (def .getLabel ());
Original file line number Diff line number Diff line change 1111import static org .junit .Assert .assertEquals ;
1212
1313public class FootnoteMarkdownRendererTest {
14- private static final Set <Extension > EXTENSIONS = Set .of (FootnotesExtension .create ());
14+ private static final Set <Extension > EXTENSIONS = Set .of (FootnotesExtension .builder (). inlineFootnotes ( true ). build ());
1515 private static final Parser PARSER = Parser .builder ().extensions (EXTENSIONS ).build ();
1616 private static final MarkdownRenderer RENDERER = MarkdownRenderer .builder ().extensions (EXTENSIONS ).build ();
1717
@@ -36,6 +36,11 @@ public void testBackslashInLabel() {
3636 assertRoundTrip ("[^\\ foo]\n \n [^\\ foo]: note\n " );
3737 }
3838
39+ @ Test
40+ public void testInline () {
41+ assertRoundTrip ("^[test *foo*]\n " );
42+ }
43+
3944 private void assertRoundTrip (String input ) {
4045 String rendered = parseAndRender (input );
4146 assertEquals (input , rendered );
You can’t perform that action at this time.
0 commit comments