Framework for writing Overleaf bots
Project description
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:
-
CLI Listen Command: Use
listento monitor and display changes in real-timeuv run overphloem listen --project-id $PROJECT_ID --verbose
-
Attach Shell Scripts: Run custom shell scripts when changes are detected
uv run overphloem attach --project-id $PROJECT_ID --script ./examples/change_detector.sh
-
Python Event API: Create custom event handlers using the
@ondecoratorfrom 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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file overphloem-0.1.0.tar.gz.
File metadata
- Download URL: overphloem-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37e9f02f0c3cb07cb51d3a02b6a8c65935cb157ba918b344072169c3ff829fbf
|
|
| MD5 |
aaa6fc441e6a51c898f223058a1a2a0d
|
|
| BLAKE2b-256 |
cdc447c882186e8714ba9ad3626b49e6c108dac23e31c7b16e0217a5ddb5a38b
|
File details
Details for the file overphloem-0.1.0-py3-none-any.whl.
File metadata
- Download URL: overphloem-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eeb9b8f3f3f5eb846b1dd2a1356a405147eceee73aa907d9569d926233765ad
|
|
| MD5 |
208eccab3749e41b353a79f1e36e04d6
|
|
| BLAKE2b-256 |
75190a7dc3cb9c446d5bc2f220988156897e30c8253eb060ee5bbbf223d3d575
|