LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-31-2017, 11:34 AM   #1
Krupski
Member
 
Registered: Jan 2015
Location: The worst state in USA (can you guess?)
Distribution: Debian 11 (x86_64)
Posts: 44

Rep: Reputation: 0
Need to convert man page to .odt or .doc and back again


Hi all,

I would like to know if there is a utility to convert a man page file to a Libre Office .odt or .doc file and then back again?

I'm working on adding a lot of features and functions to an existing package and of course wish to update it's man page accordingly.

So, here's what I'm hoping to do:

(1) Convert the man page file to an .odt or .doc file.
(2) Open it with Libre Office Writer and edit it.
(3) Convert the edited .odt or .doc file back to a man page file.

NOTE that I need to preserve the existing formatting, since the man page utilizes bold and underline.

BTW, my system is Debian 8, x86_64 if that makes any difference.

Thanks!
 
Old 07-31-2017, 11:37 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Take a look at http://docbook.org for a glimpse "behind the scenes" at the technology that is used at the source of many forms of documentation – including man-pages. There is a root-source document from which man-page content is generated, and this same technology can generate other forms of output.

For instance, all of those O'Reilly Books that we used to pore over, were all written in DocBook, and all of the derivative publications that they produced came from the same sources.

So, you wouldn't take the man-page-formatted output: you'd go back to its XML source, and produce your other output from it.

Welcome to the wonderous world of "XSLT."

Last edited by sundialsvcs; 07-31-2017 at 11:39 AM.
 
Old 07-31-2017, 11:48 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by Krupski View Post
NOTE that I need to preserve the existing formatting, since the man page utilizes bold and underline.
Formatting or structure? The data format for man pages contains a heck of a lot of structural information that you would 100% lose if you were to just look at the layout and presentation.

Anyway, I digress. Your approach will not work to get to your stated goal of building out an existing man page. The only way to do that is to use the format they use. See the macros documentation for that:

Code:
man 7 man
It's not difficult and it is precise.

Over in OpenBSD, there have been a lot of refinements in regards to manuals:

http://mandoc.bsd.lv/

I think some of the other BSDs have also adopted these improvements. Hopefully, they will eventually wend their way over to GNU/Linux.
 
Old 07-31-2017, 12:01 PM   #4
Krupski
Member
 
Registered: Jan 2015
Location: The worst state in USA (can you guess?)
Distribution: Debian 11 (x86_64)
Posts: 44

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sundialsvcs View Post
Take a look at http://docbook.org for a glimpse "behind the scenes" at the technology that is used at the source of many forms of documentation – including man-pages. There is a root-source document from which man-page content is generated, and this same technology can generate other forms of output.

For instance, all of those O'Reilly Books that we used to pore over, were all written in DocBook, and all of the derivative publications that they produced came from the same sources.

So, you wouldn't take the man-page-formatted output: you'd go back to its XML source, and produce your other output from it.

Welcome to the wonderous world of "XSLT."
I was really looking for a utility where my lazy self could just do something like this:

$utility < manpage.1 > manpage.doc

And, by the way, my source file isn't in XML format, it looks like this (a small snippet of course):

.IP "\fBdefdbl\fP \fIvariable\fP[\fB\-\fP\fIvariable\fP]" "{{{
Declare the global \fIvariable\fP as real. Only unqualified variables (no
type extension) can be declared. Variable ranges can only be built from
single letter variables. Declaration is done at compile time.
."}}}
.IP "\fBdefint\fP \fIvariable\fP[\fB\-\fP\fIvariable\fP]" "{{{
Declare the global \fIvariable\fP as integer.
."}}}
.IP "\fBdefstr\fP \fIvariable\fP[\fB\-\fP\fIvariable\fP]" "{{{
Declare the global \fIvariable\fP as string.
."}}}


...which (after conversion) in the document editor would look like this:

defdbl variable[-variable]
Declare the global variable as real. Only unqualified variables (no type extension) can be declared. Variable ranges can only be built from single letter variables. Declaration is done at compile time.

