File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1313from pathlib import Path
1414
1515from yaml import safe_load as parse_string
16+ from yaml import safe_dump
1617
1718from log import trace
1819import nbformat
@@ -641,6 +642,20 @@ def nb_parameterize(nb, params):
641642
642643 # prepend options
643644 if len (params_cell_yaml ):
645+ # https://github.com/quarto-dev/quarto-cli/issues/10097
646+ # We need to find and drop `label: ` from the yaml options
647+ # to avoid label duplication
648+ # The only way to do this robustly is to parse the yaml
649+ # and then re-encode it
650+ try :
651+ params_cell_yaml = parse_string ("\n " .join (params_cell_yaml ))
652+ del params_cell_yaml ['label' ]
653+ params_cell_yaml = safe_dump (params_cell_yaml ).strip ().splitlines ()
654+ except Exception as e :
655+ sys .stderr .write ("\n WARNING: Invalid YAML option format in cell:\n " + "\n " .join (params_cell_yaml ) + "\n " )
656+ sys .stderr .flush ()
657+ params_cell_yaml = []
658+
644659 comment_chars = nb_language_comment_chars (language )
645660 option_prefix = comment_chars [0 ] + "| "
646661 option_suffix = comment_chars [1 ] if len (comment_chars ) > 1 else None
You can’t perform that action at this time.
0 commit comments