Define a Linux manual page's TITLE text when using docbook2man? - linux

I'm experimenting with Linux manual (man) page creation using DocBook, and specifically I'm using 'docbook2man' on a Fedora 20 box, and I've been unable to figure how to create the manual's title text.
For example, if I open the man-pages(7) manual page, the manual's title is MAN-PAGES(7) and the manual's title text is Linux Programmer's Manual.
For further clarification, man-pages(7) defines the TH command as
.TH title section date source manual
It's the manual element--e.g., Linux Programmer's Manual--that I'm trying to figure out how to create using docbook2man.
I've been experimenting with the example code found in section 4.6 "Generating a man page" on the Using DocBook website. The pertinent sections of that code example are provided below (see Listing 1). The file name I'm using for this example code is foo-ref.sgml. The command line I'm using is
docbook2man foo-ref.sgml
Listing 1. Example SGML manual page
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<refentry>
<refentryinfo>
<date>2001-01-01</date>
</refentryinfo>
<refmeta>
<refentrytitle>
<application>foo</application>
</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>foo 1.0</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
<application>foo</application>
</refname>
<refpurpose>
Does nothing useful.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>2001-01-01</date>
</refsynopsisdivinfo>
<cmdsynopsis>
<command>foo</command>
<arg><option>-f </option><replaceable class="parameter">bar</replaceable></arg>
<arg><option>-d<replaceable class="parameter">n</replaceable></option></arg>
<arg rep="repeat"><replaceable class="parameter">file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<refsect1info>
<date>2001-01-01</date>
</refsect1info>
<title>DESCRIPTION</title>
<para>
<command>foo</command> does nothing useful.
</para>
</refsect1>
<!-- etc. -->
</refentry>
When I process this source code with docbook2man, a man page named 'foo.1' is generated whose .TH macro is rendered as shown below, but with an empty string "" for the manual's title text element:
.TH "FOO" "1" "2001-01-01" "foo 1.0" ""
I've dug around in the DocBook5 refentry refernece manual, trying various tags, but so far I haven't found anything that produces the title text. I've also searched the Interwebs for DocBook manual page examples, but none of the examples I've found produces the manual title text. So I'm starting to wonder if this is even doable with docbook2man?
Any suggestions?

After some more experimenting and without the desired results, I decided to abandon the docbook2man program and use instead the doclifter(1) and xsltproc(1) programs to create my Linux manual pages.
Example 1) On a Fedora 20 host, use doclifter to translate an existing man page man-pages(7) into a DocBook 'refentry' compatible XML file. This is VERY USEFUL because it renders an XML file that can can be used as a example reference for creating one's own DocBook 'refentry' XML source files.
Listing 1. doclifter example (man->XML)
# Install the doclifter package
sudo yum -y install doclifter
# Create a temporary directory in which to experiment, and go to it
mkdir ~/tmp
cd ~/tmp/
# Copy the existing man-pages.7.gz file into the temporary directory
# and uncompress it.
cp /usr/share/man/man7/man-pages.7.gz ~/tmp/
gunzip man-pages.7.gz
# Convert the man page into DocBook XML format
doclifter man-pages.7
# There should now be a file named 'man-pages.7.xml'.
ls man-pages.7.xml
Example 2) On a Fedora Linux 20 host, use xsltproc to convert an XML file ~/tmp/foo.xml containing DocBook refentry content into a Linux manual (man) page ~/tmp/foo.1.
Listing 2 below is the XML source code for example file ~/tmp/foo.xml that will be translated by xsltproc into the manual page file ~/tmp/foo.1 (see Listing 3 below). This XML source code is a derivative work from (1) the SGML example code provided in section 4.6 "Generating a man page" on the Using DocBook website, and (2) various code snippets--some modified, some copied verbatim--from the XML file created by doclifter in Example 1 above.
Listing 2. Example DocBook 'refentry' XML file ~/tmp/foo.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<refentry id='foo'>
<!-- HEADER & FOOTER INFO -->
<refmeta>
<!-- see also: man 7 man-pages -->
<!-- .TH title section date source manual -->
<!-- title -->
<refentrytitle>FOO</refentrytitle>
<!-- section -->
<manvolnum>1</manvolnum>
<!-- date -->
<refmiscinfo class='date'>2015-06-26</refmiscinfo>
<!-- source -->
<refmiscinfo class='source'>SOURCE TEXT</refmiscinfo>
<!-- manual -->
<refmiscinfo class='manual'>MANUAL TEXT</refmiscinfo>
</refmeta>
<!-- Section: NAME -->
<refnamediv>
<refname>foo</refname>
<refpurpose>
Does nothing useful.
</refpurpose>
</refnamediv>
<!-- Section: SYNOPSYS -->
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
<command>foo</command>
<arg><option>-f </option><replaceable class="parameter">bar</replaceable></arg>
<arg><option>-d<replaceable class="parameter">n</replaceable></option></arg>
<arg rep="repeat"><replaceable class="parameter">file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<!-- Section: DESCRIPTION | OPTIONS | ... -->
<refsect1 id='description'><title>DESCRIPTION</title>
<para>
<command>foo</command> does nothing useful.
</para>
</refsect1>
<refsect1 id='authors'><title>AUTHORS</title>
<para>Jim Fischer</para>
</refsect1>
</refentry>
Listing 3 below shows the xsltproc commands to use (on a Fedora 20 host) to translate the file ~/tmp/foo.xml into the manual page file ~/tmp/foo.1.
Listing 3. xsltproc example (foo.xml -> foo.1)
# Change to the temporary directory
cd ~/tmp/
# Use xsltproc to convert foo.xml into foo.1
$ xsltproc /usr/share/sgml/docbook/xsl-stylesheets-1.78.1/manpages/docbook.xsl foo.xml
# Verify foo.1 was created
ls foo.1
man ./foo.1

