mizuho 0.9.6 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -2
- data/Rakefile +0 -37
- data/asciidoc/BUGS +9 -18
- data/asciidoc/BUGS.txt +5 -14
- data/asciidoc/CHANGELOG +1433 -266
- data/asciidoc/CHANGELOG.txt +2821 -1810
- data/asciidoc/COPYING +339 -339
- data/asciidoc/COPYRIGHT +18 -18
- data/asciidoc/INSTALL +189 -30
- data/asciidoc/INSTALL.txt +175 -19
- data/asciidoc/MANIFEST +88 -0
- data/asciidoc/Makefile.in +29 -13
- data/asciidoc/README +16 -17
- data/asciidoc/README.txt +35 -36
- data/asciidoc/a2x.py +902 -0
- data/asciidoc/asciidoc.conf +610 -455
- data/asciidoc/asciidoc.py +1965 -1061
- data/asciidoc/asciidocapi.py +257 -0
- data/asciidoc/common.aap +2 -2
- data/asciidoc/configure +1170 -1023
- data/asciidoc/configure.ac +1 -1
- data/asciidoc/dblatex/asciidoc-dblatex.xsl +42 -0
- data/asciidoc/doc/a2x.1 +559 -102
- data/asciidoc/doc/a2x.1.txt +233 -91
- data/asciidoc/doc/article-docinfo.xml +87 -0
- data/asciidoc/doc/article.pdf +0 -0
- data/asciidoc/doc/article.txt +139 -122
- data/asciidoc/doc/asciidoc.1 +157 -46
- data/asciidoc/doc/asciidoc.1.txt +171 -118
- data/asciidoc/doc/asciidoc.conf +7 -8
- data/asciidoc/doc/asciidoc.dict +960 -635
- data/asciidoc/doc/asciidoc.txt +2335 -1464
- data/asciidoc/doc/asciidocapi.txt +189 -0
- data/asciidoc/doc/asciimathml.txt +14 -17
- data/asciidoc/doc/book-multi.txt +181 -155
- data/asciidoc/doc/book.epub +0 -0
- data/asciidoc/doc/book.txt +156 -131
- data/asciidoc/doc/customers.csv +18 -18
- data/asciidoc/doc/epub-notes.txt +210 -0
- data/asciidoc/doc/faq.txt +1122 -547
- data/asciidoc/doc/latex-backend.txt +192 -191
- data/asciidoc/doc/latex-bugs.txt +134 -0
- data/asciidoc/doc/latex-filter.pdf +0 -0
- data/asciidoc/doc/latex-filter.txt +196 -0
- data/asciidoc/doc/latexmath.txt +13 -136
- data/asciidoc/doc/latexmathml.txt +2 -2
- data/asciidoc/doc/main.aap +233 -297
- data/asciidoc/doc/music-filter.pdf +0 -0
- data/asciidoc/doc/music-filter.txt +55 -65
- data/asciidoc/doc/publishing-ebooks-with-asciidoc.txt +398 -0
- data/asciidoc/doc/slidy-example.txt +167 -0
- data/asciidoc/doc/slidy.txt +113 -0
- data/asciidoc/doc/source-highlight-filter.pdf +0 -0
- data/asciidoc/doc/source-highlight-filter.txt +45 -20
- data/asciidoc/doc/testasciidoc.txt +231 -0
- data/asciidoc/docbook-xsl/asciidoc-docbook-xsl.txt +30 -8
- data/asciidoc/docbook-xsl/chunked.xsl +17 -19
- data/asciidoc/docbook-xsl/common.xsl +106 -67
- data/asciidoc/docbook-xsl/epub.xsl +35 -0
- data/asciidoc/docbook-xsl/fo.xsl +3 -0
- data/asciidoc/docbook-xsl/htmlhelp.xsl +16 -17
- data/asciidoc/docbook-xsl/manpage.xsl +31 -31
- data/asciidoc/docbook-xsl/text.xsl +6 -1
- data/asciidoc/docbook-xsl/xhtml.xsl +14 -14
- data/asciidoc/docbook45.conf +759 -0
- data/asciidoc/filters/code/code-filter-readme.txt +37 -37
- data/asciidoc/filters/code/code-filter-test.txt +15 -15
- data/asciidoc/filters/code/code-filter.conf +8 -8
- data/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt +104 -64
- data/asciidoc/filters/graphviz/graphviz-filter.conf +20 -16
- data/asciidoc/filters/graphviz/graphviz2png.py +54 -39
- data/asciidoc/filters/latex/latex-filter.conf +18 -0
- data/asciidoc/filters/latex/latex2png.py +216 -0
- data/asciidoc/filters/music/music-filter.conf +8 -17
- data/asciidoc/filters/music/music2png.py +40 -32
- data/asciidoc/filters/source/source-highlight-filter.conf +40 -34
- data/asciidoc/help.conf +261 -96
- data/asciidoc/html4.conf +505 -460
- data/asciidoc/html5.conf +686 -0
- data/asciidoc/images/highlighter.png +0 -0
- data/asciidoc/images/icons/caution.png +0 -0
- data/asciidoc/images/icons/example.png +0 -0
- data/asciidoc/images/icons/important.png +0 -0
- data/asciidoc/images/icons/note.png +0 -0
- data/asciidoc/images/icons/tip.png +0 -0
- data/asciidoc/images/icons/warning.png +0 -0
- data/asciidoc/images/smallnew.png +0 -0
- data/asciidoc/javascripts/asciidoc.js +189 -0
- data/asciidoc/javascripts/slidy.js +2845 -0
- data/asciidoc/javascripts/toc.js +8 -0
- data/asciidoc/lang-de.conf +57 -0
- data/asciidoc/lang-en.conf +54 -0
- data/asciidoc/lang-es.conf +49 -9
- data/asciidoc/lang-fr.conf +59 -0
- data/asciidoc/lang-hu.conf +55 -0
- data/asciidoc/lang-it.conf +55 -0
- data/asciidoc/lang-nl.conf +57 -0
- data/asciidoc/lang-pt-BR.conf +56 -0
- data/asciidoc/lang-ru.conf +60 -0
- data/asciidoc/lang-uk.conf +60 -0
- data/asciidoc/latex.conf +700 -663
- data/asciidoc/main.aap +77 -0
- data/asciidoc/slidy.conf +136 -0
- data/asciidoc/{examples/website/xhtml11-manpage.css → stylesheets/asciidoc-manpage.css} +1 -1
- data/asciidoc/stylesheets/asciidoc.css +508 -0
- data/asciidoc/stylesheets/docbook-xsl.css +322 -272
- data/asciidoc/stylesheets/flask-manpage.css +1 -0
- data/asciidoc/stylesheets/flask.css +584 -0
- data/asciidoc/stylesheets/pygments.css +66 -0
- data/asciidoc/stylesheets/slidy.css +445 -0
- data/asciidoc/stylesheets/toc2.css +33 -0
- data/asciidoc/stylesheets/volnitsky-manpage.css +1 -0
- data/asciidoc/stylesheets/volnitsky.css +435 -0
- data/asciidoc/stylesheets/xhtml11-quirks.css +5 -3
- data/asciidoc/tests/asciidocapi.py +257 -0
- data/asciidoc/tests/data/deprecated-quotes.txt +12 -0
- data/asciidoc/tests/data/filters-test.txt +90 -0
- data/asciidoc/tests/data/lang-de-test.txt +106 -0
- data/asciidoc/tests/data/lang-en-test.txt +114 -0
- data/asciidoc/tests/data/lang-es-test.txt +106 -0
- data/asciidoc/tests/data/lang-fr-test.txt +106 -0
- data/asciidoc/tests/data/lang-hu-test.txt +106 -0
- data/asciidoc/tests/data/lang-nl-test.txt +94 -0
- data/asciidoc/tests/data/lang-pt-BR-test.txt +106 -0
- data/asciidoc/tests/data/lang-ru-test.txt +106 -0
- data/asciidoc/tests/data/lang-uk-test.txt +106 -0
- data/asciidoc/tests/data/oldtables.txt +64 -0
- data/asciidoc/tests/data/rcs-id-marker-test.txt +6 -0
- data/asciidoc/tests/data/testcases.conf +2 -0
- data/asciidoc/tests/data/testcases.txt +740 -0
- data/asciidoc/tests/data/utf8-bom-test.txt +9 -0
- data/asciidoc/tests/data/utf8-examples.txt +217 -0
- data/asciidoc/tests/testasciidoc.conf +520 -0
- data/asciidoc/tests/testasciidoc.py +411 -0
- data/asciidoc/text.conf +16 -16
- data/asciidoc/vim/syntax/asciidoc.vim +99 -91
- data/asciidoc/wordpress.conf +43 -3
- data/asciidoc/xhtml11-quirks.conf +61 -57
- data/asciidoc/xhtml11.conf +684 -645
- data/lib/mizuho.rb +2 -0
- data/lib/mizuho/generator.rb +2 -2
- data/test/generator_spec.rb +1 -1
- data/test/parser_spec.rb +1 -1
- data/test/spec_helper.rb +3 -4
- metadata +87 -88
- data/asciidoc/a2x +0 -674
- data/asciidoc/doc/article.css-embedded.html +0 -602
- data/asciidoc/doc/article.html +0 -46
- data/asciidoc/doc/asciidoc-revhistory.xml +0 -27
- data/asciidoc/doc/asciidoc.1.css-embedded.html +0 -598
- data/asciidoc/doc/asciidoc.1.css.html +0 -212
- data/asciidoc/doc/asciidoc.1.html +0 -190
- data/asciidoc/doc/asciidoc.css-embedded.html +0 -7853
- data/asciidoc/doc/asciidoc.css.html +0 -7416
- data/asciidoc/doc/asciidoc.html +0 -3339
- data/asciidoc/doc/book-multi.css-embedded.html +0 -575
- data/asciidoc/doc/book-multi.html +0 -55
- data/asciidoc/doc/book.css-embedded.html +0 -607
- data/asciidoc/doc/book.html +0 -43
- data/asciidoc/doc/docbook-xsl.css +0 -272
- data/asciidoc/doc/latex-backend.html +0 -117
- data/asciidoc/doc/music-filter.html +0 -566
- data/asciidoc/doc/source-highlight-filter.html +0 -214
- data/asciidoc/docbook.conf +0 -721
- data/asciidoc/examples/website/ASCIIMathML.js +0 -938
- data/asciidoc/examples/website/CHANGELOG.html +0 -4389
- data/asciidoc/examples/website/CHANGELOG.txt +0 -1810
- data/asciidoc/examples/website/INSTALL.html +0 -161
- data/asciidoc/examples/website/INSTALL.txt +0 -71
- data/asciidoc/examples/website/LaTeXMathML.js +0 -1223
- data/asciidoc/examples/website/README-website.html +0 -118
- data/asciidoc/examples/website/README-website.txt +0 -29
- data/asciidoc/examples/website/README.html +0 -125
- data/asciidoc/examples/website/README.txt +0 -36
- data/asciidoc/examples/website/a2x.1.html +0 -419
- data/asciidoc/examples/website/a2x.1.txt +0 -204
- data/asciidoc/examples/website/asciidoc-docbook-xsl.html +0 -130
- data/asciidoc/examples/website/asciidoc-docbook-xsl.txt +0 -43
- data/asciidoc/examples/website/asciidoc-graphviz-sample.txt +0 -130
- data/asciidoc/examples/website/asciimathml.txt +0 -64
- data/asciidoc/examples/website/build-website.sh +0 -25
- data/asciidoc/examples/website/customers.csv +0 -18
- data/asciidoc/examples/website/downloads.html +0 -257
- data/asciidoc/examples/website/downloads.txt +0 -121
- data/asciidoc/examples/website/faq.html +0 -673
- data/asciidoc/examples/website/faq.txt +0 -547
- data/asciidoc/examples/website/index.html +0 -419
- data/asciidoc/examples/website/index.txt +0 -245
- data/asciidoc/examples/website/latex-backend.html +0 -535
- data/asciidoc/examples/website/latex-backend.txt +0 -191
- data/asciidoc/examples/website/latexmathml.txt +0 -41
- data/asciidoc/examples/website/layout1.conf +0 -161
- data/asciidoc/examples/website/layout1.css +0 -65
- data/asciidoc/examples/website/layout2.conf +0 -158
- data/asciidoc/examples/website/layout2.css +0 -93
- data/asciidoc/examples/website/manpage.html +0 -266
- data/asciidoc/examples/website/manpage.txt +0 -118
- data/asciidoc/examples/website/music-filter.html +0 -242
- data/asciidoc/examples/website/music-filter.txt +0 -158
- data/asciidoc/examples/website/music1.abc +0 -12
- data/asciidoc/examples/website/music1.png +0 -0
- data/asciidoc/examples/website/music2.ly +0 -9
- data/asciidoc/examples/website/music2.png +0 -0
- data/asciidoc/examples/website/newlists.txt +0 -40
- data/asciidoc/examples/website/newtables.txt +0 -397
- data/asciidoc/examples/website/sample1.png +0 -0
- data/asciidoc/examples/website/sample3.png +0 -0
- data/asciidoc/examples/website/sample4.png +0 -0
- data/asciidoc/examples/website/source-highlight-filter.html +0 -286
- data/asciidoc/examples/website/source-highlight-filter.txt +0 -203
- data/asciidoc/examples/website/support.html +0 -78
- data/asciidoc/examples/website/support.txt +0 -5
- data/asciidoc/examples/website/toc.js +0 -69
- data/asciidoc/examples/website/userguide.html +0 -7460
- data/asciidoc/examples/website/userguide.txt +0 -4979
- data/asciidoc/examples/website/version83.txt +0 -37
- data/asciidoc/examples/website/version9.html +0 -143
- data/asciidoc/examples/website/version9.txt +0 -48
- data/asciidoc/examples/website/xhtml11-quirks.css +0 -41
- data/asciidoc/examples/website/xhtml11.css +0 -328
- data/asciidoc/stylesheets/xhtml11-manpage.css +0 -18
- data/asciidoc/stylesheets/xhtml11.css +0 -328
data/asciidoc/MANIFEST
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
a2x.py
|
2
|
+
asciidoc.py
|
3
|
+
asciidocapi.py
|
4
|
+
BUGS
|
5
|
+
BUGS.txt
|
6
|
+
MANIFEST
|
7
|
+
main.aap
|
8
|
+
common.aap
|
9
|
+
CHANGELOG
|
10
|
+
CHANGELOG.txt
|
11
|
+
asciidoc.conf
|
12
|
+
docbook45.conf
|
13
|
+
help.conf
|
14
|
+
html4.conf
|
15
|
+
html5.conf
|
16
|
+
lang-*.conf
|
17
|
+
latex.conf
|
18
|
+
slidy.conf
|
19
|
+
text.conf
|
20
|
+
wordpress.conf
|
21
|
+
xhtml11.conf
|
22
|
+
xhtml11-quirks.conf
|
23
|
+
COPYING
|
24
|
+
COPYRIGHT
|
25
|
+
dblatex/asciidoc-dblatex.sty
|
26
|
+
dblatex/asciidoc-dblatex.xsl
|
27
|
+
dblatex/dblatex-readme.txt
|
28
|
+
doc/a2x.1
|
29
|
+
doc/book.epub
|
30
|
+
doc/asciidoc.1
|
31
|
+
doc/asciidoc.conf
|
32
|
+
doc/article-docinfo.xml
|
33
|
+
doc/customers.csv
|
34
|
+
doc/images/
|
35
|
+
doc/main.aap
|
36
|
+
doc/article.pdf
|
37
|
+
doc/latex-filter.pdf
|
38
|
+
doc/music-filter.pdf
|
39
|
+
doc/source-highlight-filter.pdf
|
40
|
+
doc/*.txt
|
41
|
+
doc/asciidoc.dict
|
42
|
+
docbook-xsl/*.txt
|
43
|
+
docbook-xsl/*.xsl
|
44
|
+
examples/website/main.aap
|
45
|
+
examples/website/build-website.sh
|
46
|
+
examples/website/*.css
|
47
|
+
examples/website/*.js
|
48
|
+
examples/website/customers.csv
|
49
|
+
examples/website/images/
|
50
|
+
examples/website/layout?.conf
|
51
|
+
examples/website/*.txt
|
52
|
+
filters/code/code-filter.conf
|
53
|
+
filters/code/code-filter.py
|
54
|
+
filters/code/code-filter-readme.txt
|
55
|
+
filters/code/code-filter-test.txt
|
56
|
+
filters/latex/latex2png.py
|
57
|
+
filters/latex/latex-filter.conf
|
58
|
+
filters/music/music-filter.conf
|
59
|
+
filters/music/music2png.py
|
60
|
+
filters/music/music-filter-test.txt
|
61
|
+
filters/source/source-highlight-filter.conf
|
62
|
+
filters/source/source-highlight-filter-test.txt
|
63
|
+
filters/graphviz/graphviz-filter.conf
|
64
|
+
filters/graphviz/graphviz2png.py
|
65
|
+
filters/graphviz/asciidoc-graphviz-sample.txt
|
66
|
+
images/icons/callouts/*.png
|
67
|
+
images/icons/*.png
|
68
|
+
images/icons/README
|
69
|
+
images/smallnew.png
|
70
|
+
images/tiger.png
|
71
|
+
images/highlighter.png
|
72
|
+
INSTALL
|
73
|
+
INSTALL.txt
|
74
|
+
configure
|
75
|
+
configure.ac
|
76
|
+
Makefile.in
|
77
|
+
install-sh
|
78
|
+
javascripts/*.js
|
79
|
+
README
|
80
|
+
README.txt
|
81
|
+
stylesheets/*.css
|
82
|
+
tests/testasciidoc.py
|
83
|
+
tests/testasciidoc.conf
|
84
|
+
tests/asciidocapi.py
|
85
|
+
tests/data/*.conf
|
86
|
+
tests/data/*.txt
|
87
|
+
vim/syntax/asciidoc.vim
|
88
|
+
vim/ftdetect/asciidoc_filetype.vim
|
data/asciidoc/Makefile.in
CHANGED
@@ -7,13 +7,14 @@
|
|
7
7
|
INSTALL = @INSTALL@
|
8
8
|
INSTALL_PROG = @INSTALL_PROGRAM@
|
9
9
|
INSTALL_DATA = @INSTALL_DATA@
|
10
|
-
|
10
|
+
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
11
11
|
SED = @SED@
|
12
12
|
|
13
13
|
prefix = @prefix@
|
14
14
|
exec_prefix = @exec_prefix@
|
15
15
|
bindir = @bindir@
|
16
16
|
datadir = @datadir@
|
17
|
+
docdir = @docdir@
|
17
18
|
sysconfdir = @sysconfdir@
|
18
19
|
datarootdir = @datarootdir@
|
19
20
|
mandir=@mandir@
|
@@ -23,12 +24,12 @@ VPATH = @srcdir@
|
|
23
24
|
|
24
25
|
ASCIIDOCCONF = $(sysconfdir)/asciidoc
|
25
26
|
|
26
|
-
prog = asciidoc.py a2x
|
27
|
+
prog = asciidoc.py a2x.py
|
27
28
|
progdir = $(bindir)
|
28
29
|
|
29
30
|
vimdir = @sysconfdir@/vim
|
30
31
|
|
31
|
-
manp = $(wildcard doc/*.1)
|
32
|
+
manp = $(patsubst %1.txt,%1,$(wildcard doc/*.1.txt))
|
32
33
|
manpdir = $(mandir)/man1
|
33
34
|
|
34
35
|
conf = $(wildcard *.conf)
|
@@ -54,6 +55,11 @@ musicfilterconfdir = $(filtersdir)/music
|
|
54
55
|
sourcefilterconf = filters/source/source-highlight-filter.conf
|
55
56
|
sourcefilterconfdir = $(filtersdir)/source
|
56
57
|
|
58
|
+
latexfilter = filters/latex/latex2png.py
|
59
|
+
latexfilterdir = $(filtersdir)/latex
|
60
|
+
latexfilterconf = filters/latex/latex-filter.conf
|
61
|
+
latexfilterconfdir = $(filtersdir)/latex
|
62
|
+
|
57
63
|
docbook = $(wildcard docbook-xsl/*.xsl)
|
58
64
|
docbookdir = $(ASCIIDOCCONF)/docbook-xsl
|
59
65
|
|
@@ -73,10 +79,9 @@ icons = $(wildcard images/icons/*.png) images/icons/README
|
|
73
79
|
iconsdir = $(ASCIIDOCCONF)/images/icons
|
74
80
|
|
75
81
|
doc = $(wildcard README*) $(wildcard BUGS*) $(wildcard INSTALL*) $(wildcard CHANGELOG*)
|
76
|
-
docdir = $(datadir)/doc/asciidoc
|
77
82
|
|
78
|
-
DATATARGETS = manp conf docbook dblatex css js callouts icons codefilterconf musicfilterconf sourcefilterconf graphvizfilterconf
|
79
|
-
PROGTARGETS = prog codefilter musicfilter graphvizfilter
|
83
|
+
DATATARGETS = manp conf docbook dblatex css js callouts icons codefilterconf musicfilterconf sourcefilterconf graphvizfilterconf latexfilterconf
|
84
|
+
PROGTARGETS = prog codefilter musicfilter graphvizfilter latexfilter
|
80
85
|
TARGETS = $(DATATARGETS) $(PROGTARGETS) doc
|
81
86
|
|
82
87
|
INSTDIRS = $(TARGETS:%=%dir)
|
@@ -95,6 +100,9 @@ $(PROGTARGETS): % : %dir
|
|
95
100
|
$(DATATARGETS): % : %dir
|
96
101
|
$(INSTALL_DATA) $($@) $(DESTDIR)/$($<)/
|
97
102
|
|
103
|
+
$(manp): %.1 : %.1.txt
|
104
|
+
python a2x.py -f manpage $<
|
105
|
+
|
98
106
|
docs:
|
99
107
|
$(INSTALL) -d $(DESTDIR)/$(docdir)
|
100
108
|
$(INSTALL_DATA) $(doc) $(DESTDIR)/$(docdir)
|
@@ -116,14 +124,16 @@ docs:
|
|
116
124
|
( cd examples/website && \
|
117
125
|
cp -R * $(DESTDIR)/$(docdir)/examples/website )
|
118
126
|
|
119
|
-
|
120
|
-
(cd $(DESTDIR)/$(progdir);
|
127
|
+
progsymlink:
|
128
|
+
(cd $(DESTDIR)/$(progdir); ln -sf asciidoc.py asciidoc)
|
129
|
+
(cd $(DESTDIR)/$(progdir); ln -sf a2x.py a2x)
|
121
130
|
|
122
131
|
fixconfpath:
|
123
132
|
@for f in $(prog); do \
|
124
133
|
echo "Fixing CONF_DIR in $$f"; \
|
125
|
-
$(SED) "s#^CONF_DIR = '.*'#CONF_DIR = '$(ASCIIDOCCONF)'
|
134
|
+
$(SED) "s#^CONF_DIR = '.*'#CONF_DIR = '$(ASCIIDOCCONF)'#" $$f > $$f.out; \
|
126
135
|
mv $$f.out $$f; \
|
136
|
+
chmod +x $$f; \
|
127
137
|
done
|
128
138
|
|
129
139
|
install-vim:
|
@@ -145,17 +155,23 @@ uninstall-vim:
|
|
145
155
|
done
|
146
156
|
|
147
157
|
|
148
|
-
build: fixconfpath
|
158
|
+
build: fixconfpath $(manp)
|
149
159
|
|
150
|
-
|
160
|
+
|
161
|
+
install: all $(PROGTARGETS) $(DATATARGETS) progsymlink install-vim
|
151
162
|
|
152
163
|
uninstall: uninstall-vim
|
153
164
|
rm -f $(DESTDIR)/$(progdir)/asciidoc
|
165
|
+
rm -f $(DESTDIR)/$(progdir)/asciidoc.py
|
154
166
|
rm -f $(DESTDIR)/$(progdir)/a2x
|
155
|
-
rm -f $(DESTDIR)/$(
|
156
|
-
rm -f $(DESTDIR)/$(
|
167
|
+
rm -f $(DESTDIR)/$(progdir)/a2x.py
|
168
|
+
rm -f $(DESTDIR)/$(manpdir)/asciidoc.1
|
169
|
+
rm -f $(DESTDIR)/$(manpdir)/a2x.1
|
157
170
|
rm -rf $(DESTDIR)/$(confdir)
|
158
171
|
rm -rf $(DESTDIR)/$(docdir)
|
159
172
|
|
173
|
+
clean:
|
174
|
+
rm -f $(manp)
|
175
|
+
|
160
176
|
test:
|
161
177
|
@echo "Nothing to see here...Move along."
|
data/asciidoc/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
AsciiDoc README File
|
2
2
|
|
3
|
-
version 8.
|
3
|
+
version 8.6.5, 20 May 2011
|
4
4
|
__________________________________________________________________
|
5
5
|
|
6
6
|
1. Prerequisites
|
@@ -13,34 +13,33 @@
|
|
13
13
|
|
14
14
|
2. Obtaining AsciiDoc
|
15
15
|
|
16
|
-
|
17
|
-
[2]http://www.methods.co.nz/asciidoc/
|
18
|
-
[3]http://sourceforge.net/projects/asciidoc/.
|
16
|
+
Documentation and installation instructions are on the AsciiDoc website
|
17
|
+
[2]http://www.methods.co.nz/asciidoc/
|
19
18
|
__________________________________________________________________
|
20
19
|
|
21
20
|
3. Tools
|
22
21
|
|
23
|
-
Current AsciiDoc version tested on Xubuntu Linux
|
24
|
-
* Python 2.5
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
* dblatex 0.2.9
|
22
|
+
Current AsciiDoc version tested on Xubuntu Linux 10.04 with:
|
23
|
+
* Python 2.6.5
|
24
|
+
* DocBook XSL Stylesheets 1.76.1
|
25
|
+
* xsltproc (libxml 20706, libxslt 10126 and libexslt 815).
|
26
|
+
* w3m 0.5.2
|
27
|
+
* dblatex 0.3
|
30
28
|
* FOP 0.95
|
29
|
+
* A-A-P 1.091
|
31
30
|
__________________________________________________________________
|
32
31
|
|
33
|
-
4.
|
32
|
+
4. Copying
|
34
33
|
|
35
|
-
Copyright
|
36
|
-
granted under the terms of the GNU General Public License
|
34
|
+
Copyright © 2002-2011 Stuart Rackham. Free use of this software is
|
35
|
+
granted under the terms of the GNU General Public License version 2
|
36
|
+
(GPLv2).
|
37
37
|
__________________________________________________________________
|
38
38
|
|
39
|
-
Version 8.
|
40
|
-
Last updated
|
39
|
+
Version 8.6.5
|
40
|
+
Last updated 2011-05-04 18:47:58 NZST
|
41
41
|
|
42
42
|
References
|
43
43
|
|
44
44
|
1. http://www.python.org/
|
45
45
|
2. http://www.methods.co.nz/asciidoc/
|
46
|
-
3. http://sourceforge.net/projects/asciidoc/
|
data/asciidoc/README.txt
CHANGED
@@ -1,36 +1,35 @@
|
|
1
|
-
AsciiDoc README File
|
2
|
-
====================
|
3
|
-
|
4
|
-
Prerequisites
|
5
|
-
-------------
|
6
|
-
AsciiDoc is written in Python so you need a Python interpreter
|
7
|
-
(version 2.4 or later) to execute asciidoc(1). Python is installed by
|
8
|
-
default in most Linux distributions. You can download Python from the
|
9
|
-
official Python website http://www.python.org.
|
10
|
-
|
11
|
-
|
12
|
-
Obtaining AsciiDoc
|
13
|
-
------------------
|
14
|
-
|
15
|
-
http://www.methods.co.nz/asciidoc/
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
AsciiDoc README File
|
2
|
+
====================
|
3
|
+
|
4
|
+
Prerequisites
|
5
|
+
-------------
|
6
|
+
AsciiDoc is written in Python so you need a Python interpreter
|
7
|
+
(version 2.4 or later) to execute asciidoc(1). Python is installed by
|
8
|
+
default in most Linux distributions. You can download Python from the
|
9
|
+
official Python website http://www.python.org.
|
10
|
+
|
11
|
+
|
12
|
+
Obtaining AsciiDoc
|
13
|
+
------------------
|
14
|
+
Documentation and installation instructions are on the AsciiDoc
|
15
|
+
website http://www.methods.co.nz/asciidoc/
|
16
|
+
|
17
|
+
|
18
|
+
Tools
|
19
|
+
-----
|
20
|
+
Current AsciiDoc version tested on Xubuntu Linux 10.04 with:
|
21
|
+
|
22
|
+
- Python 2.6.5
|
23
|
+
- DocBook XSL Stylesheets 1.76.1
|
24
|
+
- xsltproc (libxml 20706, libxslt 10126 and libexslt 815).
|
25
|
+
- w3m 0.5.2
|
26
|
+
- dblatex 0.3
|
27
|
+
- FOP 0.95
|
28
|
+
- A-A-P 1.091
|
29
|
+
|
30
|
+
|
31
|
+
Copying
|
32
|
+
-------
|
33
|
+
Copyright (C) 2002-2011 Stuart Rackham. Free use of this software is
|
34
|
+
granted under the terms of the GNU General Public License version 2
|
35
|
+
(GPLv2).
|
data/asciidoc/a2x.py
ADDED
@@ -0,0 +1,902 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
'''
|
3
|
+
a2x - A toolchain manager for AsciiDoc (converts Asciidoc text files to other
|
4
|
+
file formats)
|
5
|
+
|
6
|
+
Copyright: Stuart Rackham (c) 2009
|
7
|
+
License: MIT
|
8
|
+
Email: srackham@gmail.com
|
9
|
+
|
10
|
+
'''
|
11
|
+
|
12
|
+
import os
|
13
|
+
import fnmatch
|
14
|
+
import HTMLParser
|
15
|
+
import re
|
16
|
+
import shutil
|
17
|
+
import subprocess
|
18
|
+
import sys
|
19
|
+
import traceback
|
20
|
+
import urlparse
|
21
|
+
import zipfile
|
22
|
+
import xml.dom.minidom
|
23
|
+
import mimetypes
|
24
|
+
|
25
|
+
PROG = os.path.basename(os.path.splitext(__file__)[0])
|
26
|
+
VERSION = '8.6.5'
|
27
|
+
|
28
|
+
# AsciiDoc global configuration file directory.
|
29
|
+
# NOTE: CONF_DIR is "fixed up" by Makefile -- don't rename or change syntax.
|
30
|
+
CONF_DIR = '/etc/asciidoc'
|
31
|
+
|
32
|
+
|
33
|
+
######################################################################
|
34
|
+
# Default configuration file parameters.
|
35
|
+
######################################################################
|
36
|
+
|
37
|
+
# Optional environment variable dictionary passed to
|
38
|
+
# executing programs. If set to None the existing
|
39
|
+
# environment is used.
|
40
|
+
ENV = None
|
41
|
+
|
42
|
+
# External executables.
|
43
|
+
ASCIIDOC = 'asciidoc'
|
44
|
+
XSLTPROC = 'xsltproc'
|
45
|
+
DBLATEX = 'dblatex' # pdf generation.
|
46
|
+
FOP = 'fop' # pdf generation (--fop option).
|
47
|
+
W3M = 'w3m' # text generation.
|
48
|
+
LYNX = 'lynx' # text generation (if no w3m).
|
49
|
+
XMLLINT = 'xmllint' # Set to '' to disable.
|
50
|
+
EPUBCHECK = 'epubcheck' # Set to '' to disable.
|
51
|
+
# External executable default options.
|
52
|
+
ASCIIDOC_OPTS = ''
|
53
|
+
DBLATEX_OPTS = ''
|
54
|
+
FOP_OPTS = ''
|
55
|
+
XSLTPROC_OPTS = ''
|
56
|
+
|
57
|
+
######################################################################
|
58
|
+
# End of configuration file parameters.
|
59
|
+
######################################################################
|
60
|
+
|
61
|
+
|
62
|
+
#####################################################################
|
63
|
+
# Utility functions
|
64
|
+
#####################################################################
|
65
|
+
|
66
|
+
OPTIONS = None # These functions read verbose and dry_run command options.
|
67
|
+
|
68
|
+
def errmsg(msg):
|
69
|
+
sys.stderr.write('%s: %s\n' % (PROG,msg))
|
70
|
+
|
71
|
+
def warning(msg):
|
72
|
+
errmsg('WARNING: %s' % msg)
|
73
|
+
|
74
|
+
def infomsg(msg):
|
75
|
+
print '%s: %s' % (PROG,msg)
|
76
|
+
|
77
|
+
def die(msg, exit_code=1):
|
78
|
+
errmsg('ERROR: %s' % msg)
|
79
|
+
sys.exit(exit_code)
|
80
|
+
|
81
|
+
def trace():
|
82
|
+
"""Print traceback to stderr."""
|
83
|
+
errmsg('-'*60)
|
84
|
+
traceback.print_exc(file=sys.stderr)
|
85
|
+
errmsg('-'*60)
|
86
|
+
|
87
|
+
def verbose(msg):
|
88
|
+
if OPTIONS.verbose or OPTIONS.dry_run:
|
89
|
+
infomsg(msg)
|
90
|
+
|
91
|
+
class AttrDict(dict):
|
92
|
+
"""
|
93
|
+
Like a dictionary except values can be accessed as attributes i.e. obj.foo
|
94
|
+
can be used in addition to obj['foo'].
|
95
|
+
If self._default has been set then it will be returned if a non-existant
|
96
|
+
attribute is accessed (instead of raising an AttributeError).
|
97
|
+
"""
|
98
|
+
def __getattr__(self, key):
|
99
|
+
try:
|
100
|
+
return self[key]
|
101
|
+
except KeyError, k:
|
102
|
+
if self.has_key('_default'):
|
103
|
+
return self['_default']
|
104
|
+
else:
|
105
|
+
raise AttributeError, k
|
106
|
+
def __setattr__(self, key, value):
|
107
|
+
self[key] = value
|
108
|
+
def __delattr__(self, key):
|
109
|
+
try: del self[key]
|
110
|
+
except KeyError, k: raise AttributeError, k
|
111
|
+
def __repr__(self):
|
112
|
+
return '<AttrDict ' + dict.__repr__(self) + '>'
|
113
|
+
def __getstate__(self):
|
114
|
+
return dict(self)
|
115
|
+
def __setstate__(self,value):
|
116
|
+
for k,v in value.items(): self[k]=v
|
117
|
+
|
118
|
+
def isexecutable(file_name):
|
119
|
+
return os.path.isfile(file_name) and os.access(file_name, os.X_OK)
|
120
|
+
|
121
|
+
def find_executable(file_name):
|
122
|
+
'''
|
123
|
+
Search for executable file_name in the system PATH.
|
124
|
+
Return full path name or None if not found.
|
125
|
+
'''
|
126
|
+
def _find_executable(file_name):
|
127
|
+
if os.path.split(file_name)[0] != '':
|
128
|
+
# file_name includes directory so don't search path.
|
129
|
+
if not isexecutable(file_name):
|
130
|
+
return None
|
131
|
+
else:
|
132
|
+
return file_name
|
133
|
+
for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
|
134
|
+
f = os.path.join(p, file_name)
|
135
|
+
if isexecutable(f):
|
136
|
+
return os.path.realpath(f)
|
137
|
+
return None
|
138
|
+
if os.name == 'nt' and os.path.splitext(file_name)[1] == '':
|
139
|
+
for ext in ('.cmd','.bat','.exe'):
|
140
|
+
result = _find_executable(file_name + ext)
|
141
|
+
if result: break
|
142
|
+
else:
|
143
|
+
result = _find_executable(file_name)
|
144
|
+
return result
|
145
|
+
|
146
|
+
def shell_cd(path):
|
147
|
+
verbose('chdir %s' % path)
|
148
|
+
if not OPTIONS.dry_run:
|
149
|
+
os.chdir(path)
|
150
|
+
|
151
|
+
def shell_makedirs(path):
|
152
|
+
if os.path.isdir(path):
|
153
|
+
return
|
154
|
+
verbose('creating %s' % path)
|
155
|
+
if not OPTIONS.dry_run:
|
156
|
+
os.makedirs(path)
|
157
|
+
|
158
|
+
def shell_copy(src, dst):
|
159
|
+
verbose('copying "%s" to "%s"' % (src,dst))
|
160
|
+
if not OPTIONS.dry_run:
|
161
|
+
shutil.copy(src, dst)
|
162
|
+
|
163
|
+
def shell_rm(path):
|
164
|
+
if not os.path.exists(path):
|
165
|
+
return
|
166
|
+
verbose('deleting %s' % path)
|
167
|
+
if not OPTIONS.dry_run:
|
168
|
+
os.unlink(path)
|
169
|
+
|
170
|
+
def shell_rmtree(path):
|
171
|
+
if not os.path.isdir(path):
|
172
|
+
return
|
173
|
+
verbose('deleting %s' % path)
|
174
|
+
if not OPTIONS.dry_run:
|
175
|
+
shutil.rmtree(path)
|
176
|
+
|
177
|
+
def shell(cmd, raise_error=True):
|
178
|
+
'''
|
179
|
+
Execute command cmd in shell and return resulting subprocess.Popen object.
|
180
|
+
If raise_error is True then a non-zero return terminates the application.
|
181
|
+
'''
|
182
|
+
if os.name == 'nt':
|
183
|
+
# TODO: this is probably unnecessary, see:
|
184
|
+
# http://groups.google.com/group/asciidoc/browse_frm/thread/9442ee0c419f1242
|
185
|
+
# Windows doesn't like running scripts directly so explicitly
|
186
|
+
# specify python interpreter.
|
187
|
+
# Extract first (quoted or unquoted) argument.
|
188
|
+
mo = re.match(r'^\s*"\s*(?P<arg0>[^"]+)\s*"', cmd)
|
189
|
+
if not mo:
|
190
|
+
mo = re.match(r'^\s*(?P<arg0>[^ ]+)', cmd)
|
191
|
+
if mo.group('arg0').endswith('.py'):
|
192
|
+
cmd = 'python ' + cmd
|
193
|
+
# Remove redundant quoting -- this is not just costmetic, quoting seems to
|
194
|
+
# dramatically decrease the allowed command length in Windows XP.
|
195
|
+
cmd = re.sub(r'"([^ ]+?)"', r'\1', cmd)
|
196
|
+
verbose('executing: %s' % cmd)
|
197
|
+
if OPTIONS.dry_run:
|
198
|
+
return
|
199
|
+
if OPTIONS.verbose:
|
200
|
+
stdout = stderr = None
|
201
|
+
else:
|
202
|
+
stdout = stderr = subprocess.PIPE
|
203
|
+
try:
|
204
|
+
popen = subprocess.Popen(cmd, stdout=stdout, stderr=stderr,
|
205
|
+
shell=True, env=ENV)
|
206
|
+
except OSError, e:
|
207
|
+
die('failed: %s: %s' % (cmd, e))
|
208
|
+
popen.wait()
|
209
|
+
if popen.returncode != 0 and raise_error:
|
210
|
+
die('%s returned non-zero exit status %d' % (cmd, popen.returncode))
|
211
|
+
return popen
|
212
|
+
|
213
|
+
def find_resources(files, tagname, attrname, filter=None):
|
214
|
+
'''
|
215
|
+
Search all files and return a list of local URIs from attrname attribute
|
216
|
+
values in tagname tags.
|
217
|
+
Handles HTML open and XHTML closed tags.
|
218
|
+
Non-local URIs are skipped.
|
219
|
+
files can be a file name or a list of file names.
|
220
|
+
The filter function takes a dictionary of tag attributes and returns True if
|
221
|
+
the URI is to be included.
|
222
|
+
'''
|
223
|
+
class FindResources(HTMLParser.HTMLParser):
|
224
|
+
# Nested parser class shares locals with enclosing function.
|
225
|
+
def handle_startendtag(self, tag, attrs):
|
226
|
+
self.handle_starttag(tag, attrs)
|
227
|
+
def handle_starttag(self, tag, attrs):
|
228
|
+
attrs = dict(attrs)
|
229
|
+
if tag == tagname and (filter is None or filter(attrs)):
|
230
|
+
# Accept only local URIs.
|
231
|
+
uri = urlparse.urlparse(attrs[attrname])
|
232
|
+
if uri[0] in ('','file') and not uri[1] and uri[2]:
|
233
|
+
result.append(uri[2])
|
234
|
+
if isinstance(files, str):
|
235
|
+
files = [files]
|
236
|
+
result = []
|
237
|
+
for f in files:
|
238
|
+
verbose('finding resources in: %s' % f)
|
239
|
+
if OPTIONS.dry_run:
|
240
|
+
continue
|
241
|
+
parser = FindResources()
|
242
|
+
# HTMLParser has problems with non-ASCII strings.
|
243
|
+
# See http://bugs.python.org/issue3932
|
244
|
+
mo = re.search(r'^<\?xml.* encoding="(.*?)"', open(f).readline())
|
245
|
+
if mo:
|
246
|
+
encoding = mo.group(1)
|
247
|
+
parser.feed(open(f).read().decode(encoding))
|
248
|
+
else:
|
249
|
+
parser.feed(open(f).read())
|
250
|
+
parser.close()
|
251
|
+
result = list(set(result)) # Drop duplicate values.
|
252
|
+
result.sort()
|
253
|
+
return result
|
254
|
+
|
255
|
+
# NOT USED.
|
256
|
+
def copy_files(files, src_dir, dst_dir):
|
257
|
+
'''
|
258
|
+
Copy list of relative file names from src_dir to dst_dir.
|
259
|
+
'''
|
260
|
+
for f in files:
|
261
|
+
f = os.path.normpath(f)
|
262
|
+
if os.path.isabs(f):
|
263
|
+
continue
|
264
|
+
src = os.path.join(src_dir, f)
|
265
|
+
dst = os.path.join(dst_dir, f)
|
266
|
+
if not os.path.exists(dst):
|
267
|
+
if not os.path.isfile(src):
|
268
|
+
warning('missing file: %s' % src)
|
269
|
+
continue
|
270
|
+
dstdir = os.path.dirname(dst)
|
271
|
+
shell_makedirs(dstdir)
|
272
|
+
shell_copy(src, dst)
|
273
|
+
|
274
|
+
def find_files(path, pattern):
|
275
|
+
'''
|
276
|
+
Return list of file names matching pattern in directory path.
|
277
|
+
'''
|
278
|
+
result = []
|
279
|
+
for (p,dirs,files) in os.walk(path):
|
280
|
+
for f in files:
|
281
|
+
if fnmatch.fnmatch(f, pattern):
|
282
|
+
result.append(os.path.normpath(os.path.join(p,f)))
|
283
|
+
return result
|
284
|
+
|
285
|
+
def exec_xsltproc(xsl_file, xml_file, dst_dir, opts = ''):
|
286
|
+
cwd = os.getcwd()
|
287
|
+
shell_cd(dst_dir)
|
288
|
+
try:
|
289
|
+
shell('"%s" %s "%s" "%s"' % (XSLTPROC, opts, xsl_file, xml_file))
|
290
|
+
finally:
|
291
|
+
shell_cd(cwd)
|
292
|
+
|
293
|
+
def get_source_options(asciidoc_file):
|
294
|
+
'''
|
295
|
+
Look for a2x command options in AsciiDoc source file.
|
296
|
+
Limitation: options cannot contain double-quote characters.
|
297
|
+
'''
|
298
|
+
def parse_options():
|
299
|
+
# Parse options to result sequence.
|
300
|
+
inquotes = False
|
301
|
+
opt = ''
|
302
|
+
for c in options:
|
303
|
+
if c == '"':
|
304
|
+
if inquotes:
|
305
|
+
result.append(opt)
|
306
|
+
opt = ''
|
307
|
+
inquotes = False
|
308
|
+
else:
|
309
|
+
inquotes = True
|
310
|
+
elif c == ' ':
|
311
|
+
if inquotes:
|
312
|
+
opt += c
|
313
|
+
elif opt:
|
314
|
+
result.append(opt)
|
315
|
+
opt = ''
|
316
|
+
else:
|
317
|
+
opt += c
|
318
|
+
if opt:
|
319
|
+
result.append(opt)
|
320
|
+
|
321
|
+
result = []
|
322
|
+
if os.path.isfile(asciidoc_file):
|
323
|
+
options = ''
|
324
|
+
for line in open(asciidoc_file):
|
325
|
+
mo = re.search(r'^//\s*a2x:', line)
|
326
|
+
if mo:
|
327
|
+
options += ' ' + line[mo.end():].strip()
|
328
|
+
parse_options()
|
329
|
+
return result
|
330
|
+
|
331
|
+
|
332
|
+
#####################################################################
|
333
|
+
# Application class
|
334
|
+
#####################################################################
|
335
|
+
|
336
|
+
class A2X(AttrDict):
|
337
|
+
'''
|
338
|
+
a2x options and conversion functions.
|
339
|
+
'''
|
340
|
+
|
341
|
+
def execute(self):
|
342
|
+
'''
|
343
|
+
Process a2x command.
|
344
|
+
'''
|
345
|
+
self.process_options()
|
346
|
+
# Append configuration file options.
|
347
|
+
self.asciidoc_opts += ' ' + ASCIIDOC_OPTS
|
348
|
+
self.dblatex_opts += ' ' + DBLATEX_OPTS
|
349
|
+
self.fop_opts += ' ' + FOP_OPTS
|
350
|
+
self.xsltproc_opts += ' ' + XSLTPROC_OPTS
|
351
|
+
# Execute to_* functions.
|
352
|
+
self.__getattribute__('to_'+self.format)()
|
353
|
+
if not (self.keep_artifacts or self.format == 'docbook' or self.skip_asciidoc):
|
354
|
+
shell_rm(self.dst_path('.xml'))
|
355
|
+
|
356
|
+
def load_conf(self):
|
357
|
+
'''
|
358
|
+
Load a2x configuration file from default locations and --conf-file
|
359
|
+
option.
|
360
|
+
'''
|
361
|
+
global ASCIIDOC
|
362
|
+
CONF_FILE = 'a2x.conf'
|
363
|
+
a2xdir = os.path.dirname(os.path.realpath(__file__))
|
364
|
+
conf_files = []
|
365
|
+
# From a2x.py directory.
|
366
|
+
conf_files.append(os.path.join(a2xdir, CONF_FILE))
|
367
|
+
# If the asciidoc executable and conf files are in the a2x directory
|
368
|
+
# then use the local copy of asciidoc and skip the global a2x conf.
|
369
|
+
asciidoc = os.path.join(a2xdir, 'asciidoc.py')
|
370
|
+
asciidoc_conf = os.path.join(a2xdir, 'asciidoc.conf')
|
371
|
+
if os.path.isfile(asciidoc) and os.path.isfile(asciidoc_conf):
|
372
|
+
self.asciidoc = asciidoc
|
373
|
+
else:
|
374
|
+
self.asciidoc = None
|
375
|
+
# From global conf directory.
|
376
|
+
conf_files.append(os.path.join(CONF_DIR, CONF_FILE))
|
377
|
+
# From $HOME directory.
|
378
|
+
home_dir = os.environ.get('HOME')
|
379
|
+
if home_dir is not None:
|
380
|
+
conf_files.append(os.path.join(home_dir, '.asciidoc', CONF_FILE))
|
381
|
+
# From --conf-file option.
|
382
|
+
if self.conf_file is not None:
|
383
|
+
if not os.path.isfile(self.conf_file):
|
384
|
+
die('missing configuration file: %s' % self.conf_file)
|
385
|
+
conf_files.append(self.conf_file)
|
386
|
+
# From --xsl-file option.
|
387
|
+
if self.xsl_file is not None:
|
388
|
+
if not os.path.isfile(self.xsl_file):
|
389
|
+
die('missing XSL file: %s' % self.xsl_file)
|
390
|
+
self.xsl_file = os.path.abspath(self.xsl_file)
|
391
|
+
# Load ordered files.
|
392
|
+
for f in conf_files:
|
393
|
+
if os.path.isfile(f):
|
394
|
+
verbose('loading conf file: %s' % f)
|
395
|
+
execfile(f, globals())
|
396
|
+
# If asciidoc is not local to a2x then search the PATH.
|
397
|
+
if not self.asciidoc:
|
398
|
+
self.asciidoc = find_executable(ASCIIDOC)
|
399
|
+
if not self.asciidoc:
|
400
|
+
die('unable to find asciidoc: %s' % ASCIIDOC)
|
401
|
+
|
402
|
+
def process_options(self):
|
403
|
+
'''
|
404
|
+
Validate and command options and set defaults.
|
405
|
+
'''
|
406
|
+
if not os.path.isfile(self.asciidoc_file):
|
407
|
+
die('missing SOURCE_FILE: %s' % self.asciidoc_file)
|
408
|
+
self.asciidoc_file = os.path.abspath(self.asciidoc_file)
|
409
|
+
if not self.destination_dir:
|
410
|
+
self.destination_dir = os.path.dirname(self.asciidoc_file)
|
411
|
+
else:
|
412
|
+
if not os.path.isdir(self.destination_dir):
|
413
|
+
die('missing --destination-dir: %s' % self.destination_dir)
|
414
|
+
self.destination_dir = os.path.abspath(self.destination_dir)
|
415
|
+
self.resource_dirs = []
|
416
|
+
self.resource_files = []
|
417
|
+
if self.resource_manifest:
|
418
|
+
if not os.path.isfile(self.resource_manifest):
|
419
|
+
die('missing --resource-manifest: %s' % self.resource_manifest)
|
420
|
+
for r in open(self.resource_manifest):
|
421
|
+
self.resources.append(r.strip())
|
422
|
+
for r in self.resources:
|
423
|
+
r = os.path.expanduser(r)
|
424
|
+
r = os.path.expandvars(r)
|
425
|
+
if r.endswith(('/','\\')):
|
426
|
+
if os.path.isdir(r):
|
427
|
+
self.resource_dirs.append(r)
|
428
|
+
else:
|
429
|
+
die('missing resource directory: %s' % r)
|
430
|
+
elif os.path.isdir(r):
|
431
|
+
self.resource_dirs.append(r)
|
432
|
+
elif r.startswith('.') and '=' in r:
|
433
|
+
ext, mimetype = r.split('=')
|
434
|
+
mimetypes.add_type(mimetype, ext)
|
435
|
+
else:
|
436
|
+
self.resource_files.append(r)
|
437
|
+
for p in (os.path.dirname(self.asciidoc), CONF_DIR):
|
438
|
+
for d in ('images','stylesheets'):
|
439
|
+
d = os.path.join(p,d)
|
440
|
+
if os.path.isdir(d):
|
441
|
+
self.resource_dirs.append(d)
|
442
|
+
verbose('resource files: %s' % self.resource_files)
|
443
|
+
verbose('resource directories: %s' % self.resource_dirs)
|
444
|
+
if not self.doctype and self.format == 'manpage':
|
445
|
+
self.doctype = 'manpage'
|
446
|
+
if self.doctype:
|
447
|
+
self.asciidoc_opts += ' --doctype %s' % self.doctype
|
448
|
+
for attr in self.attributes:
|
449
|
+
self.asciidoc_opts += ' --attribute "%s"' % attr
|
450
|
+
# self.xsltproc_opts += ' --nonet'
|
451
|
+
if self.verbose:
|
452
|
+
self.asciidoc_opts += ' --verbose'
|
453
|
+
self.dblatex_opts += ' -V'
|
454
|
+
if self.icons or self.icons_dir:
|
455
|
+
params = [
|
456
|
+
'callout.graphics 1',
|
457
|
+
'navig.graphics 1',
|
458
|
+
'admon.textlabel 0',
|
459
|
+
'admon.graphics 1',
|
460
|
+
]
|
461
|
+
if self.icons_dir:
|
462
|
+
params += [
|
463
|
+
'admon.graphics.path "%s/"' % self.icons_dir,
|
464
|
+
'callout.graphics.path "%s/callouts/"' % self.icons_dir,
|
465
|
+
'navig.graphics.path "%s/"' % self.icons_dir,
|
466
|
+
]
|
467
|
+
else:
|
468
|
+
params = [
|
469
|
+
'callout.graphics 0',
|
470
|
+
'navig.graphics 0',
|
471
|
+
'admon.textlabel 1',
|
472
|
+
'admon.graphics 0',
|
473
|
+
]
|
474
|
+
if self.stylesheet:
|
475
|
+
params += ['html.stylesheet "%s"' % self.stylesheet]
|
476
|
+
if self.format == 'htmlhelp':
|
477
|
+
params += ['htmlhelp.chm "%s"' % self.basename('.chm'),
|
478
|
+
'htmlhelp.hhp "%s"' % self.basename('.hhp'),
|
479
|
+
'htmlhelp.hhk "%s"' % self.basename('.hhk'),
|
480
|
+
'htmlhelp.hhc "%s"' % self.basename('.hhc')]
|
481
|
+
if self.doctype == 'book':
|
482
|
+
params += ['toc.section.depth 1']
|
483
|
+
# Books are chunked at chapter level.
|
484
|
+
params += ['chunk.section.depth 0']
|
485
|
+
for o in params:
|
486
|
+
if o.split()[0]+' ' not in self.xsltproc_opts:
|
487
|
+
self.xsltproc_opts += ' --stringparam ' + o
|
488
|
+
if self.fop_opts:
|
489
|
+
self.fop = True
|
490
|
+
if os.path.splitext(self.asciidoc_file)[1].lower() == '.xml':
|
491
|
+
self.skip_asciidoc = True
|
492
|
+
else:
|
493
|
+
self.skip_asciidoc = False
|
494
|
+
|
495
|
+
def dst_path(self, ext):
|
496
|
+
'''
|
497
|
+
Return name of file or directory in the destination directory with
|
498
|
+
the same name as the asciidoc source file but with extension ext.
|
499
|
+
'''
|
500
|
+
return os.path.join(self.destination_dir, self.basename(ext))
|
501
|
+
|
502
|
+
def basename(self, ext):
|
503
|
+
'''
|
504
|
+
Return the base name of the asciidoc source file but with extension
|
505
|
+
ext.
|
506
|
+
'''
|
507
|
+
return os.path.basename(os.path.splitext(self.asciidoc_file)[0]) + ext
|
508
|
+
|
509
|
+
def asciidoc_conf_file(self, path):
|
510
|
+
'''
|
511
|
+
Return full path name of file in asciidoc configuration files directory.
|
512
|
+
Search first the directory containing the asciidoc executable then
|
513
|
+
the global configuration file directory.
|
514
|
+
'''
|
515
|
+
f = os.path.join(os.path.dirname(self.asciidoc), path)
|
516
|
+
if not os.path.isfile(f):
|
517
|
+
f = os.path.join(CONF_DIR, path)
|
518
|
+
if not os.path.isfile(f):
|
519
|
+
die('missing configuration file: %s' % f)
|
520
|
+
return os.path.normpath(f)
|
521
|
+
|
522
|
+
def xsl_stylesheet(self, file_name=None):
|
523
|
+
'''
|
524
|
+
Return full path name of file in asciidoc docbook-xsl configuration
|
525
|
+
directory.
|
526
|
+
If an XSL file was specified with the --xsl-file option then it is
|
527
|
+
returned.
|
528
|
+
'''
|
529
|
+
if self.xsl_file is not None:
|
530
|
+
return self.xsl_file
|
531
|
+
if not file_name:
|
532
|
+
file_name = self.format + '.xsl'
|
533
|
+
return self.asciidoc_conf_file(os.path.join('docbook-xsl', file_name))
|
534
|
+
|
535
|
+
def copy_resources(self, html_files, src_dir, dst_dir, resources=[]):
|
536
|
+
'''
|
537
|
+
Search html_files for images and CSS resource URIs (html_files can be a
|
538
|
+
list of file names or a single file name).
|
539
|
+
Copy them from the src_dir to the dst_dir.
|
540
|
+
If not found in src_dir then recursively search all specified
|
541
|
+
resource directories.
|
542
|
+
Optional additional resources files can be passed in the resources list.
|
543
|
+
'''
|
544
|
+
resources = resources[:]
|
545
|
+
resources += find_resources(html_files, 'link', 'href',
|
546
|
+
lambda attrs: attrs.get('type') == 'text/css')
|
547
|
+
resources += find_resources(html_files, 'img', 'src')
|
548
|
+
resources += self.resource_files
|
549
|
+
resources = list(set(resources)) # Drop duplicates.
|
550
|
+
resources.sort()
|
551
|
+
for f in resources:
|
552
|
+
if '=' in f:
|
553
|
+
src, dst = f.split('=')
|
554
|
+
if not dst:
|
555
|
+
dst = src
|
556
|
+
else:
|
557
|
+
src = dst = f
|
558
|
+
src = os.path.normpath(src)
|
559
|
+
dst = os.path.normpath(dst)
|
560
|
+
if os.path.isabs(dst):
|
561
|
+
die('absolute resource file name: %s' % dst)
|
562
|
+
if dst.startswith(os.pardir):
|
563
|
+
die('resource file outside destination directory: %s' % dst)
|
564
|
+
src = os.path.join(src_dir, src)
|
565
|
+
dst = os.path.join(dst_dir, dst)
|
566
|
+
if not os.path.isfile(src):
|
567
|
+
for d in self.resource_dirs:
|
568
|
+
d = os.path.join(src_dir, d)
|
569
|
+
found = find_files(d, os.path.basename(src))
|
570
|
+
if found:
|
571
|
+
src = found[0]
|
572
|
+
break
|
573
|
+
else:
|
574
|
+
if not os.path.isfile(dst):
|
575
|
+
die('missing resource: %s' % src)
|
576
|
+
continue
|
577
|
+
# Arrive here if resource file has been found.
|
578
|
+
if os.path.normpath(src) != os.path.normpath(dst):
|
579
|
+
dstdir = os.path.dirname(dst)
|
580
|
+
shell_makedirs(dstdir)
|
581
|
+
shell_copy(src, dst)
|
582
|
+
|
583
|
+
def to_docbook(self):
|
584
|
+
'''
|
585
|
+
Use asciidoc to convert asciidoc_file to DocBook.
|
586
|
+
args is a string containing additional asciidoc arguments.
|
587
|
+
'''
|
588
|
+
docbook_file = self.dst_path('.xml')
|
589
|
+
if self.skip_asciidoc:
|
590
|
+
if not os.path.isfile(docbook_file):
|
591
|
+
die('missing docbook file: %s' % docbook_file)
|
592
|
+
return
|
593
|
+
shell('"%s" --backend docbook %s --out-file "%s" "%s"' %
|
594
|
+
(self.asciidoc, self.asciidoc_opts, docbook_file, self.asciidoc_file))
|
595
|
+
if not self.no_xmllint and XMLLINT:
|
596
|
+
shell('"%s" --nonet --noout --valid "%s"' % (XMLLINT, docbook_file))
|
597
|
+
|
598
|
+
def to_xhtml(self):
|
599
|
+
self.to_docbook()
|
600
|
+
docbook_file = self.dst_path('.xml')
|
601
|
+
xhtml_file = self.dst_path('.html')
|
602
|
+
opts = '%s --output "%s"' % (self.xsltproc_opts, xhtml_file)
|
603
|
+
exec_xsltproc(self.xsl_stylesheet(), docbook_file, self.destination_dir, opts)
|
604
|
+
src_dir = os.path.dirname(self.asciidoc_file)
|
605
|
+
self.copy_resources(xhtml_file, src_dir, self.destination_dir)
|
606
|
+
|
607
|
+
def to_manpage(self):
|
608
|
+
self.to_docbook()
|
609
|
+
docbook_file = self.dst_path('.xml')
|
610
|
+
opts = self.xsltproc_opts
|
611
|
+
exec_xsltproc(self.xsl_stylesheet(), docbook_file, self.destination_dir, opts)
|
612
|
+
|
613
|
+
def to_pdf(self):
|
614
|
+
if self.fop:
|
615
|
+
self.exec_fop()
|
616
|
+
else:
|
617
|
+
self.exec_dblatex()
|
618
|
+
|
619
|
+
def exec_fop(self):
|
620
|
+
self.to_docbook()
|
621
|
+
docbook_file = self.dst_path('.xml')
|
622
|
+
xsl = self.xsl_stylesheet('fo.xsl')
|
623
|
+
fo = self.dst_path('.fo')
|
624
|
+
pdf = self.dst_path('.pdf')
|
625
|
+
opts = '%s --output "%s"' % (self.xsltproc_opts, fo)
|
626
|
+
exec_xsltproc(xsl, docbook_file, self.destination_dir, opts)
|
627
|
+
shell('"%s" %s -fo "%s" -pdf "%s"' % (FOP, self.fop_opts, fo, pdf))
|
628
|
+
if not self.keep_artifacts:
|
629
|
+
shell_rm(fo)
|
630
|
+
|
631
|
+
def exec_dblatex(self):
|
632
|
+
self.to_docbook()
|
633
|
+
docbook_file = self.dst_path('.xml')
|
634
|
+
xsl = self.asciidoc_conf_file(os.path.join('dblatex','asciidoc-dblatex.xsl'))
|
635
|
+
sty = self.asciidoc_conf_file(os.path.join('dblatex','asciidoc-dblatex.sty'))
|
636
|
+
shell('"%s" -t %s -p "%s" -s "%s" %s "%s"' %
|
637
|
+
(DBLATEX, self.format, xsl, sty, self.dblatex_opts, docbook_file))
|
638
|
+
|
639
|
+
def to_dvi(self):
|
640
|
+
self.exec_dblatex()
|
641
|
+
|
642
|
+
def to_ps(self):
|
643
|
+
self.exec_dblatex()
|
644
|
+
|
645
|
+
def to_tex(self):
|
646
|
+
self.exec_dblatex()
|
647
|
+
|
648
|
+
def to_htmlhelp(self):
|
649
|
+
self.to_chunked()
|
650
|
+
|
651
|
+
def to_chunked(self):
|
652
|
+
self.to_docbook()
|
653
|
+
docbook_file = self.dst_path('.xml')
|
654
|
+
opts = self.xsltproc_opts
|
655
|
+
xsl_file = self.xsl_stylesheet()
|
656
|
+
if self.format == 'chunked':
|
657
|
+
dst_dir = self.dst_path('.chunked')
|
658
|
+
elif self.format == 'htmlhelp':
|
659
|
+
dst_dir = self.dst_path('.htmlhelp')
|
660
|
+
if not 'base.dir ' in opts:
|
661
|
+
opts += ' --stringparam base.dir "%s/"' % os.path.basename(dst_dir)
|
662
|
+
# Create content.
|
663
|
+
shell_rmtree(dst_dir)
|
664
|
+
shell_makedirs(dst_dir)
|
665
|
+
exec_xsltproc(xsl_file, docbook_file, self.destination_dir, opts)
|
666
|
+
html_files = find_files(dst_dir, '*.html')
|
667
|
+
src_dir = os.path.dirname(self.asciidoc_file)
|
668
|
+
self.copy_resources(html_files, src_dir, dst_dir)
|
669
|
+
|
670
|
+
def update_epub_manifest(self, opf_file):
|
671
|
+
'''
|
672
|
+
Scan the OEBPS directory for any files that have not been registered in
|
673
|
+
the OPF manifest then add them to the manifest.
|
674
|
+
'''
|
675
|
+
opf_dir = os.path.dirname(opf_file)
|
676
|
+
resource_files = []
|
677
|
+
for (p,dirs,files) in os.walk(os.path.dirname(opf_file)):
|
678
|
+
for f in files:
|
679
|
+
f = os.path.join(p,f)
|
680
|
+
if os.path.isfile(f):
|
681
|
+
assert f.startswith(opf_dir)
|
682
|
+
f = '.' + f[len(opf_dir):]
|
683
|
+
f = os.path.normpath(f)
|
684
|
+
if f not in ['content.opf']:
|
685
|
+
resource_files.append(f)
|
686
|
+
opf = xml.dom.minidom.parseString(open(opf_file).read())
|
687
|
+
manifest_files = []
|
688
|
+
manifest = opf.getElementsByTagName('manifest')[0]
|
689
|
+
for el in manifest.getElementsByTagName('item'):
|
690
|
+
f = el.getAttribute('href')
|
691
|
+
f = os.path.normpath(f)
|
692
|
+
manifest_files.append(f)
|
693
|
+
count = 0
|
694
|
+
for f in resource_files:
|
695
|
+
if f not in manifest_files:
|
696
|
+
count += 1
|
697
|
+
verbose('adding to manifest: %s' % f)
|
698
|
+
item = opf.createElement('item')
|
699
|
+
item.setAttribute('href', f.replace(os.path.sep, '/'))
|
700
|
+
item.setAttribute('id', 'a2x-%d' % count)
|
701
|
+
mimetype = mimetypes.guess_type(f)[0]
|
702
|
+
if mimetype is None:
|
703
|
+
die('unknown mimetype: %s' % f)
|
704
|
+
item.setAttribute('media-type', mimetype)
|
705
|
+
manifest.appendChild(item)
|
706
|
+
if count > 0:
|
707
|
+
open(opf_file, 'w').write(opf.toxml())
|
708
|
+
|
709
|
+
def to_epub(self):
|
710
|
+
self.to_docbook()
|
711
|
+
xsl_file = self.xsl_stylesheet()
|
712
|
+
docbook_file = self.dst_path('.xml')
|
713
|
+
epub_file = self.dst_path('.epub')
|
714
|
+
build_dir = epub_file + '.d'
|
715
|
+
shell_rmtree(build_dir)
|
716
|
+
shell_makedirs(build_dir)
|
717
|
+
# Create content.
|
718
|
+
exec_xsltproc(xsl_file, docbook_file, build_dir, self.xsltproc_opts)
|
719
|
+
# Copy resources referenced in the OPF and resources referenced by the
|
720
|
+
# generated HTML (in theory DocBook XSL should ensure they are
|
721
|
+
# identical but this is not always the case).
|
722
|
+
src_dir = os.path.dirname(self.asciidoc_file)
|
723
|
+
dst_dir = os.path.join(build_dir, 'OEBPS')
|
724
|
+
opf_file = os.path.join(dst_dir, 'content.opf')
|
725
|
+
opf_resources = find_resources(opf_file, 'item', 'href')
|
726
|
+
html_files = find_files(dst_dir, '*.html')
|
727
|
+
self.copy_resources(html_files, src_dir, dst_dir, opf_resources)
|
728
|
+
# Register any unregistered resources.
|
729
|
+
self.update_epub_manifest(opf_file)
|
730
|
+
# Build epub archive.
|
731
|
+
cwd = os.getcwd()
|
732
|
+
shell_cd(build_dir)
|
733
|
+
try:
|
734
|
+
if not self.dry_run:
|
735
|
+
zip = zipfile.ZipFile(epub_file, 'w')
|
736
|
+
try:
|
737
|
+
# Create and add uncompressed mimetype file.
|
738
|
+
verbose('archiving: mimetype')
|
739
|
+
open('mimetype','w').write('application/epub+zip')
|
740
|
+
zip.write('mimetype', compress_type=zipfile.ZIP_STORED)
|
741
|
+
# Compress all remaining files.
|
742
|
+
for (p,dirs,files) in os.walk('.'):
|
743
|
+
for f in files:
|
744
|
+
f = os.path.normpath(os.path.join(p,f))
|
745
|
+
if f != 'mimetype':
|
746
|
+
verbose('archiving: %s' % f)
|
747
|
+
zip.write(f, compress_type=zipfile.ZIP_DEFLATED)
|
748
|
+
finally:
|
749
|
+
zip.close()
|
750
|
+
verbose('created archive: %s' % epub_file)
|
751
|
+
finally:
|
752
|
+
shell_cd(cwd)
|
753
|
+
if not self.keep_artifacts:
|
754
|
+
shell_rmtree(build_dir)
|
755
|
+
if self.epubcheck and EPUBCHECK:
|
756
|
+
if not find_executable(EPUBCHECK):
|
757
|
+
warning('epubcheck skipped: unable to find executable: %s' % EPUBCHECK)
|
758
|
+
else:
|
759
|
+
shell('"%s" "%s"' % (EPUBCHECK, epub_file))
|
760
|
+
|
761
|
+
def to_text(self):
|
762
|
+
text_file = self.dst_path('.text')
|
763
|
+
html_file = self.dst_path('.text.html')
|
764
|
+
if self.lynx:
|
765
|
+
shell('"%s" %s --conf-file "%s" -b html4 -o "%s" "%s"' %
|
766
|
+
(self.asciidoc, self.asciidoc_opts, self.asciidoc_conf_file('text.conf'),
|
767
|
+
html_file, self.asciidoc_file))
|
768
|
+
shell('"%s" -dump "%s" > "%s"' %
|
769
|
+
(LYNX, html_file, text_file))
|
770
|
+
else:
|
771
|
+
# Use w3m(1).
|
772
|
+
self.to_docbook()
|
773
|
+
docbook_file = self.dst_path('.xml')
|
774
|
+
opts = '%s --output "%s"' % (self.xsltproc_opts, html_file)
|
775
|
+
exec_xsltproc(self.xsl_stylesheet(), docbook_file,
|
776
|
+
self.destination_dir, opts)
|
777
|
+
shell('"%s" -cols 70 -dump -T text/html -no-graph "%s" > "%s"' %
|
778
|
+
(W3M, html_file, text_file))
|
779
|
+
if not self.keep_artifacts:
|
780
|
+
shell_rm(html_file)
|
781
|
+
|
782
|
+
|
783
|
+
#####################################################################
|
784
|
+
# Script main line.
|
785
|
+
#####################################################################
|
786
|
+
|
787
|
+
if __name__ == '__main__':
|
788
|
+
description = '''A toolchain manager for AsciiDoc (converts Asciidoc text files to other file formats)'''
|
789
|
+
from optparse import OptionParser
|
790
|
+
parser = OptionParser(usage='usage: %prog [OPTIONS] SOURCE_FILE',
|
791
|
+
version='%s %s' % (PROG,VERSION),
|
792
|
+
description=description)
|
793
|
+
parser.add_option('-a', '--attribute',
|
794
|
+
action='append', dest='attributes', default=[], metavar='ATTRIBUTE',
|
795
|
+
help='set asciidoc attribute value')
|
796
|
+
parser.add_option('--asciidoc-opts',
|
797
|
+
action='append', dest='asciidoc_opts', default=[],
|
798
|
+
metavar='ASCIIDOC_OPTS', help='asciidoc options')
|
799
|
+
#DEPRECATED
|
800
|
+
parser.add_option('--copy',
|
801
|
+
action='store_true', dest='copy', default=False,
|
802
|
+
help='DEPRECATED: does nothing')
|
803
|
+
parser.add_option('--conf-file',
|
804
|
+
dest='conf_file', default=None, metavar='CONF_FILE',
|
805
|
+
help='configuration file')
|
806
|
+
parser.add_option('-D', '--destination-dir',
|
807
|
+
action='store', dest='destination_dir', default=None, metavar='PATH',
|
808
|
+
help='output directory (defaults to SOURCE_FILE directory)')
|
809
|
+
parser.add_option('-d','--doctype',
|
810
|
+
action='store', dest='doctype', metavar='DOCTYPE',
|
811
|
+
choices=('article','manpage','book'),
|
812
|
+
help='article, manpage, book')
|
813
|
+
parser.add_option('--epubcheck',
|
814
|
+
action='store_true', dest='epubcheck', default=False,
|
815
|
+
help='check EPUB output with epubcheck')
|
816
|
+
parser.add_option('-f','--format',
|
817
|
+
action='store', dest='format', metavar='FORMAT', default = 'pdf',
|
818
|
+
choices=('chunked','epub','htmlhelp','manpage','pdf', 'text',
|
819
|
+
'xhtml','dvi','ps','tex','docbook'),
|
820
|
+
help='chunked, epub, htmlhelp, manpage, pdf, text, xhtml, dvi, ps, tex, docbook')
|
821
|
+
parser.add_option('--icons',
|
822
|
+
action='store_true', dest='icons', default=False,
|
823
|
+
help='use admonition, callout and navigation icons')
|
824
|
+
parser.add_option('--icons-dir',
|
825
|
+
action='store', dest='icons_dir',
|
826
|
+
default=None, metavar='PATH',
|
827
|
+
help='admonition and navigation icon directory')
|
828
|
+
parser.add_option('-k', '--keep-artifacts',
|
829
|
+
action='store_true', dest='keep_artifacts', default=False,
|
830
|
+
help='do not delete temporary build files')
|
831
|
+
parser.add_option('--lynx',
|
832
|
+
action='store_true', dest='lynx', default=False,
|
833
|
+
help='use lynx to generate text files')
|
834
|
+
parser.add_option('-L', '--no-xmllint',
|
835
|
+
action='store_true', dest='no_xmllint', default=False,
|
836
|
+
help='do not check asciidoc output with xmllint')
|
837
|
+
parser.add_option('-n','--dry-run',
|
838
|
+
action='store_true', dest='dry_run', default=False,
|
839
|
+
help='just print the commands that would have been executed')
|
840
|
+
parser.add_option('-r','--resource',
|
841
|
+
action='append', dest='resources', default=[],
|
842
|
+
metavar='PATH',
|
843
|
+
help='resource file or directory containing resource files')
|
844
|
+
parser.add_option('-m', '--resource-manifest',
|
845
|
+
action='store', dest='resource_manifest', default=None, metavar='FILE',
|
846
|
+
help='read resources from FILE')
|
847
|
+
#DEPRECATED
|
848
|
+
parser.add_option('--resource-dir',
|
849
|
+
action='append', dest='resources', default=[],
|
850
|
+
metavar='PATH',
|
851
|
+
help='DEPRECATED: use --resource')
|
852
|
+
#DEPRECATED
|
853
|
+
parser.add_option('-s','--skip-asciidoc',
|
854
|
+
action='store_true', dest='skip_asciidoc', default=False,
|
855
|
+
help='DEPRECATED: redundant')
|
856
|
+
parser.add_option('--stylesheet',
|
857
|
+
action='store', dest='stylesheet', default=None,
|
858
|
+
metavar='STYLESHEET',
|
859
|
+
help='HTML CSS stylesheet file name')
|
860
|
+
#DEPRECATED
|
861
|
+
parser.add_option('--safe',
|
862
|
+
action='store_true', dest='safe', default=False,
|
863
|
+
help='DEPRECATED: does nothing')
|
864
|
+
parser.add_option('--dblatex-opts',
|
865
|
+
action='append', dest='dblatex_opts', default=[],
|
866
|
+
metavar='DBLATEX_OPTS', help='dblatex options')
|
867
|
+
parser.add_option('--fop',
|
868
|
+
action='store_true', dest='fop', default=False,
|
869
|
+
help='use FOP to generate PDF files')
|
870
|
+
parser.add_option('--fop-opts',
|
871
|
+
action='append', dest='fop_opts', default=[],
|
872
|
+
metavar='FOP_OPTS', help='options for FOP pdf generation')
|
873
|
+
parser.add_option('--xsltproc-opts',
|
874
|
+
action='append', dest='xsltproc_opts', default=[],
|
875
|
+
metavar='XSLTPROC_OPTS', help='xsltproc options for XSL stylesheets')
|
876
|
+
parser.add_option('--xsl-file',
|
877
|
+
action='store', dest='xsl_file', metavar='XSL_FILE',
|
878
|
+
help='custom XSL stylesheet')
|
879
|
+
parser.add_option('-v', '--verbose',
|
880
|
+
action='count', dest='verbose', default=0,
|
881
|
+
help='increase verbosity')
|
882
|
+
if len(sys.argv) == 1:
|
883
|
+
parser.parse_args(['--help'])
|
884
|
+
source_options = get_source_options(sys.argv[-1])
|
885
|
+
argv = source_options + sys.argv[1:]
|
886
|
+
opts, args = parser.parse_args(argv)
|
887
|
+
if len(args) != 1:
|
888
|
+
parser.error('incorrect number of arguments')
|
889
|
+
opts.asciidoc_opts = ' '.join(opts.asciidoc_opts)
|
890
|
+
opts.dblatex_opts = ' '.join(opts.dblatex_opts)
|
891
|
+
opts.fop_opts = ' '.join(opts.fop_opts)
|
892
|
+
opts.xsltproc_opts = ' '.join(opts.xsltproc_opts)
|
893
|
+
opts = eval(str(opts)) # Convert optparse.Values to dict.
|
894
|
+
a2x = A2X(opts)
|
895
|
+
OPTIONS = a2x # verbose and dry_run used by utility functions.
|
896
|
+
verbose('args: %r' % argv)
|
897
|
+
a2x.asciidoc_file = args[0]
|
898
|
+
try:
|
899
|
+
a2x.load_conf()
|
900
|
+
a2x.execute()
|
901
|
+
except KeyboardInterrupt:
|
902
|
+
exit(1)
|