Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cpp2LaTeX

A charcoal-and-green workspace for turning standalone C++ functions into LaTeX pseudocode, using algorithm and algpseudocode.

Run locally

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python main.py

Open http://127.0.0.1:5000. For development with automatic reload, use flask --app main run --reload.

Deploy on Render

The included render.yaml creates one free Python web service in Singapore. Render installs the dependencies, runs test_app.py, then serves the app through Gunicorn. Pushes to the connected branch deploy automatically. Python uses the latest 3.13 patch release, as configured in .python-version.

In Render, create a Blueprint from this repository, or create a Web Service with these settings:

Setting Value
Runtime Python 3
Instance Free
Build command pip install -r requirements.txt && python test_app.py
Start command gunicorn main:app --bind 0.0.0.0:$PORT --access-logfile -
Health check /

No database, LaTeX installation, or secret environment variables are needed. The app generates LaTeX source without executing C++ or compiling documents on the server.

To connect a domain, open the service's Settings → Custom Domains, add the exact hostname, create the DNS records Render displays, and select Verify. Render provisions HTTPS automatically. Domain registration is separate; the free service sleeps after 15 minutes without traffic and can take about a minute to wake up.

Use the workspace

Paste a function, import or drop a C++ source file, or load an example. Optionally set an algorithm title, toggle line numbers, and choose a full document or an algorithm snippet. Click Convert to LaTeX (or press Ctrl/⌘ + Enter), inspect the layout preview or LaTeX source, then copy or download the .tex file.

The source and settings are saved in this browser. Clear and replacement actions offer Undo. Tab keeps its normal keyboard navigation behavior; Ctrl/⌘ + ] indents the selected lines. The converter sends code to the Flask server, does not execute it, and does not write it to server storage.

The full document includes its LaTeX packages. To use a snippet in an existing paper, add this to its preamble:

\usepackage{algorithm}
\usepackage{algpseudocode}

The browser preview illustrates the algorithm's structure, rather than compiling a PDF. Compile the downloaded file in your LaTeX editor for final typesetting.

Supported input

One complete function at a time, up to 50,000 characters. Supports nested if / else if / else, for, while, do / while, braced or single-statement bodies, return statements, expressions, and standalone or trailing comments. Identifiers and LaTeX special characters are preserved and escaped. Do/while conditions are negated for the equivalent repeat / until form.

This is a lightweight statement parser, not a C++ compiler. Classes, templates, macros (other than include lines), switch, exceptions, lambdas, and initializer lists are not supported. Comments inside expressions should be moved to their own line. The converter validates structure; it does not type-check C++.

Check the converter

python test_app.py

The dependency-free regression checks cover nesting, do/while semantics, escaping, output settings, invalid input, request limits, and the Flask routes.

Created by Ayush Rathore, Shardendu Shekhar Chaubey, and Lokesh Yadav.

About

A tool converting C++ functions to LaTeX pseudo-code, reducing time spent on professional writing by over 90%.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages