mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
feat: add support for running php
This commit is contained in:
1 parent
9e2a20c369
commit
9609a67b1d
2 files changed
+20
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
const code_Blocks = document.querySelectorAll('pre > code');
|
||||
const runInnerHTML = '<svg height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M16.6582 9.28638C18.098 10.1862 18.8178 10.6361 19.0647 11.2122C19.2803 11.7152 19.2803 12.2847 19.0647 12.7878C18.8178 13.3638 18.098 13.8137 16.6582 14.7136L9.896 18.94C8.29805 19.9387 7.49907 20.4381 6.83973 20.385C6.26501 20.3388 5.73818 20.0469 5.3944 19.584C5 19.053 5 18.1108 5 16.2264V7.77357C5 5.88919 5 4.94701 5.3944 4.41598C5.73818 3.9531 6.26501 3.66111 6.83973 3.6149C7.49907 3.5619 8.29805 4.06126 9.896 5.05998L16.6582 9.28638Z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></g></svg>';
|
||||
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('<?php') ? `<?php\n\n${content.trim()}\n\n?>` : content,
|
||||
},
|
||||
tools: {
|
||||
status: 'closed',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const plaugroundUrl = livecodes.getPlaygroundUrl({config});
|
||||
window.open(plaugroundUrl, '_blank');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user