Still experimenting with this whole XML->MAN conversion process. Here's another method for performing the conversion that I think I prefer to the xsltproc version shown in my previous reply.
Listing 1. XML->MAN conversion using db2x_xsltproc and db2x_manxml
#!/bin/bash
# vim: ft=sh:tw=75:ts=4:sw=4
clear
MANDIR=${HOME}/tmp/
MANUAL=foo
SECTION=1
MAN_FILE="${MANUAL}.${SECTION}"
XML_FILE="${MANUAL}.xml"
cd "${MANDIR}"
# [Optional] Sanity check to ensure the man page build actually occurs.
rm -f "${MAN_FILE}"
# XML -> MAN
# n.b. The option '--to-stdout' allows full control over the
# man page's file name. Otherwise, the man page's file name is
# defined implicitly via the refentry.refmeta.refentrytitle
# value in the XML source file. Note that (1) the refentrytitle
# value corresponds to ".TH title" and should be written in
# all-caps--e.g., 'FOO'--in accordance with man-pages(7), and
# (2) one typically does not want the man page's file name to
# be all-caps (preferred file name is 'foo.1' and not 'FOO.1').
#
db2x_xsltproc -s man "${XML_FILE}" | db2x_manxml --to-stdout > "${MAN_FILE}"
exit_code=("${PIPESTATUS[#]}")
if [ ${exit_code[0]} -ne 0 ]; then
echo ":: ERROR :: db2x_xlstproc returned exit code ${exit_code[0]}; aborting..." >&2
exit "${exit_code[0]}"
elif [ ${exit_code[1]} -ne 0 ]; then
echo ":: ERROR :: db2x_manxml returned exit code ${exit_code[1]}; aborting..." >&2
exit "${exit_code[1]}"
fi
# Display the man file
man ./"${MAN_FILE}"

Related

I want to write a document to be viewed via the 'less' command. Where can I find the formatting standards specifications?

I would like to convert Markdown files so these can be viewed via less...
However, I want the formatting (bold, italic, etc.) to be preserved and displayed accordingly... Unfortunately I cannot find the specifications.
My preferred approach would have been to use Pandoc to convert the md-files into a file type that less can properly display...
Files of any format supported by pandoc can be read like Unix man pages:
pandoc --standalone --to=man INPUT_FILE | man -l -
This uses less by default, unless you have the PAGER variable set to some other value.
A good way to use it is to create a shell function:
mandoc () { pandoc --standalone --to=man "$#" | man -l - }
Now you can read files using Markdown, docx, LaTeX, etc. as if they were manpages.
mandoc README.md
mandoc term-project.tex
mandoc thesis.docx
# and so on
As you can see, the command causes pandoc to convert its input to a format called man, which is really groff man (see https://man.cx/groff_man(7)).

"No manual entry for [filename]" error, when trying to view my man page [duplicate]

This question already has answers here:
How do you view a man page you just created?
(2 answers)
Closed 3 years ago.
I'm creating a man page with Vim for something I made, but when I try to view it with the command:
man testScript.1
I get the error "No manual Entry testScript.1"
However, if I use:
cat *testScript.1
I can see the contents of that file listed.
This is what little code I have so far:
#!/bin/bash
.TH Testingjanne 1 "24 April 2019" "Version 1"
.sh NAME
Testingjanne - To test Janne
.SH SYNOPSIS
.B [-d] [-e] [-f
.I filename
.B ]
What am I doing wrong? Why can't I see the man page as a man page?
You can view your man page with:
man testScript
for example, if I do:
echo foo > /usr/share/man/man1/padawin.1
Then, the following works:
man padawin

add a permitted path to ghostscipt running configuration

I use a program which create me postscript file before using ps2pdf to make it a readable pdf, i've made a program which add some string to overwrite the company new logo. (The first program can't import image file itself).
I add the string before the before-last line of the file (" showpage").
While running my program to add the logo there is no error.
With the option -dNOSAFER everything is fine, but by default it's set to -dSAFER, and an invalidfileaccess error pop, the files are 6 jpg images alone in their directory.
I don't want to make it run with the -dNOSAFER option on. As it will fully open the file system.
In the documentation I've seen that there is a "permitted path" setting, but i can't find nowhere to set this up. Is it just a command line option to set in the command launching the program ? Or is there a config file for GhostScript / ps2pdf where i can put the path to this directory as permitted path.
in this documentation :
http://www.ghostscript.com/doc/current/Use.htm
I only find
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than
standard input, at the end of each page. This may be useful if input
is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE. Also
note that -dTTYPAUSE requires opening the terminal device directly,
and may cause problems in combination with -dSAFER. Permission errors
can be avoided by adding the device to the permitted reading list
before invoking safer mode
gs -dTTYPAUSE -dDELAYSAFER -c '<< /PermitFileReading [ (/dev/tty)] >> setuserparams .locksafe' -dSAFER
The quote is just for the context but is this a way to put the permitted path ?
As gs automatically launch with the full system as readOnly there will be no difference ? There is no other find result for PermitFile in this page.
Try adding the required path to the search path with -I (Include) See Use.htm, section 8 How Ghostscript finds files. This should only be a problem if you are using 'run' or similar to read files from another location.
The section on TTYPAUSE is not relevant.

