Skip to content

Commit ddb0947

Browse files
committed
Merge pull request asciidoc-py#26 from jghub/a2xfix
Modified the way the command string is constructed for calling the text-browsers
2 parents ec78e1c + c628b43 commit ddb0947

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

a2x.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@
4545
XSLTPROC = 'xsltproc'
4646
DBLATEX = 'dblatex' # pdf generation.
4747
FOP = 'fop' # pdf generation (--fop option).
48-
W3M = 'w3m' # text generation.
49-
LYNX = 'lynx' # text generation (if no w3m).
48+
W3M = 'w3m' # primary text file generator.
49+
LYNX = 'lynx' # alternate text file generator.
5050
XMLLINT = 'xmllint' # Set to '' to disable.
5151
EPUBCHECK = 'epubcheck' # Set to '' to disable.
5252
# External executable default options.
5353
ASCIIDOC_OPTS = ''
54+
BACKEND_OPTS = ''
5455
DBLATEX_OPTS = ''
5556
FOP_OPTS = ''
57+
LYNX_OPTS = '-dump'
58+
W3M_OPTS = '-dump -cols 70 -T text/html -no-graph'
5659
XSLTPROC_OPTS = ''
57-
BACKEND_OPTS = ''
5860

5961
######################################################################
6062
# End of configuration file parameters.
@@ -819,17 +821,17 @@ def to_text(self):
819821
shell('"%s" %s --conf-file "%s" -b html4 -a "a2x-format=%s" -o "%s" "%s"' %
820822
(self.asciidoc, self.asciidoc_opts, self.asciidoc_conf_file('text.conf'),
821823
self.format, html_file, self.asciidoc_file))
822-
shell('"%s" -dump "%s" > "%s"' %
823-
(LYNX, html_file, text_file))
824+
cmd = '"%s" %s "%s" > "%s"' % (LYNX, LYNX_OPTS, html_file, text_file)
825+
shell(cmd)
824826
else:
825827
# Use w3m(1).
826828
self.to_docbook()
827829
docbook_file = self.dst_path('.xml')
828830
opts = '%s --output "%s"' % (self.xsltproc_opts, html_file)
829831
exec_xsltproc(self.xsl_stylesheet(), docbook_file,
830832
self.destination_dir, opts)
831-
shell('"%s" -cols 70 -dump -T text/html -no-graph "%s" > "%s"' %
832-
(W3M, html_file, text_file))
833+
cmd = '"%s" %s "%s" > "%s"' % (W3M, W3M_OPTS, html_file, text_file)
834+
shell(cmd)
833835
if not self.keep_artifacts:
834836
shell_rm(html_file)
835837

doc/a2x.1.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ OPTIONS
4949

5050
*-b, --backend*='BACKEND'::
5151
'BACKEND' is the name of an installed backend plugin. When this
52-
option is specified 'a2x' attempts load a file name 'a2x-backend.py'
53-
from the 'BACKEND' plugin directory It then converts the
52+
option is specified 'a2x' attempts to load a file name 'a2x-backend.py'
53+
from the 'BACKEND' plugin directory. It then converts the
5454
'SOURCE_FILE' to a 'BACKEND' formatted output file using a global
5555
function defined in 'a2x-backend.py' called 'to_BACKEND'.
5656

@@ -75,8 +75,10 @@ OPTIONS
7575
Do not delete temporary build files.
7676

7777
*--lynx*::
78-
Use 'lynx(1)' to generate text formatted output. The default
79-
behavior is to use 'w3m(1)'.
78+
Use 'lynx(1)' (actually: the text-based browser defined by the `LYNX` config
79+
variable) when generating text formatted output. The default behavior is to
80+
use 'w3m(1)' (actually: the text-based browser defined by the `W3M` config
81+
variable).
8082

8183
*-L, --no-xmllint*::
8284
Do not check asciidoc output with 'xmllint(1)'.
@@ -323,17 +325,28 @@ ASCIIDOC = 'asciidoc'
323325
XSLTPROC = 'xsltproc'
324326
DBLATEX = 'dblatex' # pdf generation.
325327
FOP = 'fop' # pdf generation (--fop option).
326-
W3M = 'w3m' # text generation.
327-
LYNX = 'lynx' # text generation (if no w3m).
328+
W3M = 'w3m' # primary text file generator.
329+
LYNX = 'lynx' # alternate text file generator.
328330
XMLLINT = 'xmllint' # Set to '' to disable.
329331
EPUBCHECK = 'epubcheck' # Set to '' to disable.
330332
# External executable default options.
331333
ASCIIDOC_OPTS = ''
334+
BACKEND_OPTS = ''
332335
DBLATEX_OPTS = ''
333336
FOP_OPTS = ''
337+
LYNX_OPTS = '-dump'
338+
W3M_OPTS = '-dump -cols 70 -T text/html -no-graph'
334339
XSLTPROC_OPTS = ''
335340
---------------------------------------------------------------------
336341

342+
Note, that it is possible to redefine `W3M` and `LYNX` to use different text-based
343+
browsers, e.g. 'links': http://links.twibright.com/ or
344+
'elinks': http://elinks.or.cz/. `LYNX_OPTS` and `W3M_OPTS` can be used to pass
345+
options to the selected browser. If these are defined they override the
346+
respective defaults listed above (so don't forget to include the '-dump' option
347+
in your definition: this is mandatory at least with 'w3m', 'lynx', 'links', and
348+
'elinks' in order to send the formatted text to stdout).
349+
337350

338351
BUGS
339352
----

0 commit comments

Comments
 (0)