반응형
display_html 함수가 Jupyter Lab에서 작동하지 않습니다
이 "R 코드"는 주피터에서는 잘 작동하지만 실험실에서는 잘 작동하지 않는다:
library(IRdisplay)
display_html(
'
<script>
code_show=true;
function code_toggle() {
if (code_show){
$(\'div.input\').hide();
} else {
$(\'div.input\').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()">
<input type="submit" value="Code On/Off">
</form>
<style type="text/css">
.container { width:80% !important; }
.main-container {
max-width: 2000px;
margin-left: 100px;
margin-right: 10px;
}
/*body{font-family: Lucida Sans Unicode} */
.nav>li>a {
position: relative;
display: block;
padding: 10px 15px;
color: #004F59;
}
.nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus {
color: #ffffff;
background-color: #004F59;
}
.list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover {
background-color: #004F59;
}
</style>
'
)
나는 또한 다른 맥락에서 display_html을 사용하려고 했다. 이것이 실험실에서 작동하지 않는 이유가 있나요? 쉽게 고칠 수 있나요? 감사해요.
주피터랩에서 잘 작동하고, 당신의 기능에 대한 콜백도 잘 작동합니다. 노트북 v6와 주피터랩의 유일한 차이점은 다음과 같다:
- jQuery는 주피터랩에서 기본적으로 사용할 수 없기 때문에(2020년대에는 더 이상 필요하지 않기 때문에), 에 의한 선택은 작동하지 않을 것이다 - 대신 표준을 사용한다
- CSS 클래스는 서로 다르기 때문에 스타일을 조정해야 한다; 무엇을 달성하고 싶었는지 명확하지 않지만 입력 영역을 숨기는 경우 주피터랩에서 표준 JS로 동일한 효과를 얻을 수 있다:
IRdisplay::display_html('
<script type="text/javascript">
let code_show = true;
function code_toggle() {
if (code_show) {
document.querySelectorAll(".jp-Cell-inputArea").forEach(function(inputArea) {
inputArea.style.display = "none";
});
} else {
document.querySelectorAll(".jp-Cell-inputArea").forEach(function(inputArea) {
inputArea.style.display = "";
});
}
code_show = !code_show;
}
</script>
<form action="javascript:code_toggle()">
<input type="submit" value="Code On/Off">
</form>
')
이것은 특정 셀이 아니라 전체 문서에 있는 모든 코드를 숨기는 것처럼 보이나요?
반응형
'개발하자' 카테고리의 다른 글
VS 코드 주피터: 파이썬 대화형 창을 기본 콘솔로 작동시킬 수 있는 방법이 있나요? (0) | 2023.07.16 |
---|---|
FastAPI 엔드포인트 내의 동적 URL로 리디렉션하는 방법은 무엇입니까? (0) | 2023.07.16 |
"terraform apply"에서 도커 서버 ping 오류 발생 (0) | 2023.07.15 |
VScode가 주피터 노트북을 HTML로 내보내지 못함 - 'jupitter-nbconvert'를 찾을 수 없음 (0) | 2023.07.14 |
TypeScript 게터를 메모하는 방법 (0) | 2023.07.13 |