Skip to main content

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)
```

result

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)
```

result

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.
...

Metadata

Release files for mkdocs-onecompiler-plugin 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-onecompiler-plugin 0.1.0
File Size Uploaded Provenance Actions
mkdocs_onecompiler_plugin-0.1.0.tar.gz 4.4 kB Without provenance Details for mkdocs_onecompiler_plugin-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-onecompiler-plugin 0.1.0
File Interpreter ABI Platform Actions
mkdocs_onecompiler_plugin-0.1.0-py3-none-any.whl Python 3 none any Details for mkdocs_onecompiler_plugin-0.1.0-py3-none-any.whl

Total release size: 9.8 kB

Release files / mkdocs_onecompiler_plugin-0.1.0.tar.gz

Download URL mkdocs_onecompiler_plugin-0.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4ea0b2fc73b77cbaf0f27c62373e54e48dded2c83cf96ae8d87e4552666c9b83
BLAKE2b-256 checksum
How to use checksums
ec76f8a519af9b6ccbb38072c0374453258ab1442c4816fe65d8d51c6c43de07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.0 CPython/3.11.4 Linux/6.4.11-200.fc38.x86_64

Release files / mkdocs_onecompiler_plugin-0.1.0-py3-none-any.whl

Download URL mkdocs_onecompiler_plugin-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1a5cd12c8c4b4ce3c8da0ce86602fb55d9e952667065a84407a1205f11a37f3
BLAKE2b-256 checksum
How to use checksums
3356f1b931e1cdba7b00674b344cd0aa348107202e4e5af44d13dc5acea2b554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.0 CPython/3.11.4 Linux/6.4.11-200.fc38.x86_64

Security for mkdocs-onecompiler-plugin 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page