Include OneCompiler online compiler to your mkdocs website
Project description
mkdocs-onecompiler-plugin
Include OneCompiler online compiler to your mkdocs website.
Requirements
Works only with mkdocs-material
as it ships a pymdownx custom fence.
Installation
pip install mkdocs-onecompiler-plugin
Configuration
Here is a minimal configuration to use the onecompiler fence
# mkdocs.yml
theme:
name: material
markdown_extensions:
- attr_list
- pymdownx.superfences:
custom_fences:
- name: onecompiler
class: onecompiler
format: !!python/name:mkdocs_onecompiler_plugin.formatter
Usage
The bare minimum is to provide the language.
```{.onecompiler lang="python"}
a = 3
b = 5
c = a + b
print(c)
```
Then we can use all the OneCompiler API to tweak the iframe.
```{.onecompiler lang="python" listenToEvents=true filename="example.py" hideNew=true hideStdin=true hideNewFileOption=true hideTitle=true theme="dark" height="200px"}
a = 3
b = 5
c = a + b
print(c)
```
Debug
We can access formatter parameters when debug=true
is passed to the attributes.
```{.onecompiler .test #wtfid lang="python" listenToEvents=true filename="example.py" hideNew=true hideStdin=true hideNewFileOption=true hideTitle=true theme="dark" debug=true}
a = 3
b = 5
c = a + b
print(c)
```
You must run mkdocs
with the verbose flag -v
to print debug messages.
...
INFO - Building documentation...
DEBUG - Running 1 `config` events
INFO - Cleaning site directory
DEBUG - Reading markdown pages.
DEBUG - Reading: index.md
DEBUG - mkdocs_onecompiler_plugin: source: a = 3
b = 5
c = a + b
print(c)
DEBUG - mkdocs_onecompiler_plugin: language: onecompiler
DEBUG - mkdocs_onecompiler_plugin: css_class: onecompiler
DEBUG - mkdocs_onecompiler_plugin: options: {}
DEBUG - mkdocs_onecompiler_plugin: md: <markdown.core.Markdown object at
0x7f5f917bb6d0>
DEBUG - mkdocs_onecompiler_plugin: attrs: {'lang': 'python', 'listenToEvents': 'true',
'filename': 'example.py', 'hideNew': 'true', 'hideStdin': 'true',
'hideNewFileOption': 'true', 'hideTitle': 'true', 'theme': 'dark', 'height':
'200px'}
DEBUG - mkdocs_onecompiler_plugin: classes: ['test']
DEBUG - mkdocs_onecompiler_plugin: id_value: wtfid2
DEBUG - mkdocs_onecompiler_plugin: kwargs: {}
DEBUG - mkdocs_onecompiler_plugin: debug: True
DEBUG - mkdocs_onecompiler_plugin:
<iframe id="wtfid2" referrerpolicy="no-referrer" name="wtfid2"
class="onecompiler test"
src="https://onecompiler.com/embed/python?availableLanguages=true&hideLanguageSelection=false&hideNew=true&hideNewFileOption=true&disableCopyPaste=false&hideStdin=true&hideResult=false&hideTitle=true&listenToEvents=true&theme=dark"
height="200px" width="100%" onload='this.contentWindow.postMessage({
eventType: "populateCode",
language: "python",
files: [
{
"name": "example.py",
"content": String.raw`a = 3
b = 5
c = a + b
print(c)`
}
]
}, "*");'>
</iframe>
DEBUG - Copying static assets.
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_onecompiler_plugin-0.1.0.tar.gz
.
File metadata
- Download URL: mkdocs_onecompiler_plugin-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.0 CPython/3.11.4 Linux/6.4.11-200.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ea0b2fc73b77cbaf0f27c62373e54e48dded2c83cf96ae8d87e4552666c9b83 |
|
MD5 | 6c14a43bcee1f6d4ffe1c9270865c808 |
|
BLAKE2b-256 | ec76f8a519af9b6ccbb38072c0374453258ab1442c4816fe65d8d51c6c43de07 |
File details
Details for the file mkdocs_onecompiler_plugin-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_onecompiler_plugin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.0 CPython/3.11.4 Linux/6.4.11-200.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a5cd12c8c4b4ce3c8da0ce86602fb55d9e952667065a84407a1205f11a37f3 |
|
MD5 | b43a0cfb5b56bb365b820953f9bc352d |
|
BLAKE2b-256 | 3356f1b931e1cdba7b00674b344cd0aa348107202e4e5af44d13dc5acea2b554 |