Coder Social home page Coder Social logo

odt2dynalist's Introduction

ODT to Dynalist Converter

Introduction

This project is a set of scripts I developed to convert a bunch of LibreOffice ODT files containing speaking notes to a format suitable for pasting into Dynalist. I'm releasing them in case they can help someone else. However, some assembly is required. There are many ways to format lists in LibreOffice/OpenOffice, and I made no attempt to account for any of them except for the one I use.

Because of the Some Assembly Required nature of these scripts, you should have at least basic familiarity with both Python and Bash.

You're welcome to fork it and modify it to suit your needs. If you modify it in a way that doesn't break existing functionality, feel free to send me a pull request. If it works without modification, count yourself lucky.

Prerequisites

I developed this on a Linux machine using LibreOffice 5.1.4.2. It will probably work on other operating systems and with OpenOffice, but I haven't tested any other setup.

Minimum requirements

If you meet these requirements, you'll be able to run the conversion script, but you'll have to interact with LibreOffice manually.

  • Python 3
  • Beautiful Soup 4 (only required for HTML mode). In Ubuntu, the package is python-bs4. For other systems, Google is your friend.

Optimal requirements

To take full advantage of the scripts, make sure you meet these requirements in addition to the minimum requirements above:

  • Bash on any supported OS: Linux, Mac OS, Windows 10, etc.
  • W3C's Tidy. The Ubuntu package is called tidy.
  • LibreOffice (I presume OpenOffice will also work, but I haven't tested it.)
  • A way to copy from the command line to the clipboard:
    • If you have X11 (as most Linux users have), you need xsel. The Ubuntu package is also called xsel.
    • If you have another environment (Windows 10, Mac OS, Mir, etc.), you'll need to research which tool to use and modify the odt2html and/or odt2txt scripts accordingly.

Configuration

Read through the file sermons_to_python.py and make any changes necessary to ensure compatibility with your source files. I can't give you specific instructions here, except to note that text mode is most likely the easiest to make work if your source files are compatible. See the comments in the script file for details. Text mode, however, can't convert any formatting or footnotes.

HTML mode

If you want to preserve formatting, you have to use HTML mode. I hope that HTML mode will work without configuration, but I make no promises. In particular, it only preserves bold, italic, and footnotes. If you want to preserve any other formatting, you'll need to modify the script. Pull requests that preserve additional formatting are welcome.

Text mode

If you want to use text mode, note that by default the supported outline format is as follows. If your files follow a different sequence, you'll have to adjust the script. If your files are inconsistent in style, then text mode will have problems.

I.  Level one
II. More level one
    A.  Level two
    B.  More level two
        1.  Level three
        2.  More level three
            a.  Level four
            b.  More level four
                i.  Level five
                ii. More level five
                    α.  Level six
                    β.  More level six
                    γ.  Still more level six
                iii. Still more level five
            c.  Still more level four
        3.  Still more level three
    C.  Still more level two
III.  Still more level one

Usage

Once everything is configured properly, run either odt2txt or odt2html. odt2html preserves some formatting, so it's preferred. However, depending on how your sources files are structured, you may need to fall back to odt2txt.

./odt2html /path/to/input/document.odt

The script will convert the file and copy the result to your clipboard. You should then be able to paste directly into Dynalist.

If the document contained footnotes, they'll have the #fixme hashtag added to them, because pasting directly into a Dynalist note isn't supported. You can do a search on Dynalist for #fixme and manually cut and paste the footnotes into Dynalist notes.

Known Issues

Some things don't work as well as I'd like them to. Here are the known issues:

  • LibreOffice is a real nuisance to work with via script. The conversion will fail silently if it is running when you invoke odt2html or odt2txt. The scripts try to check for this and print an error message if LibreOffice and/or OpenOffice is running, but the check isn't foolproof. If you're getting errors, make sure that LibreOffice/OpenOffice is complely shut down, including any background processes.
  • For some reason, I can't paste directly into Dynalist on Chromium. Instead, I have to paste into a text editor, select all, cut, then past into Dynalist. If you know of a solution, I'd love to hear about it.
  • If you can't use xsel or an equivalent program (see the optimal requirements section above), you'll need to modify odt2html and/or odt2txt to make them leave an output file around that you can open and manually copy from:
    • For odt2html, you need to keep the file html/$BASE.html.txt around until you've copied the data from it.
    • For odt2txt, you need the file txt/$BASE.txt.

odt2dynalist's People

Contributors

mssever avatar

Watchers

 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.