Skip to content

Code block with python,playground cause wrong playground behaviour #3215

Description

@dalance

Problem

This issue is a part of #3124.

Now code block with python,playground is not supported, so it is expected no-op.
But actually it causes some strange behaviours.

Steps

[output.html.playground]
editable = true
```python,playground
print("hello")
```

```rust
fn main() { println!("hello"); }
```
  • broken copy button is shown at the first python code block
  • play/copy button is not show at the second rust code block

I think the expected behaviour is the python code block is not playground (because python,playground is not supported) and the rust code block works fine.
If this issue is fixed, user can insert python,playground support by the way of #3124.

Possible Solution(s)

The necessary code change is probably like below:

const playgrounds = Array.from(document.querySelectorAll('.playground'));

-    const playgrounds = Array.from(document.querySelectorAll('.playground'));
+    const playgrounds = Array.from(document.querySelectorAll('pre.playground'));

Array.from(document.querySelectorAll('.playground')).forEach(function(pre_block) {

-    Array.from(document.querySelectorAll('.playground')).forEach(function(pre_block) {
+    Array.from(document.querySelectorAll('pre.playground')).forEach(function(pre_block) {

Notes

No response

Version

mdbook v0.5.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions