Skip to main content

Rocher

Rocher is a Python package for the Monaco code editor. The Monaco Editor is the code editor that powers Visual Studio Code. It provides a prebuilt version of the editor as a Python package, allowing you to embed it into any Python application as a standard Python package.

Screenshot

Installation

pip install rocher

Usage

See the samples/ folder for more examples to use it with multiple frameworks.

Path

The package provides only a function path():

import rocher

rocher.path()

This is the path where the Monaco editor is installed. You can serve after this path with your favorite Python web framework as a static folder.

Editor HTML

The package provides a editor_html():

import rocher

rocher.editor_html(
    "/static/vs",
    "container",
    "python",
    "print('Hello World!')",
)

This function will return a HTML string that you can embed in your web page. The first parameter is the path where the Monaco editor is exposed. The second parameter is the id of the HTML element where the editor will be embedded. The third parameter is the language of the editor. The fourth parameter is the initial content of the editor.

Colorizer

The package also a simple syntax highlighter:

import rocher

rocher.colorize_html("container")

This function will return a HTML string that you can embed in your web page. The first parameter is the id of the HTML element where the content will be highlighted.

Flask

The package provide an helper for Flask + Jinja2:

First you need to register the editor

```python
from flask import Flask
import rocher.flask

app = Flask(__name__)

rocher.editor_register(app)

Then you can use the editor in your template:

<div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
{{
    rocher_editor(
        "container",
        "python",
        source_code,
        readOnly=true,
        theme="vs-dark",
        lineHeight=20
    )
}}

All supported options are listed here: https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html

Or the colorizer:

{{ rocher_colorize("code", initialize=False) }}

<h2>Python</h2>
<pre id="code" data-lang="python" style="width: 500px">
print("Hello World!")
</pre>

Why the name Rocher?

Le Rocher is the hill where the Principality of Monaco is built.

Versioning

Following semantic versioning convention the major and version number of this package is the version of the Monaco Editor. The patch number is use to release a version of this package independent of the Monaco Editor version.

Update the Monaco Editor

Edit update_editor.sh and change the version number. Then run the script. It will download the new version of the Monaco editor and update the package.

And run:

hatch build -t sdist 

To build the packaged version.

Automated builds

An automated build runs every Friday to check for updates. If a new version of the Monaco Editor has been published on NPM, a new release will be created automatically.

I can't find the Monaco Editor source code in the repository

The Monaco Editor is not part of this repository. It is downloaded from the official repository during the build process. See the update_editor.sh script.

Projects using this package

  • [https://github.com/julien-duponchelle/colvert](Colvert a DuckDB UI)
  • [https://github.com/assembliss/webassembliss](webassembliss: WebApp that emulates different versions of assembly)

License

Licensed under the MIT License, see LICENSE for more information.

Credits

All credit goes to the Monaco Editor team. This package is just a wrapper around their work.

Metadata

Release files for rocher 0.55.1

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

Source distribution (sdist)

Source distribution for rocher 0.55.1
File Size Uploaded
rocher-0.55.1.tar.gz 3.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for rocher 0.55.1
File Interpreter ABI Platform
rocher-0.55.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 MB

Release files / rocher-0.55.1.tar.gz

Download URL rocher-0.55.1.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
319557b5915cb4e530d4550d6716216505e34e36afbd6dc461a5aab52aa2fa96
BLAKE2b-256 checksum
How to use checksums
0edda31e2b03141e822e1552790bc4b7ce92326e9b08b49e53533e7848b17981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.

Transparency log

Release files / rocher-0.55.1-py3-none-any.whl

Download URL rocher-0.55.1-py3-none-any.whl
Size 3.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
880c0068dadb82904515b21759c15d2aedb06f8ef15f0aec5cb451cbad887036
BLAKE2b-256 checksum
How to use checksums
d1bfeb74db14b11174c8ed051556875d1d7ad73098e3906656a5b877c7915f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.55.1 This release

2 release files

0.52.2

2 release files

0.52.0

2 release files

0.51.0

2 release files

0.50.0

2 release files

0.49.0

2 release files

0.48.0

2 release files

0.47.0

2 release files

0.46.0

2 release files

0.45.0

2 release files

0.44.0

2 release files

0.43.3

2 release files

0.43.2

2 release files

0.43.0

2 release files

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