FooBarWidget-mizuho 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.markdown +68 -0
  3. data/Rakefile +9 -0
  4. data/asciidoc/BUGS +34 -0
  5. data/asciidoc/BUGS.txt +28 -0
  6. data/asciidoc/CHANGELOG +1585 -0
  7. data/asciidoc/CHANGELOG.txt +1595 -0
  8. data/asciidoc/COPYING +339 -0
  9. data/asciidoc/COPYRIGHT +18 -0
  10. data/asciidoc/INSTALL +82 -0
  11. data/asciidoc/INSTALL.txt +71 -0
  12. data/asciidoc/README +46 -0
  13. data/asciidoc/README.txt +36 -0
  14. data/asciidoc/a2x +641 -0
  15. data/asciidoc/asciidoc.conf +404 -0
  16. data/asciidoc/asciidoc.py +4255 -0
  17. data/asciidoc/common.aap +9 -0
  18. data/asciidoc/dblatex/asciidoc-dblatex.sty +18 -0
  19. data/asciidoc/dblatex/asciidoc-dblatex.xsl +17 -0
  20. data/asciidoc/dblatex/dblatex-readme.txt +22 -0
  21. data/asciidoc/doc/a2x.1 +246 -0
  22. data/asciidoc/doc/a2x.1.txt +195 -0
  23. data/asciidoc/doc/article.css-embedded.html +579 -0
  24. data/asciidoc/doc/article.html +62 -0
  25. data/asciidoc/doc/article.pdf +0 -0
  26. data/asciidoc/doc/article.txt +124 -0
  27. data/asciidoc/doc/asciidoc-revhistory.xml +27 -0
  28. data/asciidoc/doc/asciidoc.1 +161 -0
  29. data/asciidoc/doc/asciidoc.1.css-embedded.html +562 -0
  30. data/asciidoc/doc/asciidoc.1.css.html +212 -0
  31. data/asciidoc/doc/asciidoc.1.html +190 -0
  32. data/asciidoc/doc/asciidoc.1.txt +118 -0
  33. data/asciidoc/doc/asciidoc.conf +8 -0
  34. data/asciidoc/doc/asciidoc.css-embedded.html +7954 -0
  35. data/asciidoc/doc/asciidoc.css.html +7553 -0
  36. data/asciidoc/doc/asciidoc.dict +673 -0
  37. data/asciidoc/doc/asciidoc.html +3502 -0
  38. data/asciidoc/doc/asciidoc.txt +4757 -0
  39. data/asciidoc/doc/asciimath.txt +47 -0
  40. data/asciidoc/doc/book-multi.css-embedded.html +575 -0
  41. data/asciidoc/doc/book-multi.html +72 -0
  42. data/asciidoc/doc/book-multi.txt +159 -0
  43. data/asciidoc/doc/book.css-embedded.html +585 -0
  44. data/asciidoc/doc/book.html +60 -0
  45. data/asciidoc/doc/book.txt +133 -0
  46. data/asciidoc/doc/customers.csv +18 -0
  47. data/asciidoc/doc/faq.txt +262 -0
  48. data/asciidoc/doc/latex-backend.html +224 -0
  49. data/asciidoc/doc/latex-backend.txt +193 -0
  50. data/asciidoc/doc/latexmath.txt +35 -0
  51. data/asciidoc/doc/main.aap +293 -0
  52. data/asciidoc/doc/music-filter.html +513 -0
  53. data/asciidoc/doc/music-filter.pdf +0 -0
  54. data/asciidoc/doc/music-filter.txt +158 -0
  55. data/asciidoc/doc/source-highlight-filter.html +183 -0
  56. data/asciidoc/doc/source-highlight-filter.pdf +0 -0
  57. data/asciidoc/doc/source-highlight-filter.txt +174 -0
  58. data/asciidoc/docbook-xsl/asciidoc-docbook-xsl.txt +71 -0
  59. data/asciidoc/docbook-xsl/chunked.xsl +19 -0
  60. data/asciidoc/docbook-xsl/common.xsl +67 -0
  61. data/asciidoc/docbook-xsl/fo.xsl +117 -0
  62. data/asciidoc/docbook-xsl/htmlhelp.xsl +17 -0
  63. data/asciidoc/docbook-xsl/manpage.xsl +28 -0
  64. data/asciidoc/docbook-xsl/shaded-literallayout.patch +32 -0
  65. data/asciidoc/docbook-xsl/xhtml.xsl +14 -0
  66. data/asciidoc/docbook.conf +606 -0
  67. data/asciidoc/examples/website/CHANGELOG.html +3828 -0
  68. data/asciidoc/examples/website/INSTALL.html +163 -0
  69. data/asciidoc/examples/website/README-website.html +129 -0
  70. data/asciidoc/examples/website/README-website.txt +29 -0
  71. data/asciidoc/examples/website/README.html +125 -0
  72. data/asciidoc/examples/website/a2x.1.html +395 -0
  73. data/asciidoc/examples/website/asciidoc-docbook-xsl.html +165 -0
  74. data/asciidoc/examples/website/asciimath.html +157 -0
  75. data/asciidoc/examples/website/build-website.sh +25 -0
  76. data/asciidoc/examples/website/downloads.html +219 -0
  77. data/asciidoc/examples/website/downloads.txt +98 -0
  78. data/asciidoc/examples/website/faq.html +372 -0
  79. data/asciidoc/examples/website/index.html +398 -0
  80. data/asciidoc/examples/website/index.txt +222 -0
  81. data/asciidoc/examples/website/latex-backend.html +640 -0
  82. data/asciidoc/examples/website/latexmath.html +119 -0
  83. data/asciidoc/examples/website/layout1.conf +161 -0
  84. data/asciidoc/examples/website/layout1.css +65 -0
  85. data/asciidoc/examples/website/layout2.conf +158 -0
  86. data/asciidoc/examples/website/layout2.css +93 -0
  87. data/asciidoc/examples/website/manpage.html +266 -0
  88. data/asciidoc/examples/website/music-filter.html +242 -0
  89. data/asciidoc/examples/website/music1.abc +12 -0
  90. data/asciidoc/examples/website/music1.png +0 -0
  91. data/asciidoc/examples/website/music2.ly +9 -0
  92. data/asciidoc/examples/website/music2.png +0 -0
  93. data/asciidoc/examples/website/source-highlight-filter.html +251 -0
  94. data/asciidoc/examples/website/support.html +78 -0
  95. data/asciidoc/examples/website/support.txt +5 -0
  96. data/asciidoc/examples/website/userguide.html +7597 -0
  97. data/asciidoc/examples/website/version9.html +143 -0
  98. data/asciidoc/examples/website/version9.txt +48 -0
  99. data/asciidoc/filters/code-filter-readme.txt +37 -0
  100. data/asciidoc/filters/code-filter-test-c++.txt +7 -0
  101. data/asciidoc/filters/code-filter-test.txt +15 -0
  102. data/asciidoc/filters/code-filter.conf +8 -0
  103. data/asciidoc/filters/code-filter.py +239 -0
  104. data/asciidoc/filters/music-filter-test.txt +40 -0
  105. data/asciidoc/filters/music-filter.conf +40 -0
  106. data/asciidoc/filters/music2png.py +189 -0
  107. data/asciidoc/filters/source-highlight-filter-test.txt +19 -0
  108. data/asciidoc/filters/source-highlight-filter.conf +100 -0
  109. data/asciidoc/help.conf +213 -0
  110. data/asciidoc/html4.conf +363 -0
  111. data/asciidoc/images/highlighter.png +0 -0
  112. data/asciidoc/images/icons/README +5 -0
  113. data/asciidoc/images/icons/callouts/1.png +0 -0
  114. data/asciidoc/images/icons/callouts/10.png +0 -0
  115. data/asciidoc/images/icons/callouts/11.png +0 -0
  116. data/asciidoc/images/icons/callouts/12.png +0 -0
  117. data/asciidoc/images/icons/callouts/13.png +0 -0
  118. data/asciidoc/images/icons/callouts/14.png +0 -0
  119. data/asciidoc/images/icons/callouts/15.png +0 -0
  120. data/asciidoc/images/icons/callouts/2.png +0 -0
  121. data/asciidoc/images/icons/callouts/3.png +0 -0
  122. data/asciidoc/images/icons/callouts/4.png +0 -0
  123. data/asciidoc/images/icons/callouts/5.png +0 -0
  124. data/asciidoc/images/icons/callouts/6.png +0 -0
  125. data/asciidoc/images/icons/callouts/7.png +0 -0
  126. data/asciidoc/images/icons/callouts/8.png +0 -0
  127. data/asciidoc/images/icons/callouts/9.png +0 -0
  128. data/asciidoc/images/icons/caution.png +0 -0
  129. data/asciidoc/images/icons/example.png +0 -0
  130. data/asciidoc/images/icons/home.png +0 -0
  131. data/asciidoc/images/icons/important.png +0 -0
  132. data/asciidoc/images/icons/next.png +0 -0
  133. data/asciidoc/images/icons/note.png +0 -0
  134. data/asciidoc/images/icons/prev.png +0 -0
  135. data/asciidoc/images/icons/tip.png +0 -0
  136. data/asciidoc/images/icons/up.png +0 -0
  137. data/asciidoc/images/icons/warning.png +0 -0
  138. data/asciidoc/images/smallnew.png +0 -0
  139. data/asciidoc/images/tiger.png +0 -0
  140. data/asciidoc/install.sh +55 -0
  141. data/asciidoc/javascripts/ASCIIMathML.js +938 -0
  142. data/asciidoc/javascripts/LaTeXMathML.js +1223 -0
  143. data/asciidoc/javascripts/toc.js +69 -0
  144. data/asciidoc/lang-es.conf +15 -0
  145. data/asciidoc/latex.conf +663 -0
  146. data/asciidoc/linuxdoc.conf +285 -0
  147. data/asciidoc/math.conf +50 -0
  148. data/asciidoc/stylesheets/docbook-xsl.css +271 -0
  149. data/asciidoc/stylesheets/xhtml-deprecated-manpage.css +21 -0
  150. data/asciidoc/stylesheets/xhtml-deprecated.css +247 -0
  151. data/asciidoc/stylesheets/xhtml11-manpage.css +18 -0
  152. data/asciidoc/stylesheets/xhtml11-quirks.css +49 -0
  153. data/asciidoc/stylesheets/xhtml11.css +284 -0
  154. data/asciidoc/t.conf +20 -0
  155. data/asciidoc/text.conf +16 -0
  156. data/asciidoc/vim/ftdetect/asciidoc_filetype.vim +53 -0
  157. data/asciidoc/vim/syntax/asciidoc.vim +139 -0
  158. data/asciidoc/xhtml-deprecated-css.conf +235 -0
  159. data/asciidoc/xhtml-deprecated.conf +351 -0
  160. data/asciidoc/xhtml11-quirks.conf +57 -0
  161. data/asciidoc/xhtml11.conf +514 -0
  162. data/bin/mizuho +40 -0
  163. data/lib/mizuho/chapter.rb +54 -0
  164. data/lib/mizuho/generator.rb +106 -0
  165. data/lib/mizuho/heading.rb +46 -0
  166. data/lib/mizuho/parser.rb +99 -0
  167. data/lib/mizuho/template.rb +50 -0
  168. data/mizuho.gemspec +34 -0
  169. data/templates/asciidoc.css +358 -0
  170. data/templates/asciidoc.html.erb +86 -0
  171. data/templates/manualsonrails.css +165 -0
  172. data/templates/manualsonrails.html.erb +97 -0
  173. data/test/parser_spec.rb +190 -0
  174. data/test/spec_helper.rb +43 -0
  175. metadata +234 -0
