A lightweight, robust bash script designed to convert Office documents (like .odt and .docx) into Typst or LaTeX formats. It automatically extracts embedded images and handles relative file paths, ensuring your generated code compiles perfectly right out of the box.
π€ AI Disclosure: This project, including the conversion scripts and this documentation, was fully generated by AI.
To use this script, you need to have the following tools installed on your system:
- Pandoc: The core document converter (Version 3.0 or higher is required for Typst support).
- Bash: Standard Unix shell (Linux/macOS).
- Typst CLI (Optional): If you want to compile the
.typfiles into PDFs locally. - LaTeX distribution (Optional): e.g., TeX Live, if you are converting to
.texand want to compile locally.
sudo dnf install pandoc
cargo install typst-cli # If you have Rust installedClone this repository or download the script directly. Make the script executable:
chmod +x convert_simple.shThe script requires exactly three arguments:
Source File: The absolute path to your .odt or .docx file.
Output Directory: The absolute path to the folder where you want the project saved.
Format: typ (for Typst) or tex (for LaTeX).
Command Syntax:
./convert_simple.sh <SOURCE_FILE> <TARGET_DIRECTORY> <FORMAT>Example:
./convert_simple.sh "/home/user/Documents/Thesis.odt" "/home/user/Projects/Typst_Code" typWhat the script does automatically:
Creates a dedicated project folder named after your document in the target directory.
Moves into that directory to enforce relative paths for all media.
Runs Pandoc to convert the text and extracts all embedded images into a local media/ subfolder.
Leaves you with a clean, instantly compilable .typ or .tex file.
PDF Inputs: Pandoc cannot convert from PDFs. If you have a PDF, you must first convert it to a .docx file (e.g., using Word, Adobe, or Mathpix for complex formulas) before running this script.
Complex ODT Objects: Native LibreOffice drawing objects or embedded charts in .odt files may not extract perfectly. Saving the file as .docx before running the script usually resolves this.