Closed kylekyle closed 3 years ago
Not sure if this is related, but the SUPPORTED_MIMES
includes application/javascript
, while the registered renderer produces text/javascript
.
I have a same problem.
a = IRuby.input 'a'
Javascript error adding output!
SyntaxError: Unexpected end of input
See your browser Javascript console for more details.
Windows 10 Python 3.8.2 (installed with pyenv) jupyter core 4.7.0 jupyter-notebook 6.2.0 (installed with pip) ruby 3.0.1p64 (installed with Scoop) irb 1.3.5
Hi @kylekyle and @azriel1rf
Thank you for your report. I confirmed that the bug was reproduced. As kylekyle pointed out, the javascript characters are converted into Base64 encoded forms.
IRuby::Display.display("a=0;", mime: "application/javascript")
# actual: {"text/plain"=>"\"a=0;\"", "application/javascript"=>"YT0wOw=="}
# expected: {"text/plain"=>"\"a=0;\"", "application/javascript"=>"a=0;"}
This behavior is caused by the recent replacement of mimemagic with mimetype. https://github.com/SciRuby/iruby/commit/230b9162cadb7e93659772624e85cb1fd9ca338e
mimemagic's text?
methods and mimetype's ascii?
method seems to work differently.
# irb -r mimemagic
MimeMagic.new("application/javascript").text?
# => true
# irb -r mime/types
MIME::Type.new("application/javascript").ascii?
# => false
This difference causes the protect method to fail.
What should we do, @mrkn ?
If anyone can make a pull request to fix this problem, please send it to us. I'll merge.
Thanks @mrkn. I checked (#294). A pop-up window appears.
@kylekyle is the author of IRuby Input. IRuby Input has not been updated recently. If you want to continue maintaining IRuby Input, you might want to join the iruby-developers. Having the right to commit if necessary can help you stay motivated.
@azriel1rf The input fields are now working. If you find any problems, please report the issue again.
@kylekyle Feel free to send us a Pull Request to improve IRuby Input, and we'll merge it. If you need to make a lot of changes to IRuby Input and you think you need commit rights, please let us know.
Thanks.
It looks like javascript output is base64 encoded:
Which produces the following error:
Seems to be related to the
Display#protect
method.