Skip to main content

overphloem

Framework for writing Overleaf bots

Features

  • Sync a local directory with an Overleaf project
  • Run edits / operations on the project and push
  • Monitor and detect changes in real-time
  • Handle concurrent changes with automatic rebasing

Explanation

Overleaf is a collaborative LaTeX editor. Though it does not technically use git for version control, it does have a feature that allows you to sync your project with a git repository. This is useful for keeping your project in sync with a git repository, and for collaborating with others.

Because we can interact with the document project loosely like a git repository, we can automate syncs to and from the project.

Examples

Sync a local directory with an Overleaf project

uv run overphloem pull --project-id $PROJECT_ID

Push a local directory to an Overleaf project

uv run overphloem push --project-id $PROJECT_ID

Monitor changes in an Overleaf project

uv run overphloem listen --project-id $PROJECT_ID --verbose

Run a script on the project when it changes

uv run overphloem attach --on=change --project-id $PROJECT_ID --script ./examples/change_detector.sh

This can also be done using the overphloem.on decorator in Python:

from overphloem import on, Event, Project

PROJECT_ID = '1234567890'

@on(Event.CHANGE, PROJECT_ID, push=True)
def on_change(project: Project):
    # Replace all occurrences of 'foo' with 'bar'
    for file in project.files:
        if file.name.endswith('.tex'):
            file.content = file.content.replace('foo', 'bar')
    return True # Return True to push changes

Change Monitoring

overphloem provides several ways to monitor and respond to changes in Overleaf projects:

  1. CLI Listen Command: Use listen to monitor and display changes in real-time

    uv run overphloem listen --project-id $PROJECT_ID --verbose
    
  2. Attach Shell Scripts: Run custom shell scripts when changes are detected

    uv run overphloem attach --project-id $PROJECT_ID --script ./examples/change_detector.sh
    
  3. Python Event API: Create custom event handlers using the @on decorator

    from overphloem import on, Event
    
    @on(Event.CHANGE, 'your-project-id')
    def on_change(project):
        print(f"Changes detected in {project.project_id}")
    

See the examples directory for sample scripts demonstrating these approaches.

Known Limitations

main_file

The Project#main_file property is hard-coded to main.tex. This is a limitation because Overleaf does not report the main file.

Event listeners vs loops

There is no way to add "hooks" to Overleaf, so we have to poll the project for changes. This is done using a loop that checks the project for changes every N seconds, with optional falloff. This is not ideal, but it is the best we can do for now.

Git Synchronization

When both local and remote repositories have changes, the push command now automatically performs a rebase before pushing. This handles most concurrent editing scenarios gracefully, but complex merge conflicts may still require manual intervention.

Metadata

Release files for overphloem 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 overphloem 0.1.0
File Size Uploaded
overphloem-0.1.0.tar.gz 7.9 kB Details

Built distribution (wheel)

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

Total release size: 11.3 kB

Release files / overphloem-0.1.0.tar.gz

Download URL overphloem-0.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
37e9f02f0c3cb07cb51d3a02b6a8c65935cb157ba918b344072169c3ff829fbf
BLAKE2b-256 checksum
How to use checksums
cdc447c882186e8714ba9ad3626b49e6c108dac23e31c7b16e0217a5ddb5a38b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

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

Download URL overphloem-0.1.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eeb9b8f3f3f5eb846b1dd2a1356a405147eceee73aa907d9569d926233765ad
BLAKE2b-256 checksum
How to use checksums
75190a7dc3cb9c446d5bc2f220988156897e30c8253eb060ee5bbbf223d3d575
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

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