问题标签 [jdoodle]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
37 浏览

javascript - React: Iframe rendering new line character \n as a single space

I am working on an application using Node.js, Express, React & Redux that enables users to write code into a text-editor, when the user hits 'run' to submit their code the code is then compiled using the JDoodle API.

As part of the JSON response returned from JDoodle I get the compiled output, so for instance:

would return:

The issue I am having is that I am rendering this output in an Iframe within a React component, and when I do so it is rendering the new line character \n as a single space. So for instance the above code would produce the following in the Iframe:

I have tried giving the Iframe a className of iFrame and then in CSS doing the following:

but no success! I also seen a few others mention escaping the backslash so replacing \n for \n:

but I cannot seem to get this working as every time I use the backslash character in quotes Javascript thinks I'm escaping the previous character.

I also tried

but having the same issue as above.

Any help would be much appreciated, thank you!

EDIT: I had read Override body style for content in an iframe which this question was marked as a duplicate for but it does not address my issue in any way. I have now resolved my problem and if the question could be reopened I can hopefully post the solution which may in turn help others facing the same issue. Thank you!

0 投票
1 回答
16 浏览

html - 我正在尝试“剪切” iframe 元素的一部分

我使用 HTML iframe 元素在我的网站中放置了一个在线编译器网站。基本上,我希望用户直接在我的网站上编译和编写代码,而无需使用在线编译器打开单独的选项卡。

现在,我想知道是否有一个选项可以“剪切”我网站内的 iframe 元素显示的网站的一部分。以某种方式限制用户只看到我希望他看到的那个网站的一部分。

我想提一下,我不想使用任何其他方法,只是 iframe 元素。谢谢 :)

0 投票
0 回答
29 浏览

python - 如何从 Python/Flask 应用程序调用 JDoodle API

我是一名学生,我正在寻求调用 Jdoodle 的编译器 API(此处为文档)的帮助。

当我通过 Postman 发出发布请求并将其用作 JSON 正文时,它可以工作......

...我得到了我期望的输出:

但是,我不能让它从我的 Python Flask 后端工作。这是我的代码:

我也通过传入标题(headers = {“Content-Type”:“application / json”})尝试了这个,我仍然从邮递员那里得到相同的响应:

我是新手,任何帮助将不胜感激。谢谢!