rocher


Namerocher JSON
Version 0.52.0 PyPI version JSON
download
home_pageNone
SummaryRocher is wrapper arround the Monaco code Editor. It can be embed into any Python web application. Helper for Flask is provided.
upload_time2024-11-30 16:14:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords monaco code diff editor
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rocher

<a href="https://pypi.python.org/pypi/rocher"><img src="http://img.shields.io/pypi/dm/rocher.svg"></a>

Rocher is a Python package for the [https://github.com/microsoft/monaco-editor](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](screenshot.png)

## Installation

```bash
pip install rocher
```

## Usage

See the [samples/](Samples) folder for more examples to use it with multiple frameworks.

### Path

The package provides only a function path():
    
```python   
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():

```python
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:

```python
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:

```python

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:
    
```django
<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:

```django
{{ 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:    
```bash
hatch build -t sdist 
```
To build the packaged version.

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

## License

Licensed under the MIT License, see [LICENSE](LICENSE) for more information.

## Credits

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rocher",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Monaco, code, diff, editor",
    "author": null,
    "author_email": "Julien Duponchelle <julien@duponchelle.info>",
    "download_url": "https://files.pythonhosted.org/packages/0b/55/fd93f3ad90ebd65d9a891d2dccfcbc60c95b61ee6fb0c85a7a2aa90499b6/rocher-0.52.0.tar.gz",
    "platform": null,
    "description": "# Rocher\n\n<a href=\"https://pypi.python.org/pypi/rocher\"><img src=\"http://img.shields.io/pypi/dm/rocher.svg\"></a>\n\nRocher is a Python package for the [https://github.com/microsoft/monaco-editor](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.\n\n![Screenshot](screenshot.png)\n\n## Installation\n\n```bash\npip install rocher\n```\n\n## Usage\n\nSee the [samples/](Samples) folder for more examples to use it with multiple frameworks.\n\n### Path\n\nThe package provides only a function path():\n    \n```python   \nimport rocher\n\nrocher.path()\n```\n\nThis 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.\n\n### Editor HTML\n\nThe package provides a editor_html():\n\n```python\nimport rocher\n\nrocher.editor_html(\n    \"/static/vs\",\n    \"container\",\n    \"python\",\n    \"print('Hello World!')\",\n)\n```\n\nThis 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.\n\n### Colorizer\n\nThe package also a simple syntax highlighter:\n\n```python\nimport rocher\n\nrocher.colorize_html(\"container\")\n```\n\nThis 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.\n\n\n### Flask\n\nThe package provide an helper for Flask + Jinja2:\n\n```python\n\nFirst you need to register the editor\n\n```python\nfrom flask import Flask\nimport rocher.flask\n\napp = Flask(__name__)\n\nrocher.editor_register(app)\n```\n    \nThen you can use the editor in your template:\n    \n```django\n<div id=\"container\" style=\"width:800px;height:600px;border:1px solid grey\"></div>\n{{\n    rocher_editor(\n        \"container\",\n        \"python\",\n        source_code,\n        readOnly=true,\n        theme=\"vs-dark\",\n        lineHeight=20\n    )\n}}\n```\n\nAll supported options are listed here: https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html\n\n\nOr the colorizer:\n\n```django\n{{ rocher_colorize(\"code\", initialize=False) }}\n\n<h2>Python</h2>\n<pre id=\"code\" data-lang=\"python\" style=\"width: 500px\">\nprint(\"Hello World!\")\n</pre>\n```\n\n## Why the name Rocher?\n\nLe Rocher is the hill where the Principality of Monaco is built. \n\n## Versioning\n\nFollowing 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.\n\n## Update the Monaco Editor\n\nEdit 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.\n\nAnd run:    \n```bash\nhatch build -t sdist \n```\nTo build the packaged version.\n\n## I can't find the Monaco Editor source code in the repository\n\nThe 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.\n\n## Projects using this package\n\n- [https://github.com/julien-duponchelle/colvert](Colvert a DuckDB UI)\n\n## License\n\nLicensed under the MIT License, see [LICENSE](LICENSE) for more information.\n\n## Credits\n\nAll credit goes to the Monaco Editor team. This package is just a wrapper around their work.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Rocher is wrapper arround the Monaco code Editor. It can be embed into any Python web application. Helper for Flask is provided.",
    "version": "0.52.0",
    "project_urls": {
        "Documentation": "https://github.com/julien-duponchelle/rocher#readme",
        "Issues": "https://github.com/julien-duponchelle/rocher/issues",
        "Source": "https://github.com/julien-duponchelle/rocher"
    },
    "split_keywords": [
        "monaco",
        " code",
        " diff",
        " editor"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af8bd5ebd49f825d6676eca5b4b453a95529f12e04febbfb982e551c83d49803",
                "md5": "fc8722f40550c6f2537e7888f845b97e",
                "sha256": "2e4861fb6f6c5a478100c97b99d3d2aa540d5e20a6e9bfea5dc2064518d4b5be"
            },
            "downloads": -1,
            "filename": "rocher-0.52.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc8722f40550c6f2537e7888f845b97e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3252860,
            "upload_time": "2024-11-30T16:14:29",
            "upload_time_iso_8601": "2024-11-30T16:14:29.833816Z",
            "url": "https://files.pythonhosted.org/packages/af/8b/d5ebd49f825d6676eca5b4b453a95529f12e04febbfb982e551c83d49803/rocher-0.52.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b55fd93f3ad90ebd65d9a891d2dccfcbc60c95b61ee6fb0c85a7a2aa90499b6",
                "md5": "6b686dc1d981f37f10d3c1fcfe2196aa",
                "sha256": "6c50d5c2ac1cfa84c681aec96ef6b5e148303c90221c2b5ec00685ebb623107a"
            },
            "downloads": -1,
            "filename": "rocher-0.52.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6b686dc1d981f37f10d3c1fcfe2196aa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 3137169,
            "upload_time": "2024-11-30T16:14:35",
            "upload_time_iso_8601": "2024-11-30T16:14:35.400265Z",
            "url": "https://files.pythonhosted.org/packages/0b/55/fd93f3ad90ebd65d9a891d2dccfcbc60c95b61ee6fb0c85a7a2aa90499b6/rocher-0.52.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-30 16:14:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "julien-duponchelle",
    "github_project": "rocher#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rocher"
}
        
Elapsed time: 0.38901s