I work a lot with LibreOffice Writer.
I wanted to know if there was a way to edit the text through the terminal?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
libreoffice comes with an option to convert an
odt file to plain text, which then can be edited with your preferred command-line text editor and (if wanted) converted back to
libreoffice --convert-to txt document.odt
Edit the file with your preferred text editor, e.g.:
gedit document.txt nano document.txt vim document.txt
Convert it back. The
--convert-to takes a filename extension as an argument, but you may also specify a filename suffix to prevent
libreoffice from overwriting the original file (which it does without asking!):
libreoffice --convert-to _new.odt document.txt
For the conversion there's also
odt2txt, I'd just try both and compare the results.
If you're using
vim you can configure it to automatically do the conversion for you in the background, see: Is it possible to easily work with .odt, .doc, .docx, .rtf, and other non-plain-text formats in Vim? The answer there uses
odt2txt for the conversion, but it should be possible with
libreoffice --convert-to as well.
The closest thing to what you're looking for is
wordgrinder, a terminal-based word processor.
You can install it executing:
sudo apt install wordgrinder
Here is the official website of the project: https://cowlark.com/wordgrinder/
This is the Github repo: https://github.com/davidgiven/wordgrinder
And a quick Survival Guide: https://gist.github.com/davidgiven/1aba97e96a9b8f9b573b
If you check the Importing and Exporting sections you will find:
Imports basic content from ODT files. OpenDocument is complicated and hard to parse but WordGrinder will do its best to apply appropriate styles. Unsupported features are ignored.
This produces an ODT file which can be read by LibreOffice and a variety of other major word processors. Character and paragraph styles are exported and are mapped to OpenDocument styles called P, H1, H2 etc.