본문, 댓글에 syntax highlight 넣기 : 스마트에디터2 도 가능함
페이지 정보
본문
syntax highlight
[code]
<link rel=stylesheet href=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/a11y-dark.min.css>
<script src=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js></script>
<style>
pre { position:relative; -ms-overflow-style:none; }
pre::-webkit-scrollbar { display:none; }
.copyButton { position:absolute; cursor:pointer; top:10px; right:10px; }
</style>
<script>
copyImage = "http://www.mediaplayer.kr/main/wittazzurri/code/copy_hand.png";
copyMp3 = "http://www.mediaplayer.kr/main/wittazzurri/code/copy_sound.mp3";
document.write("<div class=cmt_contents style=display:none></div>");
commentZone = document.getElementsByClassName("cmt_contents");
cmtLimit = commentZone.length;
for (cmt = 0; cmt < cmtLimit; cmt++) commentZone[cmt].id = "cmt_num_" + (Number(cmt) + 1);
editorName = "<?php echo $board['bo_use_dhtml_editor'] ? $config['cf_editor'] : "none"; ?>";
function codeCopy() {
copyText.style.display = "block";
copyText.value = arguments[0].innerText.trim();
copyText.select();
document.execCommand("copy");
copyText.style.display = "none";
copySound.play();
alert("COPY CODE!!!");
}
function hlMode() {
this[arguments[0]].innerHTML = this[arguments[0]].innerHTML.replace(/\[code\]/gi, "<div name=code_" + arguments[0] + ">").replace(/\[\/code\]/gi, "</div>");
nameN = document.getElementsByName("code_" + arguments[0]);
for (n = 0; n < nameN.length; n++) {
if (arguments[0] == "bo_v_con") {
if (editorName == "smarteditor2") changeCode = (nameN[n].innerHTML.replace(/\<p\>/gi, "").replace(/\<\/p\>/gi, "<br>") + "<br>").replace(/\<br\>\<br\>/gi, "<br>");
else if (editorName == "cheditor5") changeCode = nameN[n].innerHTML.replace(/<(\/p|p)([^>]*)>/gi, "") + "<br>";
else if (editorName == "none") changeCode = nameN[n].innerHTML.replace(/\<br\>\<br\>/gi, "*br*").replace(/\<br\>/gi, "").replace(/\*br\*/gi, "<br>") + "<br>";
}
else changeCode = nameN[n].innerHTML.replace(/\<br\>\<br\>/gi, "*br*").replace(/\<br\>/gi, "").replace(/\*br\*/gi, "<br>") + "<br>";
nameN[n].innerHTML = "<pre><code>" + changeCode + "<img class=copyButton src=" + copyImage + " onclick=codeCopy(parentElement)></code></pre>";
}
}
hlGroup = ["bo_v_con"];
for (cmtPlus = 0; cmtPlus < cmtLimit; cmtPlus++) hlGroup.push(commentZone[cmtPlus].id);
for (hl in hlGroup) hlMode(hlGroup[hl]);
hljs.initHighlighting();
document.write("<textarea id=copyText style=display:none></textarea>");
document.write("<audio id=copySound src=" + copyMp3 + " ></audio>");
codeZone = document.getElementsByTagName("code");
for (cz = 0; cz < codeZone.length; cz++) {
codeZone[cz].style.fontSize = "1rem";
codeZone[cz].style.fontFamily = "times";
codeZone[cz].style.padding = "20px";
codeZone[cz].style.borderRadius = "15px";
codeZone[cz].style.backgroundColor = "#000000";
}
</script>
[/code]
[code]
<wittazzurri>코드블럭의 연속넣기도 가능합니다</wittazzurri>
[/code]
- 다음글본문, 댓글에 mp3, mp4, 유튜브 넣기 21.11.26
댓글목록
비타주리님의 댓글
비타주리 작성일
------
사용법 : https://sir.kr/g5_plugin/9655
------
[code]<wittazzurri>댓글에서도 코드블럭의 연속넣기가 가능합니다</wittazzurri>[/code]
https://youtu.be/EIzXAMjaJ98
[code]<link rel=stylesheet href=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/a11y-dark.min.css>
<script src=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js></script>
<style>
pre { position:relative; -ms-overflow-style:none; }
pre::-webkit-scrollbar { display:none; }
.copyButton { position:absolute; cursor:pointer; top:10px; right:10px; }
</style>
<script>
copyImage = "http://www.mediaplayer.kr/main/wittazzurri/code/copy_hand.png";
copyMp3 = "http://www.mediaplayer.kr/main/wittazzurri/code/copy_sound.mp3";
//document.write("<div class=cmt_contents style=display:none></div>");
//commentZone = document.getElementsByClassName("cmt_contents");
//cmtLimit = commentZone.length;
//for (cmt = 0; cmt < cmtLimit; cmt++) commentZone[cmt].id = "cmt_num_" + (Number(cmt) + 1);
editorName = "<?php echo $board['bo_use_dhtml_editor'] ? $config['cf_editor'] : "none"; ?>";
function codeCopy() {
copyText.style.display = "block";
copyText.value = arguments[0].innerText.trim();
copyText.select();
document.execCommand("copy");
copyText.style.display = "none";
copySound.play();
alert("COPY CODE!!!");
}
function hlMode() {
this[arguments[0]].innerHTML = this[arguments[0]].innerHTML.replace(/\[code\]/gi, "<div name=code_" + arguments[0] + ">").replace(/\[\/code\]/gi, "</div>");
nameN = document.getElementsByName("code_" + arguments[0]);
for (n = 0; n < nameN.length; n++) {
if (arguments[0] == "bo_v_con") {
if (editorName == "smarteditor2") changeCode = (nameN[n].innerHTML.replace(/\<p\>/gi, "").replace(/\<\/p\>/gi, "<br>") + "<br>").replace(/\<br\>\<br\>/gi, "<br>");
else if (editorName == "cheditor5") changeCode = nameN[n].innerHTML.replace(/<(\/p|p)([^>]*)>/gi, "") + "<br>";
else if (editorName == "none") changeCode = nameN[n].innerHTML.replace(/\<br\>\<br\>/gi, "*br*").replace(/\<br\>/gi, "").replace(/\*br\*/gi, "<br>") + "<br>";
}
else changeCode = nameN[n].innerHTML.replace(/\<br\>\<br\>/gi, "*br*").replace(/\<br\>/gi, "").replace(/\*br\*/gi, "<br>") + "<br>";
nameN[n].innerHTML = "<pre><code>" + changeCode + "<img class=copyButton src=" + copyImage + " onclick=codeCopy(parentElement)></code></pre>";
}
}
hlGroup = ["bo_v_con"];
for (cmtPlus = 0; cmtPlus < cmtLimit; cmtPlus++) hlGroup.push(commentZone[cmtPlus].id);
for (hl in hlGroup) hlMode(hlGroup[hl]);
hljs.initHighlighting();
document.write("<textarea id=copyText style=display:none></textarea>");
document.write("<audio id=copySound src=" + copyMp3 + " ></audio>");
codeZone = document.getElementsByTagName("code");
for (cz = 0; cz < codeZone.length; cz++) {
codeZone[cz].style.fontSize = "1rem";
codeZone[cz].style.fontFamily = "times";
codeZone[cz].style.padding = "20px";
codeZone[cz].style.borderRadius = "15px";
codeZone[cz].style.backgroundColor = "#000000";
}
</script>[/code]
비타주리님의 댓글
비타주리 작성일
[code]
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false'>
[/code]