Coder Social home page Coder Social logo

libreoffice2git's Introduction

libreoffice2git

A bashscript to convert Libreoffice Writer Documents (.odt) to a Git Friendly Format with text based diff available

Preamble

Libreoffice file formats are ZIP archives with XML files in them containing the content and styles. As ZIP archives are binary files unfortunately Git (and therefore GitHub, GitLab,etc.) won't display a nice diff for them.

This script provides a work-around in the meantime by creating a folder for each .ODT file and placing within it content that can easily have diff performed on it with good results.

Features

  • Creates a subfolder called <FILENAME.odt.git> in the folder the .odt file resides in
  • Creates Markdown and Plaintext using pandoc
  • Optionally:
    • Exports embeded pictures from the .odt file
    • Exports the whole "flat odt xml" file but tidies the XML using xmllint for easier comparisions

Usage

USAGE: ./libreoffice2git.sh [-hpz] -i <file>

  where:
    -i  --input         Input file (.odt format)
    -p  --pictures      Extract the pictures
    -z  --unzip         Save the full unzipped ODT (includes -p)
    -h  --help          show this help text

Please note that this script requires unzip, pandoc and xmllint to be installed. These are easily installed on Mac (from Homebrew)(e.g. brew install pandoc) or Ubuntu (e.g. apt-get install pandoc)

Examples

Extract just markdown and plaintext from resume.odt

./libreoffice2git.sh --input resume.odt

Extract just markdown and plaintext with pictures from resume.odt

./libreoffice2git.sh --pictures --input resume.odt

Flatten the .odt into xml, pictures with markdown and plaintext from resume.odt

./libreoffice2git.sh --pictures --unzip --input resume.odt

Git Pre-Commit Hook

To automate the git management of the office files you can install a git pre-commit hook that builds the files on already tracked office files.

Just copy the githook-pre-commit to .git/hooks/pre-commit

The libreoffice2git.sh will need to be run on each new .odt file before the hook will track the changes automatically

Based on

This script is based on the powershell script for Microsoft Word .docx files by Tomáš Hübelbauer found at https://github.com/TomasHubelbauer/modern-office-git-diff

libreoffice2git's People

Contributors

timwiel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.