diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index de410f3e1d..cb3f0f0305 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -10,6 +10,7 @@ All changes included in 1.7: - ([#11659](https://github.com/quarto-dev/quarto-cli/pull/11659)): `julia` engine - Fix escaping bug where paths containing spaces or backslashes break server startup on Windows. - ([#11752](https://github.com/quarto-dev/quarto-cli/issues/11752)): Fix regression with non-alphanumeric characters in `categories` preventing correct filtering of listing. - ([#11943](https://github.com/quarto-dev/quarto-cli/issues/11943)): Fix callout title color on dark theme in revealjs following Revealjs update in quarto 1.6. +- ([#11990](https://github.com/quarto-dev/quarto-cli/issues/11990)): Do not print parameter cell in parameterized Jupyter notebooks. - ([#12147](https://github.com/quarto-dev/quarto-cli/issues/12147)): for RevealJS format, `serif` and `simple` themes defaults back to have their heading color (`$presentation-heading-color`) to be the same as the body color (`$body-color`) as in Quarto 1.5. ## Dependencies diff --git a/src/resources/jupyter/notebook.py b/src/resources/jupyter/notebook.py index 70d9c8ff69..dabc96bbbf 100644 --- a/src/resources/jupyter/notebook.py +++ b/src/resources/jupyter/notebook.py @@ -686,9 +686,11 @@ def nb_parameterize(nb, params): # and then re-encode it try: params_cell_yaml = parse_string("\n".join(params_cell_yaml)) - del params_cell_yaml['label'] + if "label" in params_cell_yaml: + del params_cell_yaml['label'] params_cell_yaml = safe_dump(params_cell_yaml).strip().splitlines() except Exception as e: + sys.stderr.write(str(e) + "\naksjdfhakjsdhf\n") sys.stderr.write("\nWARNING: Invalid YAML option format in cell:\n" + "\n".join(params_cell_yaml) + "\n") sys.stderr.flush() params_cell_yaml = [] diff --git a/tests/docs/jupyter/parameters/issue-11990.qmd b/tests/docs/jupyter/parameters/issue-11990.qmd new file mode 100644 index 0000000000..0b04d4368d --- /dev/null +++ b/tests/docs/jupyter/parameters/issue-11990.qmd @@ -0,0 +1,18 @@ +--- +title: "Quarto Parameters" +format: html +engine: jupyter +keep-md: true +keep-ipynb: true +--- + +```{python} +#| tags: [parameters] +#| include: false +username = None +password = None +``` + +```{python} +print(f"Hello, {username}!") +``` \ No newline at end of file diff --git a/tests/smoke/jupyter/issue-11990.test.ts b/tests/smoke/jupyter/issue-11990.test.ts new file mode 100644 index 0000000000..75c8dfda62 --- /dev/null +++ b/tests/smoke/jupyter/issue-11990.test.ts @@ -0,0 +1,23 @@ +/* + * issue-11990.test.ts + * + * https://github.com/quarto-dev/quarto-cli/issues/11990 + * + * Copyright (C) 2025 Posit Software, PBC + */ + +import { join } from "../../../src/deno_ral/path.ts"; +import { docs, outputForInput } from "../../utils.ts"; +import { noErrorsOrWarnings, ensureFileRegexMatches } from "../../verify.ts"; +import { testRender } from "../render/render.ts"; + +const format = "html"; +const input = docs(join("jupyter", "parameters", "issue-11990.qmd")); +const output = outputForInput(input, format); + +testRender(input, format, false, [ + noErrorsOrWarnings, + ensureFileRegexMatches(output.outputPath, [], [ + "Injected Parameters" + ]), +], {}, ["--no-execute-daemon", "--execute-param", "username:John"]);