4 # Script used to generate doc/book/config/cmdoptions.xml
5 # and hopefully other in the future.
7 # Updated by option handlind via --elinks=path/to/elinks option
10 # Utility functions {{{1
16 echo "`basename $0` ($script_version)" >&2
17 echo "Usage: $0 [ --cmdoptions | --elinksconf | - | --elinks=path/to/elinks ]" >&2
18 cat >&2 <<END_OF_USAGE
19 --cmdoptions Print asciidoc markup with summary of the command options
20 --elinksconf Print the elinks.conf.5 manpage
21 - Read option info (elinks --config-help) from stdin
22 --elinks=path Use the elinks program with the given path
27 # Option handling {{{1
35 # If the previous option needs an argument, assign it.
36 if test -n "$prev_option"; then
37 eval "$prev_option=\$option"
44 command="$elinks -long-help"
45 filter
="sed 0,/^Options:/d"
49 command="$elinks -config-help"
50 filter
="sed 0,/^Configuration/d"
54 command="cat /dev/stdin"
57 elinks
="`echo $option | sed -e 's/.*=//'`"
60 usage
"Unknown option"
65 if test -z "$backend";
67 usage
"No backend defined"
71 script_version
=`echo "\\$Revision: 1.19 $" | sed -e 's/\\$\(.*\) \\$/\1/'`
72 elinks_version
="`$elinks -version | head -n 1 | sed -e 's/ELinks \([0-9][^ ]*\).*/\1/'`"
73 script_info
="Generated by `basename $0` ($script_version) on $date_string"
74 script_info
="$script_info using output from ELinks version $elinks_version."
75 dist_info
="`basename $0` is distributed with ELinks under the terms of the GPL."
79 print_header
="print_${backend}_header"
80 print_footer
="print_${backend}_footer"
81 print_description_end
="print_${backend}_description_end"
82 print_description_line
="print_${backend}_description_line"
83 print_option_tree
="print_${backend}_option_tree"
84 print_option_type
="print_${backend}_option_type"
86 # --cmdoptions backend {{{2
88 print_cmdoptions_header
()
93 print_cmdoptions_footer
()
98 print_cmdoptions_description_end
()
103 print_cmdoptions_description_line
()
113 line
="$(echo $line | sed 's,\(-touch-files\|-no-connect\|-session-ring\|-dump\|-default-mime-type\|text/html\|~/\.elinks\),\`\1\`,g')"
114 line
=$
(echo $line |
sed "s,'\([^']*\)',\\\'\1\\\',")
115 line
=$
(echo $line |
sed "s,ELinks,'ELinks',g")
116 line
=$
(echo $line |
sed "s,HOME,'HOME',g")
117 line
="$(echo $line | sed 's/^\([a-zA-Z]*([^)]*)\).*:/- \`\1\`:/')"
119 if test -n "$number";
121 echo -n " - $number:"
127 print_cmdoptions_option_tree
()
132 print_cmdoptions_option_type
()
138 if test -n "$typeid" && test "$typeid" != "$path";
140 if test "$typeid" = "(alias";
142 typestring
="$typestring ($default)"
145 typestring
="$typestring $typeid"
148 if test -n "$default" && test "$default" != "$path";
150 typestring
="$typestring ($default)"
152 if test "$default" = "-?, -h, -help";
154 typestring
="$default"
159 # --elinksconf backend {{{2
161 print_elinksconf_header
()
168 .\" Copyleft (c) 2002-2004 The ELinks project
170 .\" This file may be distributed under the terms of the GNU
171 .\" General Public License. <www.gnu.org/licenses/gpl.html>
173 .\" Process this file with groff -man -Tascii elinks.conf.5
174 .TH ELINKS.CONF 5 "ELinks configuration file" "$date_string" "ELinks configuration file"
177 elinks.conf \- ELinks configuration file
183 file contains configuration information for ELinks. It can be used to configure
184 the behaviour of ELinks in a wide variety of ways: protocol behaviour,
185 keybindings, colors used for rendering and for the user interface.
187 It is read at startup and saved only when requested. All options described in
188 this document can be fully configured from within ELinks so no editing of
189 elinks.conf is needed.
191 Note that MIME-related options used for specifying handlers of various MIME
192 types are NOT described in this document. Documentation for these options can be
193 found at the ELinks homepage. Keybindings can also be specified in elinks.conf.
194 This is described in the elinkskeys(5) man page.
198 The syntax of the configuration file is very simple. The elinks.conf file is a
199 free-form ASCII text file. The file may contain extra tabs and newlines for
200 formatting purposes. Keywords in the file are case-sensitive. Comments may be
201 placed anywhere within the file (except within quotes). Comments begin with the
202 # character and end at the end of the line.
206 Some sample settings:
209 # Use asynchronous DNS resolver?
210 set connection.async_dns = 1
211 # horizontal text margin.
212 set document.browse.margin_width = 3
213 # Default document codepage.
214 set document.codepage.assume = "ISO-8859-1"
215 # User defined protocol handlers
216 set protocol.user.mailto.unix = "mutt %h -s \e\*(lq%s\e\*(rq"
224 print_elinksconf_footer
()
227 echo ".SH \"DOCUMENT INFO\""
231 echo ".SH \"SEE ALSO\""
232 echo ".BR elinks (1),"
233 echo ".BR elinkskeys (5)"
236 print_elinksconf_description_end
()
238 if test -n "$parse_int_option";
245 print_elinksconf_description_line
()
249 if test -n "$number";
251 if test "$parse_int_option" = "1";
265 print_elinksconf_option_tree
()
269 echo ".SS $title ($path)"
272 print_elinksconf_option_type
()
278 echo "\\f3$path\\f2 $typeid\\f1 ($default)"
290 $command |
$filter |
while read line
292 if test -n "$parse_description"
294 # If the line is empty it is our clue that
295 # the desciption is over.
298 $print_description_end
304 line
=`echo "$line" | sed -e "s/[ ]*(DISABLED)//"`
306 if test -n "$parse_int_option";
310 number
="`echo $line | sed -e 's/\(-[0-9-]*\).*/\1/'`"
311 line
=`echo "$line" | sed -e "s/$number[ ]*//"`
315 number
="`echo $line | sed -e 's/\([0-9-]*\).*/\1/'`"
316 line
=`echo "$line" | sed -e "s/$number[ ]*//"`
321 $print_description_line "$line" "$number"
330 title
="`echo $line | sed -e 's/\([A-Z]*\):.*/\1/'`"
331 path
="`echo $line | sed -e 's/.*: (\([a-z_].*\))/\1/'`"
332 $print_option_tree "$title" "$path"
337 path
="`echo $line | sed -e 's/\([a-z-][^ ]*\).*/\1/'`"
338 typeid
="`echo $line | sed -e 's/[ ]*[a-z-][^ ]* \([^ ]*\).*/\1/'`"
339 default
="`echo \"$line\" | sed -e 's/[^(]*(\(.*\))/\1/'`"
340 $print_option_type "$path" "$typeid" "$default"
341 if test "$typeid" = "<num>";
354 # vim: tabstop=4 shiftwidth=4