javascript WordPress的Prismjs
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript WordPress的Prismjs相关的知识,希望对你有一定的参考价值。
// Usage and detail: https://yuis-programming.com
$(document).ready(function(){
// console.log('yy') ;
for (i = 0; i < document.querySelectorAll('article code').length; i++) {
["ruby","php","markdown","autohotkey","bash","markup","css","javascript","java","kotlin","json","haskell",
"sass","scss","sql","batch","python","lua","apacheconf","git","vim","go","yaml","perl","csharp","erb"].forEach(function(value){
if ( document.querySelectorAll('article code')[i].classList.value ) {
if ( document.querySelectorAll('article code')[i].classList.value.split(/\s/).indexOf(value) > -1 ){
// console.log( `including ${value}`)
document.querySelectorAll('article code')[i].classList.replace( value ,`lang-${value}`)
document.querySelectorAll('article code')[i].classList.add('line-numbers') ;
}
} else {
document.querySelectorAll('article code')[i].classList.value = "language-markup" ;
document.querySelectorAll('article code')[i].classList.add('line-numbers') ;
}
})
}
Prism.highlightAll() ;
});
以上是关于javascript WordPress的Prismjs的主要内容,如果未能解决你的问题,请参考以下文章
wordpress - 错误 403 文件 javascript 插件 wordpress
带有 Javascript 的 Wordpress 插件
在 wordpress 主题中插入 javascript 背景
如何在 Wordpress 中实现 javascript
使用纯 Javascript 通过 AJAX 发送 WordPress 对象
WordPress JavaScript