Cool, I did it.
<!DOCTYPE html>
<html>
<style>
.tk { border-collapse: collapse; }
.tk th, td { border: 1px solid #ddd; padding: 6px }
.tk th { width: 56px; background-color: #f7f7f7; font-size: 24px; font-weight: normal; }
.tk td { width: 240px; text-align: left; font-size: 16px; }
</style>
<body onload="kanjiFormat()">
<p id="jisho">#長#long, leader#ながい、おさ#チョウ#</p>
<script>
var codeKstart = '<table align="center" class="tk"><tr><th rowspan="2">'
var codeMstart = '</th><td>'
var codeRstart = '</td></tr><tr><td>'
var codeComma = '、'
var codeRend = '</td></tr></table>'
function kanjiFormat() {
var str = document.getElementById("jisho").innerHTML;
var txt = str.replace(/#/, codeKstart).replace(/#/, codeMstart).replace(/#/, codeRstart).replace(/#/, codeComma).replace(/#/, codeRend);
document.getElementById("jisho").innerHTML = txt;
}
</script>
</body>
</html>
Now:
- How do I make the search for forward slashes (/)? I replaced them with # for the sake of testing. Nevermind, it will try to replace the forward slashes from html as well. Gotta replace them with another symbol when I paste it.
- Also, sometimes there one less category (e.g. /電/electricity/デン), in that case I wouldn't need the comma var. Where do I put an if in this function?