diff --git a/source/_posts/php.md b/source/_posts/php.md index a135035..6a8c890 100644 --- a/source/_posts/php.md +++ b/source/_posts/php.md @@ -10,6 +10,7 @@ intro: | This [PHP](https://www.php.net/manual/en/) cheat sheet provides a reference for quickly looking up the correct syntax for the code you use most frequently. plugins: - copyCode + - runCode --- ## Getting Started diff --git a/themes/coo/layout/_partial/scripts.ejs b/themes/coo/layout/_partial/scripts.ejs index 31a7f8c..59c627f 100644 --- a/themes/coo/layout/_partial/scripts.ejs +++ b/themes/coo/layout/_partial/scripts.ejs @@ -81,7 +81,7 @@ const code_Blocks = document.querySelectorAll('pre > code'); const runInnerHTML = ''; code_Blocks.forEach(function (codeBlock) { - let content = codeBlock.textContent; + let content = codeBlock.textContent || ''; let language = [...codeBlock.classList].filter(c => c.startsWith("language-"))[0].replace("language-", ""); if (language === 'shell') return; @@ -102,7 +102,7 @@ language = 'typescript'; } - const editorId = ['javascript', 'typescript', 'python'].includes(language) + const editorId = ['javascript', 'typescript', 'python', 'php'].includes(language) ? 'script' : ['css', 'scss'].includes(language) ? 'style' @@ -185,6 +185,23 @@ } } + if (['php'].includes(language)) { + config = { + ...baseConfig, + style: { + language: 'css', + content: 'body { white-space: pre-wrap; }\n', + }, + script: { + language: 'php-wasm', + content: !content.trim().startsWith('` : content, + }, + tools: { + status: 'closed', + } + } + } + const plaugroundUrl = livecodes.getPlaygroundUrl({config}); window.open(plaugroundUrl, '_blank'); });