File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -925,11 +925,19 @@ export function jupyterCellWithOptions(
925925 const validMetadata : Record < string , string | number | boolean > = { } ;
926926 for ( const key of Object . keys ( cell . metadata ) ) {
927927 const value = cell . metadata [ key ] ;
928+ let jsonEncodedKeyIndex = 0 ;
928929 if ( value !== undefined ) {
929930 if ( value && typeof value === "object" ) {
931+ // https://github.com/quarto-dev/quarto-cli/issues/9089
930932 // 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.
931939 validMetadata [
932- `quarto-json-encoded- ${ key . replaceAll ( / [ ^ A - Z a - z ] / g , "_" ) } `
940+ `quarto-private- ${ ++ jsonEncodedKeyIndex } `
933941 ] = JSON . stringify ( { key, value } ) ;
934942 } else if (
935943 typeof value === "string" || typeof value === "number" ||
You can’t perform that action at this time.
0 commit comments