simple-odf is a library for creating Open Document Format text files using Typescript/JavaScript and Node.js.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See usage for notes on how to integrate the project in your software.
To get started locally, follow these instructions:
-
Make sure that you have Node 10.x or later installed. See instructions here.
-
Make sure that you have yarn installed; see instructions here.
-
simple-odf uses npm for running development scripts. If you haven't already done so, please install npm.
-
Clone the forked repo to your local computer using git.
Open terminal and type:
git clone https://github.com/<your_username>/simple-odf
-
Run
npm install
from the root of your clone of this project to install dependencies.# navigate into the cloned repo cd simple-odf # install the dependencies npm install
To make a local build run:
npm build
npm pack
This generates a number of javascript files in the dist/
directory and a simple-odf-<version-number>.tgz
file in the project root.
To actually use the locally built lib, switch to another repository reproducing the specific issue you want to fix (or just generate a local repo). Then install the locally built package:
cd <path-to-your-other-repo>
npm install <path-to-the-simple-odf-repo>/*.tgz
There are two different kind of tests which can be run locally:
Each class of project should be tested isolated which is done by the unit tests. To run them, just execute npm test
.
There are also some tests which verify that the resulting document is correct. These cannot be run yet.
When debugging a specific test, change describe()
or it()
to fdescribe()
and fit()
to focus execution to just that one test. This will keep the output clean and speed up execution by not running irrelevant tests.
If you want to use this package in your software, add it to your project dependencies via npm or yarn.
# npm
npm i simple-odf
# yarn
yarn add simple-odf
Now you can create your first document.
const simpleOdf = require('simple-odf');
const document = new simpleOdf.TextDocument();
const body = document.getBody();
body.addHeading('Welcome to simple-odf');
body.addParagraph('The quick, brown fox jumps over a lazy dog.');
document.saveFlat('/home/homer/Welcome.fodf');
See the examples for more details on how to use the library.
- @xmldom/xmldom - Used to serialize the XML
If you want to contribute to simple-odf, you are very welcome. Send issues and pull requests with your ideas.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project exists thanks to all the contributors who participate in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
Learn more about the OASIS Open Document Format.