1313 */
1414
1515'use strict' ;
16+ /**
17+ * Converts a markdown node to an HTML string.
18+ *
19+ * @param {Object } thing - Markdown AST node
20+ * @returns {string } HTML representation
21+ */
22+ function renderVariableValue ( thing ) {
23+ // Handle relationship types (e.g. Party)
24+ if (
25+ thing . elementType &&
26+ thing . elementType . startsWith ( 'org.accordproject.party@' ) &&
27+ typeof thing . value === 'string'
28+ ) {
29+ // Remove quotes if present
30+ const unquoted = thing . value . replace ( / ^ " ( .* ) " $ / , '$1' ) ;
31+
32+ // Extract identifier after #
33+ const parts = unquoted . split ( '#' ) ;
34+ return parts . length > 1 ? parts [ 1 ] : unquoted ;
35+ }
36+
37+ // Default behavior
38+ return thing . value ;
39+ }
1640
1741// const CiceroMarkTransformer = require('@accordproject/markdown-cicero').CiceroMarkTransformer;
1842
@@ -81,7 +105,8 @@ class ToHtmlStringVisitor {
81105 if ( thing . identifiedBy ) {
82106 attributes += ` identifiedBy="${ thing . identifiedBy } "` ;
83107 }
84- parameters . result += `<span ${ attributes } >${ thing . value } </span>` ;
108+ parameters . result += `<span ${ attributes } >${ renderVariableValue ( thing ) } </span>` ;
109+
85110 }
86111 break ;
87112 case 'FormattedVariable' : {
@@ -92,7 +117,8 @@ class ToHtmlStringVisitor {
92117 if ( thing . identifiedBy ) {
93118 attributes += ` identifiedBy="${ thing . identifiedBy } "` ;
94119 }
95- parameters . result += `<span ${ attributes } >${ thing . value } </span>` ;
120+ parameters . result += `<span ${ attributes } >${ renderVariableValue ( thing ) } </span>` ;
121+
96122 }
97123 break ;
98124 case 'EnumVariable' : {
@@ -104,7 +130,8 @@ class ToHtmlStringVisitor {
104130 if ( thing . identifiedBy ) {
105131 attributes += ` identifiedBy="${ thing . identifiedBy } "` ;
106132 }
107- parameters . result += `<span ${ attributes } >${ thing . value } </span>` ;
133+ parameters . result += `<span ${ attributes } >${ renderVariableValue ( thing ) } </span>` ;
134+
108135 }
109136 break ;
110137 case 'Conditional' :
0 commit comments