data/asciidoc/README ADDED
@@ -0,0 +1,46 @@
1
+ AsciiDoc README File
2
+
3
+ version 8.2.7, 4 July 2008
4
+ __________________________________________________________________
5
+
6
+ 1. Prerequisites
7
+
8
+ AsciiDoc is written in Python so you need a Python interpreter (version
9
+ 2.4 or later) to execute asciidoc(1). Python is installed by default in
10
+ most Linux distributions. You can download Python from the official
11
+ Python website [1]http://www.python.org.
12
+ __________________________________________________________________
13
+
14
+ 2. Obtaining AsciiDoc
15
+
16
+ The latest AsciiDoc version and online documentation can be found at
17
+ [2]http://www.methods.co.nz/asciidoc/ and at the SourceForge
18
+ [3]http://sourceforge.net/projects/asciidoc/.
19
+ __________________________________________________________________
20
+
21
+ 3. Tools
22
+
23
+ Current AsciiDoc version tested on Xubuntu Linux 7.10 with:
24
+ * Python 2.5.1
25
+ * bash 3.2.25(1)
26
+ * DocBook XSL Stylesheets 1.72.0 (with AsciiDoc drivers and patches).
27
+ * xsltproc (libxml 20629, libxslt 10121 and libexslt 813).
28
+ * lynx 2.8.5rel.1.
29
+ * dblatex 0.2.8
30
+ * FOP 0.95beta
31
+ __________________________________________________________________
32
+
33
+ 4. COPYING
34
+
35
+ Copyright � 2002-2008 Stuart Rackham. Free use of this software is
36
+ granted under the terms of the GNU General Public License (GPL).
37
+ __________________________________________________________________
38
+
39
+ Version 8.2.7
40
+ Last updated 2008-07-04 23:26:27 NZDT
41
+
42
+ References
43
+
44
+ 1. http://www.python.org/
45
+ 2. http://www.methods.co.nz/asciidoc/
46
+ 3. http://sourceforge.net/projects/asciidoc/
@@ -0,0 +1,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
+ The latest AsciiDoc version and online documentation can be found at
15
+ http://www.methods.co.nz/asciidoc/ and at the SourceForge
16
+ http://sourceforge.net/projects/asciidoc/.
17
+
18
+
19
+ Tools
20
+ -----
21
+ Current AsciiDoc version tested on Xubuntu Linux 7.10 with:
22
+
23
+ - Python 2.5.1
24
+ - bash 3.2.25(1)
25
+ - DocBook XSL Stylesheets 1.72.0 (with AsciiDoc drivers and patches).
26
+ - xsltproc (libxml 20629, libxslt 10121 and libexslt 813).
27
+ - lynx 2.8.5rel.1.
28
+ - dblatex 0.2.8
29
+ - FOP 0.95beta
30
+
31
+
32
+ COPYING
33
+ -------
34
+ Copyright (C) 2002-2008 Stuart Rackham. Free use of this software
35
+ is granted under the terms of the GNU General Public License (GPL).
36
+
data/asciidoc/a2x ADDED
@@ -0,0 +1,641 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # a2x - convert Asciidoc text file to PDF, XHTML, HTML Help, manpage
4
+ # or plain text
5
+ #
6
+ # Copyright (C) 2007 Stuart Rackham. Free use of this software is granted
7
+ # under the terms of the GNU General Public License (GPL).
8
+ #
9
+
10
+ VERSION=1.0.0
11
+ BASENAME=$(basename "$0")
12
+ REALNAME="$0"
13
+ if [ ! -e "$REALNAME" ]; then
14
+ REALNAME=$(which "$REALNAME")
15
+ fi
16
+ REALNAME="$(readlink -f "$REALNAME")"
17
+ CONF_DIR=/etc/asciidoc
18
+ FOP_COMMAND="fop.sh" # FOP executable.
19
+
20
+ #--------------------------------------------------------------------
21
+ # Constants.
22
+ #--------------------------------------------------------------------
23
+
24
+ # These are mostly related to command options and are set by parse_options().
25
+ ASCIIDOC_OPTS=
26
+ COPY=no
27
+ DESTINATION_DIR=
28
+ DOCTYPE=
29
+ DRY_RUN=no
30
+ FORMAT=xhtml
31
+ ICONS=no
32
+ ICONS_DIR=./images/icons
33
+ SKIP_ASCIIDOC=no
34
+ SRC_DIR=
35
+ SRC_FILE=
36
+ SRC_NAME= # Source file name sans path and file name extension.
37
+ STYLESHEET=./docbook-xsl.css
38
+ VERBOSE_2=no
39
+ VERBOSE=no
40
+ XSLTPROC_OPTS=
41
+ DBLATEX_OPTS=
42
+ FOP_OPTS=
43
+ FOP=no
44
+
45
+ #--------------------------------------------------------------------
46
+ # General purpose functions
47
+ #--------------------------------------------------------------------
48
+
49
+ # Write $1 to stderr with backslash-escaped characters and no trailing newline.
50
+ function write_console()
51
+ {
52
+ echo -ne "$1" >&2
53
+ }
54
+
55
+ # Write newline to stderr.
56
+ function newline()
57
+ {
58
+ echo >&2
59
+ }
60
+
61
+ # Write $1 message to stderr.
62
+ function console_msg()
63
+ {
64
+ echo "$BASENAME: $1" >&2
65
+ }
66
+
67
+ # Write $1 to stderr if verbose or dry-run options set.
68
+ function verbose_msg()
69
+ {
70
+ if isyes "$VERBOSE" || isyes "$DRY_RUN"; then
71
+ console_msg "$1"
72
+ fi
73
+ }
74
+
75
+ # Return 0 if $1 is interpreted as an affirmative string.
76
+ function isyes()
77
+ {
78
+ case "$1" in
79
+ y|Y|yes|YES|Yes|true|TRUE|True) return 0;;
80
+ esac
81
+ return 1
82
+ }
83
+
84
+ # Log message $1 and exit with status $2 (default 1).
85
+ function quit()
86
+ {
87
+ local err tmp
88
+ err=${2:-1}
89
+ if [ $err -ne 0 ]; then
90
+ tmp="$VERBOSE"
91
+ VERBOSE=yes # Force console error exit message.
92
+ console_msg "failed: $1"
93
+ VERBOSE="$tmp"
94
+ else
95
+ console_msg "$1"
96
+ fi
97
+ cleanup
98
+ exit $err
99
+ }
100
+
101
+ # Execute the $1 command in the current shell subject to VERBOSE, DRY_RUN shell
102
+ # variables.
103
+ function execute_command()
104
+ {
105
+ if isyes "$VERBOSE" || isyes "$DRY_RUN"; then
106
+ console_msg "eval: $1"
107
+ fi
108
+ if isyes "$DRY_RUN"; then
109
+ return 0
110
+ else
111
+ eval $1
112
+ return $?
113
+ fi
114
+ }
115
+
116
+ # Same as execute_command() but if error occurs prints optional $2 message and
117
+ # exits program.
118
+ function execute_command_2()
119
+ {
120
+ local msg
121
+ execute_command "$1"
122
+ if [ $? -ne 0 ]; then
123
+ if [ -n "$2" ]; then
124
+ msg="$2"
125
+ else
126
+ msg="$1"
127
+ fi
128
+ quit "$msg"
129
+ fi
130
+ }
131
+
132
+ # Return 0 if $1 command can be executed.
133
+ function is_executable()
134
+ {
135
+ if which "$1" >/dev/null 2>&1; then
136
+ return 0
137
+ else
138
+ return 1
139
+ fi
140
+ }
141
+
142
+ # Return 127 if $1 is not in search path else return 0.
143
+ function require()
144
+ {
145
+ if ! is_executable "$1"; then
146
+ quit "cannot find required program: $1" 127
147
+ fi
148
+ }
149
+
150
+ # Join path $1 to path $2.
151
+ function join()
152
+ {
153
+ if [ -n "$1" ]; then
154
+ echo "$1/$2"
155
+ else
156
+ echo "$2"
157
+ fi
158
+ }
159
+
160
+ # Echo the total size in bytes of file name arguments.
161
+ function file_size()
162
+ {
163
+ echo $(du -cb "$@" | tail -1 | awk '{print $1}')
164
+ }
165
+
166
+ #--------------------------------------------------------------------
167
+ # Application specific functions
168
+ #--------------------------------------------------------------------
169
+
170
+ # Trap interrupts.
171
+ function set_trap()
172
+ {
173
+ # By convention exit code is 128 + signal number.
174
+ trap "newline; quit 'exiting: SIGINT' 130" SIGINT
175
+ trap "newline; quit 'exiting: SIGQUIT' 131" SIGQUIT
176
+ trap "quit 'exiting: SIGHUP' 129" SIGHUP
177
+ trap "quit 'exiting: SIGTERM' 143" SIGTERM
178
+ }
179
+
180
+ # Called at program exit.
181
+ function cleanup()
182
+ {
183
+ if [ "$(pwd)" != "$PWD" ]; then
184
+ execute_command "cd \"$PWD\""
185
+ fi
186
+ }
187
+
188
+ # Print help summary.
189
+ function help()
190
+ {
191
+ cat <<EOF
192
+ synopsis:
193
+
194
+ $BASENAME [OPTIONS] FILE
195
+
196
+ options:
197
+ -a, --attribute=ATTRIBUTE set asciidoc attribute value
198
+ --asciidoc-opts=ASCIIDOC_OPTS asciidoc options
199
+ --copy copy icons or HTML stylesheet
200
+ -D, --destination-dir=PATH output directory (defaults to FILE directory)
201
+ -d, --doctype=DOCTYPE article, manpage, book
202
+ -f, --format=FORMAT chunked,htmlhelp,manpage,pdf,text,xhtml,dvi,ps,tex
203
+ -h, --help print command syntax summary
204
+ --icons use admonition, callout and navigation icons
205
+ --icons-dir=PATH admonition and navigation icon directory
206
+ -n, --dry-run don't do anything just print the commands
207
+ -s, --skip-asciidoc skip asciidoc execution
208
+ --stylesheet=PATH target HTML CSS stylesheet file name
209
+ --version print program version to stdout
210
+ -v, --verbose print operational details to stderr
211
+ --dblatex-opts=DBLATEX_OPTS dblatex options
212
+ --fop-opts=FOP_OPTS options for FOP pdf generation
213
+ --xsltproc-opts=XSLTPROC_OPTS xsltproc options
214
+ EOF
215
+ }
216
+
217
+ # Print full path name of file $1 searching first in the directory containing
218
+ # the asciidoc executable and then in the global configuration directory.
219
+ function conf_file()
220
+ {
221
+ local result dir
222
+ # First look in same directory as asciidoc executable.
223
+ dir="$(dirname "$REALNAME")"
224
+ if [ ! -f "$dir/$1" -a -d $CONF_DIR ]; then
225
+ dir=$CONF_DIR
226
+ fi
227
+ result="$dir/$1"
228
+ echo $result
229
+ }
230
+
231
+ #--------------------------------------------------------------------
232
+ # Process command-line arguments $@
233
+ #--------------------------------------------------------------------
234
+ function parse_options()
235
+ {
236
+ if [ -z "$*" ]; then
237
+ help; exit 0
238
+ fi
239
+ require "getopt"
240
+ getopt -T >/dev/null
241
+ if [ $? -ne 4 ]; then
242
+ quit "enhanced getopt(1) required"
243
+ fi
244
+ short_opts="a:d:D:f:hnsv"
245
+ long_opts="attribute:,asciidoc-opts:,destination-dir:,doctype:,help,icons-dir:,dry-run,format:,copy,icons,skip-asciidoc,stylesheet:,version,verbose,xsltproc-opts:,dblatex-opts:,fop-opts:"
246
+ args=$(getopt -o $short_opts -l $long_opts -n $BASENAME -- "$@" 2>/dev/null)
247
+ if [ $? -ne 0 ]; then
248
+ quit "invalid command options, run: a2x --help"
249
+ fi
250
+ eval set -- "$args" # Set positional variables.
251
+ while true ; do
252
+ case "$1" in
253
+ -a|--attribute)
254
+ ASCIIDOC_OPTS="$ASCIIDOC_OPTS -a \"$2\""
255
+ shift 2 ;;
256
+ --asciidoc-opts)
257
+ ASCIIDOC_OPTS="$ASCIIDOC_OPTS $2"
258
+ shift 2 ;;
259
+ --copy)
260
+ COPY=yes;
261
+ shift ;;
262
+ -d|--doctype)
263
+ DOCTYPE=$2
264
+ shift 2 ;;
265
+ -D|--destination-dir)
266
+ DESTINATION_DIR=$2
267
+ shift 2 ;;
268
+ -f|--format)
269
+ FORMAT=$2
270
+ shift 2 ;;
271
+ -h|--help)
272
+ help; exit 0 ;;
273
+ --icons)
274
+ ICONS=yes
275
+ shift ;;
276
+ --icons-dir)
277
+ ICONS_DIR=$2
278
+ shift 2 ;;
279
+ -n|--dry-run)
280
+ DRY_RUN=yes;
281
+ shift ;;
282
+ -s|--skip-asciidoc)
283
+ SKIP_ASCIIDOC=yes;
284
+ shift ;;
285
+ --stylesheet)
286
+ STYLESHEET=$2
287
+ shift 2 ;;
288
+ --version)
289
+ echo "$BASENAME $VERSION" ; exit 0 ;;
290
+ -v|--verbose)
291
+ if isyes "$VERBOSE"; then
292
+ VERBOSE_2=yes
293
+ else
294
+ VERBOSE=yes
295
+ fi
296
+ shift ;;
297
+ --xsltproc-opts)
298
+ XSLTPROC_OPTS="$XSLTPROC_OPTS $2"
299
+ shift 2 ;;
300
+ --fop-opts)
301
+ FOP_OPTS="$FOP_OPTS $2"
302
+ FOP=yes
303
+ shift 2 ;;
304
+ --dblatex-opts)
305
+ DBLATEX_OPTS="$DBLATEX_OPTS $2"
306
+ shift 2 ;;
307
+ --)
308
+ shift; break ;;
309
+ *)
310
+ quit "unrecognized option: $1" ;;
311
+ esac
312
+ done
313
+
314
+ if isyes "$DRY_RUN"; then
315
+ VERBOSE=yes
316
+ fi
317
+
318
+ if [ $# -eq 0 ]; then
319
+ quit "source file not specified"
320
+ fi
321
+ if [ $# -ne 1 ]; then
322
+ quit "only one source file allowed"
323
+ fi
324
+ if [ ! -r "$1" ]; then
325
+ quit "source file not found: $1"
326
+ fi
327
+ SRC_FILE=$1
328
+ SRC_DIR=$(dirname "$1")
329
+ SRC_NAME=$1
330
+ SRC_NAME=${SRC_NAME##*/} # Strip path.
331
+ SRC_NAME=${SRC_NAME%.*} # Strip extension.
332
+ # Use FOP if there is no dblatex.
333
+ if ! is_executable dblatex && is_executable "$FOP_COMMAND"; then
334
+ FOP=yes
335
+ fi
336
+ }
337
+
338
+ #--------------------------------------------------------------------
339
+ # Validate program options.
340
+ #--------------------------------------------------------------------
341
+ function validate_options()
342
+ {
343
+ case "$FORMAT" in
344
+ chunked|dvi|htmlhelp|manpage|odt|pdf|ps|tex|text|xhtml) ;;
345
+ *) quit "illegal format: $FORMAT" ;;
346
+ esac
347
+
348
+ if [ -z "$DOCTYPE" ]; then
349
+ if [ "$FORMAT" = "manpage" ]; then
350
+ DOCTYPE=manpage
351
+ else
352
+ DOCTYPE=article
353
+ fi
354
+ fi
355
+ case "$DOCTYPE" in
356
+ article|book|manpage) ;;
357
+ *) quit "illegal doctype: $DOCTYPE" ;;
358
+ esac
359
+
360
+ if [ -z "$ICONS_DIR" ]; then
361
+ quit "icons directory not specified"
362
+ fi
363
+ if [[ "$ICONS_DIR" == /* ]]; then
364
+ quit "icons directory must be relative: $ICONS_DIR"
365
+ fi
366
+ ICONS_DIR=${ICONS_DIR%*/} # Strip trailing backslash.
367
+
368
+ if [ ! -z "$DESTINATION_DIR" ]; then
369
+ if [ ! -d "$DESTINATION_DIR" ]; then
370
+ quit "destination directory not found: $DESTINATION_DIR"
371
+ fi
372
+ else
373
+ DESTINATION_DIR="$SRC_DIR"
374
+ fi
375
+
376
+ if [ -z "$STYLESHEET" ]; then
377
+ quit "stylesheet cannot be blank"
378
+ fi
379
+ if [[ "$STYLESHEET" == /* ]]; then
380
+ quit "stylesheet path must be relative: $STYLESHEET"
381
+ fi
382
+ }
383
+
384
+ # Conditionally copy distribution stylesheet and admonition and navigation
385
+ # icons to destination directory $1.
386
+ function copy_stylesheet_and_icons()
387
+ {
388
+ if isyes $COPY; then
389
+ copy_stylesheet "$1"
390
+ if isyes $ICONS; then
391
+ copy_icons "$1/$ICONS_DIR"
392
+ fi
393
+ fi
394
+ }
395
+
396
+ # Copy distribution stylesheet to destination directory $1.
397
+ function copy_stylesheet()
398
+ {
399
+ local src dst
400
+ src=$(conf_file stylesheets/docbook-xsl.css)
401
+ if [ ! -r "$src" ]; then
402
+ quit "file not found: $src"
403
+ fi
404
+ dst="$1/$STYLESHEET"
405
+ # Check we're not trying to copy the file onto itself.
406
+ if [[ "$src" -ef "$dst" ]]; then
407
+ return
408
+ fi
409
+ execute_command_2 "cp -u \"$src\" \"$dst\""
410
+ }
411
+
412
+ # Copy distribution admonition and navigation icons to destination directory
413
+ # $1.
414
+ function copy_icons()
415
+ {
416
+ local src dst
417
+ dst="$1"
418
+ # Set source icons directory.
419
+ src=$(conf_file images/icons/home.png)
420
+ if [ ! -r "$src" ]; then
421
+ quit "file not found: $src"
422
+ fi
423
+ src=$(dirname "$src")
424
+ # Check we're not trying to copy the file onto itself.
425
+ if [[ "$src" -ef "$dst" ]]; then
426
+ return
427
+ fi
428
+ if [ -e "$dst" ]; then
429
+ if [ ! -d "$dst" ]; then
430
+ quit "icon destination must be a directory: $dst"
431
+ fi
432
+ else
433
+ execute_command_2 "mkdir -p \"$dst\""
434
+ fi
435
+ execute_command_2 "cp -rfu \"$src/\"* \"$dst\""
436
+ }
437
+
438
+ #--------------------------------------------------------------------
439
+ # Format conversion functions.
440
+ #--------------------------------------------------------------------
441
+
442
+ # Convert AsciiDoc $SRC_FILE to DocBook XML if it is newer than the
443
+ # XML output file. $1 has additional asciidoc(1) options.
444
+ function to_docbook()
445
+ {
446
+ local xml
447
+ xml="$SRC_DIR/$SRC_NAME.xml"
448
+ if isyes $SKIP_ASCIIDOC; then
449
+ if [ ! -r "$xml" ]; then
450
+ quit "file not found: $xml"
451
+ fi
452
+ return
453
+ fi
454
+ require "asciidoc"
455
+ execute_command_2 "asciidoc $ASCIIDOC_OPTS $1 -b docbook \"$SRC_FILE\""
456
+ }
457
+
458
+ function to_xhtml()
459
+ {
460
+ require "xsltproc"
461
+ local xsl xml html
462
+ xsl=$(conf_file docbook-xsl/xhtml.xsl)
463
+ if [ ! -r "$xsl" ]; then
464
+ quit "file not found: $xsl"
465
+ fi
466
+ to_docbook
467
+ xml=$(readlink -f "$SRC_DIR/$SRC_NAME.xml")
468
+ html="$SRC_NAME.html"
469
+ copy_stylesheet_and_icons "$DESTINATION_DIR"
470
+ execute_command_2 "cd \"$DESTINATION_DIR\""
471
+ execute_command_2 "xsltproc $XSLTPROC_OPTS --nonet \
472
+ \"$xsl\" \"$xml\" >\"$html\""
473
+ execute_command_2 "cd - >/dev/null"
474
+ }
475
+
476
+ function to_chunked()
477
+ {
478
+ require "xsltproc"
479
+ local chunkdir xsl xml hhp chm
480
+ case "$FORMAT" in
481
+ chunked)
482
+ chunkdir="$DESTINATION_DIR/$SRC_NAME.chunked"
483
+ xsl=chunked.xsl
484
+ ;;
485
+ htmlhelp)
486
+ chunkdir="$DESTINATION_DIR/$SRC_NAME.htmlhelp"
487
+ hhp="$SRC_NAME.hhp"
488
+ chm="$SRC_NAME.chm"
489
+ XSLTPROC_OPTS="$XSLTPROC_OPTS \
490
+ --stringparam htmlhelp.hhp \"$hhp\"
491
+ --stringparam htmlhelp.chm \"$chm\""
492
+ xsl=htmlhelp.xsl
493
+ ;;
494
+ esac
495
+ xsl=$(conf_file docbook-xsl/$xsl)
496
+ if [ ! -r "$xsl" ]; then
497
+ quit "file not found: $xsl"
498
+ fi
499
+ to_docbook
500
+ xml=$(readlink -f "$SRC_DIR/$SRC_NAME.xml")
501
+ if [ ! -d "$chunkdir" ]; then
502
+ execute_command_2 "mkdir \"$chunkdir\""
503
+ fi
504
+ execute_command_2 "rm -f \"$chunkdir/*.html\""
505
+ copy_stylesheet_and_icons "$chunkdir"
506
+ execute_command_2 "cd \"$DESTINATION_DIR\""
507
+ execute_command_2 "xsltproc $XSLTPROC_OPTS --nonet \
508
+ --stringparam base.dir \"$(basename "$chunkdir")/\" \
509
+ \"$xsl\" \"$xml\""
510
+ execute_command_2 "cd - >/dev/null"
511
+ }
512
+
513
+ function to_manpage()
514
+ {
515
+ require "xsltproc"
516
+ local xsl xml
517
+ xsl=$(conf_file docbook-xsl/manpage.xsl)
518
+ if [ ! -r "$xsl" ]; then
519
+ quit "file not found: $xsl"
520
+ fi
521
+ to_docbook "-d manpage"
522
+ xml=$(readlink -f "$SRC_DIR/$SRC_NAME.xml")
523
+ execute_command_2 "cd \"$DESTINATION_DIR\""
524
+ execute_command_2 "xsltproc $XSLTPROC_OPTS --nonet \
525
+ \"$xsl\" \"$xml\""
526
+ execute_command_2 "cd - >/dev/null"
527
+ }
528
+
529
+ function run_dblatex()
530
+ {
531
+ require "dblatex"
532
+ local xsl xml sty
533
+ to_docbook
534
+ xml="$SRC_DIR/$SRC_NAME.xml"
535
+ xsl=$(conf_file dblatex/asciidoc-dblatex.xsl)
536
+ sty=$(conf_file dblatex/asciidoc-dblatex.sty)
537
+ execute_command_2 "dblatex $DBLATEX_OPTS -t $FORMAT -p \"$xsl\" -s \"$sty\" \"$xml\""
538
+ }
539
+
540
+ function run_fop()
541
+ {
542
+ local xsl xml fo pdf
543
+ xml="$SRC_DIR/$SRC_NAME.xml"
544
+ pdf="$DESTINATION_DIR/$SRC_NAME.pdf"
545
+ require "xsltproc"
546
+ require "$FOP_COMMAND"
547
+ xsl=$(conf_file docbook-xsl/fo.xsl)
548
+ if [ ! -r "$xsl" ]; then
549
+ quit "file not found: $xsl"
550
+ fi
551
+ fo="$SRC_DIR/$SRC_NAME.fo"
552
+ to_docbook
553
+ execute_command_2 "xsltproc $XSLTPROC_OPTS --nonet \
554
+ \"$xsl\" \"$xml\" >\"$fo\""
555
+ execute_command_2 "\"$FOP_COMMAND\" $FOP_OPTS -fo \"$fo\" -pdf \"$pdf\""
556
+ }
557
+
558
+ function to_pdf()
559
+ {
560
+ if isyes $FOP; then
561
+ run_fop
562
+ else
563
+ run_dblatex
564
+ fi
565
+ }
566
+
567
+ function to_odt()
568
+ {
569
+ require "docbook2odf"
570
+ local xml odt opts
571
+ xml="$SRC_DIR/$SRC_NAME.xml"
572
+ odt="$DESTINATION_DIR/$SRC_NAME.odt"
573
+ opts="--force"
574
+ if ! isyes $VERBOSE; then
575
+ opts="$opts --quiet"
576
+ fi
577
+ to_docbook
578
+ execute_command_2 "docbook2odf $opts \"$xml\" --output-file \"$odt\""
579
+ }
580
+
581
+ function to_text()
582
+ {
583
+ require "asciidoc"
584
+ require "lynx"
585
+ local html text conf
586
+ html="$SRC_DIR/$SRC_NAME.html"
587
+ text="$DESTINATION_DIR/$SRC_NAME.text"
588
+ conf=$(conf_file text.conf)
589
+ execute_command_2 "asciidoc $ASCIIDOC_OPTS -f "$conf" -b html4 \
590
+ -o - \"$SRC_FILE\" | lynx -dump -stdin >\"$text\""
591
+ }
592
+
593
+ #--------------------------------------------------------------------
594
+ # Main
595
+ #--------------------------------------------------------------------
596
+
597
+ PWD=`pwd`
598
+ set_trap
599
+ parse_options "$@"
600
+ validate_options
601
+ ASCIIDOC_OPTS="--doctype=$DOCTYPE $ASCIIDOC_OPTS"
602
+ if isyes $VERBOSE_2; then
603
+ ASCIIDOC_OPTS="$ASCIIDOC_OPTS --verbose"
604
+ XSLTPROC_OPTS="$XSLTPROC_OPTS --verbose"
605
+ fi
606
+ case "$FORMAT" in
607
+ xhtml|chunked|htmlhelp)
608
+ XSLTPROC_OPTS="$XSLTPROC_OPTS \
609
+ --stringparam html.stylesheet \"$STYLESHEET\""
610
+ ;;
611
+ esac
612
+ if isyes $ICONS; then
613
+ XSLTPROC_OPTS="$XSLTPROC_OPTS --stringparam callout.graphics 1 \
614
+ --stringparam navig.graphics 0 \
615
+ --stringparam admon.textlabel 0 \
616
+ --stringparam admon.graphics 1 \
617
+ --stringparam admon.graphics.path \"$ICONS_DIR/\" \
618
+ --stringparam callout.graphics.path \"$ICONS_DIR/callouts/\" \
619
+ --stringparam navig.graphics.path \"$ICONS_DIR/\""
620
+ else
621
+ XSLTPROC_OPTS="$XSLTPROC_OPTS --stringparam callout.graphics 0 \
622
+ --stringparam navig.graphics 0 \
623
+ --stringparam admon.textlabel 1 \
624
+ --stringparam admon.graphics 0"
625
+ fi
626
+ case "$FORMAT" in
627
+ chunked|htmlhelp) to_chunked;;
628
+ manpage) to_manpage;;
629
+ odt) to_odt;;
630
+ pdf) to_pdf;;
631
+ text) to_text;;
632
+ xhtml) to_xhtml;;
633
+ dvi) run_dblatex;;
634
+ ps) run_dblatex;;
635
+ tex) run_dblatex;;
636
+ esac
637
+ cleanup
638
+
639
+ #--------------------------------------------------------------------
640
+ # vim: set et ts=4 sw=4 sts=4:
641
+ #--------------------------------------------------------------------