Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/_static/css/pyscript_editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,38 @@ py-editor::part(editor) {
py-editor::part(run-button) {
border-radius: 0 0 4px 0;
}

/*
* Differentiate PyScript output from the yellow-green (#eeffcc) code blocks.
* Uses a light blue-gray background, vertical spacing, and an "Output:" label.
*/
.py-editor-output {
margin-top: 0.75em;
background: #f0f4f8;
font-size: 0.875em;
padding: 0.75em 1em;
border-radius: 0 0 4px 4px;
}

.py-editor-output::before {
content: "Output:";
display: block;
font-size: 0.75em;
font-weight: 600;
color: #6c757d;
margin-bottom: 0.35em;
font-family: sans-serif;
}

/* Cells with :target: render output into a separate div (e.g. plots),
* so suppress the "Output:" label and custom background on their
* default .py-editor-output area. */
.has-target .py-editor-output::before {
display: none;
}

.has-target .py-editor-output {
background: transparent;
padding: 0;
margin-top: 0;
}
6 changes: 5 additions & 1 deletion docs/pyscript_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,12 @@ def run(self) -> list[nodes.Node]:
# visually; clipboard.js reads textContent regardless of visibility.
escaped_code = html_mod.escape(code)

outer_classes = "highlight highlight-python notranslate"
if ed_target:
outer_classes += " has-target"

editor_html = (
'<div class="highlight highlight-python notranslate">\n'
f'<div class="{outer_classes}">\n'
'<div class="highlight">\n'
f'<pre id="{cell_id}" style="display:none">{escaped_code}</pre>\n'
f'<script type="py-editor" env="{ed_env}"{config_part}{" setup" if ed_setup else ""}>\n'
Expand Down
Loading