3434import dev .ebullient .convert .tools .dnd5e .qute .QuteSubclass ;
3535
3636public class Json2QuteClass extends Json2QuteCommon {
37+ final static Pattern footnotePattern = Pattern .compile ("\\ ^\\ [([^\\ ]]+)\\ ]" );
3738
3839 final static Map <String , ClassFeature > keyToClassFeature = new HashMap <>();
3940
@@ -358,6 +359,7 @@ Multiclassing buildMulticlassing() {
358359 List <String > buildProgressionTable (List <ClassFeature > features , JsonNode sourceNode , ClassFields field ) {
359360 List <String > headings = new ArrayList <>();
360361 List <String > spellCasting = new ArrayList <>();
362+ List <String > footnotes = new ArrayList <>();
361363
362364 Map <Integer , LevelProgression > levels = new HashMap <>();
363365 for (int i = 1 ; i < 21 ; i ++) {
@@ -375,7 +377,7 @@ List<String> buildProgressionTable(List<ClassFeature> features, JsonNode sourceN
375377 if (ClassFields .rows .existsIn (tableNode )) {
376378 // headings for other/middle columns
377379 for (JsonNode label : ClassFields .colLabels .iterateArrayFrom (tableNode )) {
378- headings .add (markdownLinkToHtml ( replaceText ( label ) ));
380+ headings .add (stripTableMarkdown ( label , footnotes ));
379381 }
380382
381383 // values for other/middle columns
@@ -403,12 +405,26 @@ List<String> buildProgressionTable(List<ClassFeature> features, JsonNode sourceN
403405 }
404406 }
405407
406- return progressionAsTable (headings , spellCasting , levels );
408+ return progressionAsTable (headings , spellCasting , levels , footnotes );
409+ }
410+
411+ private String stripTableMarkdown (JsonNode label , List <String > footnotes ) {
412+ String text = markdownLinkToHtml (replaceText (label ));
413+
414+ // Extract footnotes and replace with markers
415+ Matcher matcher = footnotePattern .matcher (text );
416+
417+ return matcher .replaceAll (matchResult -> {
418+ String footnoteContent = matchResult .group (1 );
419+ footnotes .add (footnoteContent );
420+ return " <sup>‡" + footnotes .size () + "</sup>" ;
421+ });
407422 }
408423
409424 List <String > progressionAsTable (List <String > headings ,
410425 List <String > spellCasting ,
411- Map <Integer , LevelProgression > levels ) {
426+ Map <Integer , LevelProgression > levels ,
427+ List <String > footnotes ) {
412428 List <String > text = new ArrayList <>();
413429 text .add ("[!tldr] Class and Feature Progression" );
414430 text .add ("" );
@@ -455,6 +471,13 @@ List<String> progressionAsTable(List<String> headings,
455471 }
456472
457473 text .add ("</tbody></table>" );
474+ if (!footnotes .isEmpty ()) {
475+ text .add ("<section class=\" footnotes\" ><ul>" );
476+ for (var i = 0 ; i < footnotes .size (); i ++) {
477+ text .add ("<li>‡" + (i + 1 ) + ": " + footnotes .get (i ) + "</li>" );
478+ }
479+ text .add ("</ul></section>" );
480+ }
458481
459482 // Move everything into a callout box
460483 text .replaceAll (s -> "> " + s );
0 commit comments