File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -925,11 +925,19 @@ export function jupyterCellWithOptions(
925
925
const validMetadata : Record < string , string | number | boolean > = { } ;
926
926
for ( const key of Object . keys ( cell . metadata ) ) {
927
927
const value = cell . metadata [ key ] ;
928
+ let jsonEncodedKeyIndex = 0 ;
928
929
if ( value !== undefined ) {
929
930
if ( value && typeof value === "object" ) {
931
+ // https://github.com/quarto-dev/quarto-cli/issues/9089
930
932
// we need to json-encode this and signal the encoding in the key
933
+ // we can't use the key as is since it may contain invalid characters
934
+ // and modifying the key might introduce collisions
935
+ // we ensure the key is unique with a counter, and assume
936
+ // "quarto-private-*" to be a private namespace for quarto.
937
+ // we'd prefer to use _quarto-* instead, but Pandoc doesn't allow keys to start
938
+ // with an underscore.
931
939
validMetadata [
932
- `quarto-json-encoded- ${ key . replaceAll ( / [ ^ A - Z a - z ] / g , "_" ) } `
940
+ `quarto-private- ${ ++ jsonEncodedKeyIndex } `
933
941
] = JSON . stringify ( { key, value } ) ;
934
942
} else if (
935
943
typeof value === "string" || typeof value === "number" ||
You can’t perform that action at this time.
0 commit comments