diff --git a/README.md b/README.md new file mode 100644 index 0000000..1c17d10 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +ods2md +====== + +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) + +Convert LibreOffice Calc Spreadsheets (*.ods) into Markdown tables + +![Sample output](sample.png) + +Install +------- + +1. Get Python 3. + +2. (Optional) Create a virtual environment. + + ```sh + python3 -m venv env + . env/bin/activate + ``` + +3. Install `ezodf` for parsing *.ods files + + ```sh + pip3 -r requirements.txt + ``` + +Usage +----- + +```sh +./ods2md.py input_file.ods > output_file.md +``` + +Limitations +----------- + +* This program disregards all formats. Currencies and percentages will be displayed as plain numbers. +* Merged cells are not supported, the content will be shown at the first cell (this is actually a limitation of GFM table) diff --git a/ods2md.py b/ods2md.py index c25878d..56afa03 100755 --- a/ods2md.py +++ b/ods2md.py @@ -1,8 +1,26 @@ #!/usr/bin/env python3 +# Copyright 2015, 2017 Kenny Chan +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +# associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, +# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or +# substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT +# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +from __future__ import print_function + import ezodf import sys -import html import unicodedata # Ref: http://stackoverflow.com/a/31666966/224671 diff --git a/requirements.txt b/requirements.txt index 7463e9e..f8bb0f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -ezodf==0.3.0 -lxml==3.4.4 +ezodf==0.3.2 +lxml==3.7.2 diff --git a/sample.png b/sample.png new file mode 100644 index 0000000..5978a49 Binary files /dev/null and b/sample.png differ