defint variable[-variable]
Declare the global variable as integer.

defstr variable[-variable]
Declare the global variable as string.


...and when converted back to a .man file would display the same way (aside from breaking to fit the current screen width).

Am I making any sense here?
 
Old 07-31-2017, 12:06 PM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by Krupski View Post
Am I making any sense here?
No. Sorry. Typographic markup is about the best that word processors can do. There can be some structural markup at the block level (headings, paragraphs, etc.) but that is not enough.

I reiterate my suggestion to look at the original format:

Code:
man 7 man
It will save you time and effort.

It's all about using the right tool for the job.
 
Old 07-31-2017, 12:10 PM   #6
Krupski
Member
 
Registered: Jan 2015
Location: The worst state in USA (can you guess?)
Distribution: Debian 11 (x86_64)
Posts: 44

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
Anyway, I digress. Your approach will not work to get to your stated goal of building out an existing man page. The only way to do that is to use the format they use. See the macros documentation for that
I find that difficult to believe. If I had to do this more than once, I could easily write a console mode (CLI) utility to convert the "/fB" to bold and "/fI" stuff to bold and underline then generate a .doc file.

I also can't imagine that in 2017 people still use awkward cryptic coding to make a man page.

It SHOULD be as easy as firing up a word processor, writing the text (complete with formatting) and then "save as man page".

Or, fire up the word processor, LOAD the man page file and have it auto-converted to standard "document" format, which could be edited then saved back as a man page.

Seriously.... too much to expect?
 
Old 07-31-2017, 12:17 PM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by Krupski View Post
Seriously.... too much to expect?
Yes. Unfortunately. The information theory behind it does not allow for it. See the difference between typographic markup and structural markup. You'd have to add a whole new level of complexity to your text editor. Levels that have only previously had in full-blown XML or SGML editors. That level of detail takes a lot of effort to work with. I've done that at large scales in the past back when SGML was all the rage.

You and I could probably have a lazy-contest, but it'd be too much effort. I've made small changes to lots of manual pages. I found it far easier to work with the macros than previous work with XML or SGML. My approach has been to just fire up a text editor and use the macros. Compared to the high-powered electronic publishing methods, it's worlds easier.
 
Old 07-31-2017, 12:25 PM   #8
Krupski
Member
 
Registered: Jan 2015
Location: The worst state in USA (can you guess?)
Distribution: Debian 11 (x86_64)
Posts: 44

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
Yes. Unfortunately. The information theory behind it does not allow for it. See the difference between typographic markup and structural markup. You'd have to add a whole new level of complexity to your text editor. Levels that have only previously had in full-blown XML or SGML editors. That level of detail takes a lot of effort to work with. I've done that at large scales in the past back when SGML was all the rage.

You and I could probably have a lazy-contest, but it'd be too much effort. I've made small changes to lots of manual pages. I found it far easier to work with the macros than previous work with XML or SGML. My approach has been to just fire up a text editor and use the macros. Compared to the high-powered electronic publishing methods, it's worlds easier.
Wow. I'm actually amazed. It LOOKS like it should be simple to do.... I guess I'm missing something important.
 
Old 07-31-2017, 12:43 PM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Just putting bold or italics here and there would be simple, but there is much more actually going on under the hood. I think the current buzzword might be "semantic markup" rather than "structural markup". If you look up the former, you might find some relevant material.
 
Old 07-31-2017, 01:10 PM   #10
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
heres my attempt:
http://www.linuxquestions.org/questi...es-4175591129/
 
  


Reply

Tags
convert, edit, man page, office, utility



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Libreoffice - how can I convert many odt files to doc or pdf automatically? charlemagne-is-my-son Linux - Software 3 12-10-2012 11:32 AM
[SOLVED] How to convert html to odt or doc using linux command line? zoghbi Linux - Newbie 5 12-26-2011 03:49 AM
convert odt or .doc into html linuxmandrake Linux - Software 6 02-23-2008 03:48 AM
automatic conversion .doc to .odt? (several files) quarry_06 Linux - Software 2 01-31-2006 06:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration