nalgeon/codapi-js

All newlines were stripped in run only mode

Closed this issue · 11 comments

I've this problem when running python code in Docusaurus 3.3.2:

def greet(name):
  print(f"Hello, {name}!")

greet("World")
<codapi-snippet sandbox="python" init-delay="500">
</codapi-snippet>

And get this error:
image

I've also seen this issue #22, @srenatus mentioned that all newlines are stripped in running only mode (without edit mode)

image

It should be great if this issue can be fixed. Thank you

Can you put together an example on codesandbox, or share the concrete HTML you get for that snippet? I think we'll need that to assess what's happening here.

@srenatus sure, here is the codesandbox URL https://codesandbox.io/p/devbox/peaceful-firefly-3sf4zz?workspaceId=273fe185-9274-4f80-b5dd-33b5233a4574. Then go to docs/intro or intro.md file.

I just pasted the snippet code to reproduce the issue:

```python
def greet(name):
  print(f"Hello, {name}!")

greet("World")
```

<!-- Not working -->
<codapi-snippet sandbox="python" init-delay="500">
</codapi-snippet>

<!-- Working well -->
<!-- <codapi-snippet sandbox="python" editor="basic" init-delay="500">
</codapi-snippet> -->

#22 was fixed. What is your Codapi widget version?

@nalgeon I'm using codapi widget 0.19.6. #22 only fixed when widget using edit mode, if widget disabled edit mode then it's not working

FWIW this is the HTML I had been wondering about -- taken a screenshot from your code sandbox:
image

Yes, I understand, thank you. Will take a look at it when I have time.

Great, thanks @nalgeon

@srenatus do you mean whitespace inside HTML ?

@tonidy I suspect I'm just muddying the water here. I had thought that knowing the HTML that docusaurus gives you for your code snippet would help @nalgeon with debugging what's going on here. Let's see! 🤞

No worries, @srenatus. Even if it feels like you're muddying the water, your suggestion about checking the HTML output from Docusaurus might be valuable to @nalgeon 💪 .

Fixed in 0.19.7.

@nalgeon awesome, it's working now. Thanks for fixing it!