Using find with -L option

I have this:
mylink -> myfile
When I do:
find -L . -name 'mylink'
I get:
./mylink
I don't understand why this is so, given this from the man page:
-L : Follow symbolic links. When find examines or prints information about files, the information used shall be taken from the properties of the file to which the link points, not from the link itself (unless it is a bro- ken symbolic link or find is unable to examine the file to which the link points).
Based on the above I was expecting the following behavior for my example case: find starts the search. It encounters mylink. Since -L is in effect it dereferences it and gets the name of the pointed to file 'myfile'. The file name does not match the pattern 'mylink' and nothing is reported. Whats happening?
The name is not a property of the file, it's a property of the directory containing it.
If you want to match the contents of a symlink, use -lname.
The 'following of links' applies when there is a link to a directory.
A link to a file is just a file itself, to find. Without -L a link to a directory is also just a file.
Only when -L is added, will find recurse into the linked-to directory

Automatizing 'simplify path' for a svg-file (using inkscape)

I would like to automatize the inkscape command "simplify path". Concretely, I would like a command line tool which takes a svg-file as input, applies "simplify path" to all paths in the figure and saves a new (smaller) svg-file. Is this possible using inkscape? Is there a free command line tool (I'm using linux) which does the job?
UPDATE:
Since the question/answer is quite old the inkscape command line changed.
inkscape file.svg --batch-process --actions='EditSelectAll;SelectionSimplify;FileSave;FileClose'
Also see comment of Oren Ben-Kiki or Pix answer.
ORIG:
Should be possible:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine.html
shows how to call functions of inkscape (called "verbs") from the command line. To get a list of all verbs call inkscape --verb-list on commandline. What you are looking for is SelectionSimplify.
Therefore you have to write a small script that is filtering every id out of the svg and is calling inkscape with the ids. Something like this (optimize all pathes and quit from inkscape at the end)
inkscape filename.svg --verb=EditSelectAll --verb=SelectionSimplify --verb=FileSave --verb=FileClose --verb=FileQuit
Extending from Fabian's answer, to control the threshold of the simplification function, I found I needed to make a fake home directory with a minimal preferences file containing my desired threshold. Here is a simple script I just put together.
simplify.sh:
#!/bin/bash
FILENAME=$1
THRESHOLD=$2
FAKEHOME=$(mktemp -d)
mkdir -p $FAKEHOME/.config/inkscape
cat > $FAKEHOME/.config/inkscape/preferences.xml <<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<inkscape
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1">
<group
id="options">
<group
id="simplifythreshold"
value="${THRESHOLD}" />
</group>
</inkscape>
EOF
# for Inkscape < 1.0
#HOME=$FAKEHOME inkscape $FILENAME --verb=EditSelectAll --verb=SelectionSimplify --verb=FileSave --verb=FileClose
# for Inkscape > 1.0
HOME=$FAKEHOME inkscape --with-gui --batch-process $FILENAME --verb='EditSelectAll;SelectionSimplify;FileSave'
#rm -rf $FAKEHOME
Alternative to Inkscape
I've got much better results using SVGO (reduced a file from 2.7 MB to 350 KB).
You may use this online service for individual files: https://jakearchibald.github.io/svgomg/

Resources