FooBarWidget-mizuho 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.markdown +68 -0
- data/Rakefile +9 -0
- data/asciidoc/BUGS +34 -0
- data/asciidoc/BUGS.txt +28 -0
- data/asciidoc/CHANGELOG +1585 -0
- data/asciidoc/CHANGELOG.txt +1595 -0
- data/asciidoc/COPYING +339 -0
- data/asciidoc/COPYRIGHT +18 -0
- data/asciidoc/INSTALL +82 -0
- data/asciidoc/INSTALL.txt +71 -0
- data/asciidoc/README +46 -0
- data/asciidoc/README.txt +36 -0
- data/asciidoc/a2x +641 -0
- data/asciidoc/asciidoc.conf +404 -0
- data/asciidoc/asciidoc.py +4255 -0
- data/asciidoc/common.aap +9 -0
- data/asciidoc/dblatex/asciidoc-dblatex.sty +18 -0
- data/asciidoc/dblatex/asciidoc-dblatex.xsl +17 -0
- data/asciidoc/dblatex/dblatex-readme.txt +22 -0
- data/asciidoc/doc/a2x.1 +246 -0
- data/asciidoc/doc/a2x.1.txt +195 -0
- data/asciidoc/doc/article.css-embedded.html +579 -0
- data/asciidoc/doc/article.html +62 -0
- data/asciidoc/doc/article.pdf +0 -0
- data/asciidoc/doc/article.txt +124 -0
- data/asciidoc/doc/asciidoc-revhistory.xml +27 -0
- data/asciidoc/doc/asciidoc.1 +161 -0
- data/asciidoc/doc/asciidoc.1.css-embedded.html +562 -0
- data/asciidoc/doc/asciidoc.1.css.html +212 -0
- data/asciidoc/doc/asciidoc.1.html +190 -0
- data/asciidoc/doc/asciidoc.1.txt +118 -0
- data/asciidoc/doc/asciidoc.conf +8 -0
- data/asciidoc/doc/asciidoc.css-embedded.html +7954 -0
- data/asciidoc/doc/asciidoc.css.html +7553 -0
- data/asciidoc/doc/asciidoc.dict +673 -0
- data/asciidoc/doc/asciidoc.html +3502 -0
- data/asciidoc/doc/asciidoc.txt +4757 -0
- data/asciidoc/doc/asciimath.txt +47 -0
- data/asciidoc/doc/book-multi.css-embedded.html +575 -0
- data/asciidoc/doc/book-multi.html +72 -0
- data/asciidoc/doc/book-multi.txt +159 -0
- data/asciidoc/doc/book.css-embedded.html +585 -0
- data/asciidoc/doc/book.html +60 -0
- data/asciidoc/doc/book.txt +133 -0
- data/asciidoc/doc/customers.csv +18 -0
- data/asciidoc/doc/faq.txt +262 -0
- data/asciidoc/doc/latex-backend.html +224 -0
- data/asciidoc/doc/latex-backend.txt +193 -0
- data/asciidoc/doc/latexmath.txt +35 -0
- data/asciidoc/doc/main.aap +293 -0
- data/asciidoc/doc/music-filter.html +513 -0
- data/asciidoc/doc/music-filter.pdf +0 -0
- data/asciidoc/doc/music-filter.txt +158 -0
- data/asciidoc/doc/source-highlight-filter.html +183 -0
- data/asciidoc/doc/source-highlight-filter.pdf +0 -0
- data/asciidoc/doc/source-highlight-filter.txt +174 -0
- data/asciidoc/docbook-xsl/asciidoc-docbook-xsl.txt +71 -0
- data/asciidoc/docbook-xsl/chunked.xsl +19 -0
- data/asciidoc/docbook-xsl/common.xsl +67 -0
- data/asciidoc/docbook-xsl/fo.xsl +117 -0
- data/asciidoc/docbook-xsl/htmlhelp.xsl +17 -0
- data/asciidoc/docbook-xsl/manpage.xsl +28 -0
- data/asciidoc/docbook-xsl/shaded-literallayout.patch +32 -0
- data/asciidoc/docbook-xsl/xhtml.xsl +14 -0
- data/asciidoc/docbook.conf +606 -0
- data/asciidoc/examples/website/CHANGELOG.html +3828 -0
- data/asciidoc/examples/website/INSTALL.html +163 -0
- data/asciidoc/examples/website/README-website.html +129 -0
- data/asciidoc/examples/website/README-website.txt +29 -0
- data/asciidoc/examples/website/README.html +125 -0
- data/asciidoc/examples/website/a2x.1.html +395 -0
- data/asciidoc/examples/website/asciidoc-docbook-xsl.html +165 -0
- data/asciidoc/examples/website/asciimath.html +157 -0
- data/asciidoc/examples/website/build-website.sh +25 -0
- data/asciidoc/examples/website/downloads.html +219 -0
- data/asciidoc/examples/website/downloads.txt +98 -0
- data/asciidoc/examples/website/faq.html +372 -0
- data/asciidoc/examples/website/index.html +398 -0
- data/asciidoc/examples/website/index.txt +222 -0
- data/asciidoc/examples/website/latex-backend.html +640 -0
- data/asciidoc/examples/website/latexmath.html +119 -0
- data/asciidoc/examples/website/layout1.conf +161 -0
- data/asciidoc/examples/website/layout1.css +65 -0
- data/asciidoc/examples/website/layout2.conf +158 -0
- data/asciidoc/examples/website/layout2.css +93 -0
- data/asciidoc/examples/website/manpage.html +266 -0
- data/asciidoc/examples/website/music-filter.html +242 -0
- data/asciidoc/examples/website/music1.abc +12 -0
- data/asciidoc/examples/website/music1.png +0 -0
- data/asciidoc/examples/website/music2.ly +9 -0
- data/asciidoc/examples/website/music2.png +0 -0
- data/asciidoc/examples/website/source-highlight-filter.html +251 -0
- data/asciidoc/examples/website/support.html +78 -0
- data/asciidoc/examples/website/support.txt +5 -0
- data/asciidoc/examples/website/userguide.html +7597 -0
- data/asciidoc/examples/website/version9.html +143 -0
- data/asciidoc/examples/website/version9.txt +48 -0
- data/asciidoc/filters/code-filter-readme.txt +37 -0
- data/asciidoc/filters/code-filter-test-c++.txt +7 -0
- data/asciidoc/filters/code-filter-test.txt +15 -0
- data/asciidoc/filters/code-filter.conf +8 -0
- data/asciidoc/filters/code-filter.py +239 -0
- data/asciidoc/filters/music-filter-test.txt +40 -0
- data/asciidoc/filters/music-filter.conf +40 -0
- data/asciidoc/filters/music2png.py +189 -0
- data/asciidoc/filters/source-highlight-filter-test.txt +19 -0
- data/asciidoc/filters/source-highlight-filter.conf +100 -0
- data/asciidoc/help.conf +213 -0
- data/asciidoc/html4.conf +363 -0
- data/asciidoc/images/highlighter.png +0 -0
- data/asciidoc/images/icons/README +5 -0
- data/asciidoc/images/icons/callouts/1.png +0 -0
- data/asciidoc/images/icons/callouts/10.png +0 -0
- data/asciidoc/images/icons/callouts/11.png +0 -0
- data/asciidoc/images/icons/callouts/12.png +0 -0
- data/asciidoc/images/icons/callouts/13.png +0 -0
- data/asciidoc/images/icons/callouts/14.png +0 -0
- data/asciidoc/images/icons/callouts/15.png +0 -0
- data/asciidoc/images/icons/callouts/2.png +0 -0
- data/asciidoc/images/icons/callouts/3.png +0 -0
- data/asciidoc/images/icons/callouts/4.png +0 -0
- data/asciidoc/images/icons/callouts/5.png +0 -0
- data/asciidoc/images/icons/callouts/6.png +0 -0
- data/asciidoc/images/icons/callouts/7.png +0 -0
- data/asciidoc/images/icons/callouts/8.png +0 -0
- data/asciidoc/images/icons/callouts/9.png +0 -0
- data/asciidoc/images/icons/caution.png +0 -0
- data/asciidoc/images/icons/example.png +0 -0
- data/asciidoc/images/icons/home.png +0 -0
- data/asciidoc/images/icons/important.png +0 -0
- data/asciidoc/images/icons/next.png +0 -0
- data/asciidoc/images/icons/note.png +0 -0
- data/asciidoc/images/icons/prev.png +0 -0
- data/asciidoc/images/icons/tip.png +0 -0
- data/asciidoc/images/icons/up.png +0 -0
- data/asciidoc/images/icons/warning.png +0 -0
- data/asciidoc/images/smallnew.png +0 -0
- data/asciidoc/images/tiger.png +0 -0
- data/asciidoc/install.sh +55 -0
- data/asciidoc/javascripts/ASCIIMathML.js +938 -0
- data/asciidoc/javascripts/LaTeXMathML.js +1223 -0
- data/asciidoc/javascripts/toc.js +69 -0
- data/asciidoc/lang-es.conf +15 -0
- data/asciidoc/latex.conf +663 -0
- data/asciidoc/linuxdoc.conf +285 -0
- data/asciidoc/math.conf +50 -0
- data/asciidoc/stylesheets/docbook-xsl.css +271 -0
- data/asciidoc/stylesheets/xhtml-deprecated-manpage.css +21 -0
- data/asciidoc/stylesheets/xhtml-deprecated.css +247 -0
- data/asciidoc/stylesheets/xhtml11-manpage.css +18 -0
- data/asciidoc/stylesheets/xhtml11-quirks.css +49 -0
- data/asciidoc/stylesheets/xhtml11.css +284 -0
- data/asciidoc/t.conf +20 -0
- data/asciidoc/text.conf +16 -0
- data/asciidoc/vim/ftdetect/asciidoc_filetype.vim +53 -0
- data/asciidoc/vim/syntax/asciidoc.vim +139 -0
- data/asciidoc/xhtml-deprecated-css.conf +235 -0
- data/asciidoc/xhtml-deprecated.conf +351 -0
- data/asciidoc/xhtml11-quirks.conf +57 -0
- data/asciidoc/xhtml11.conf +514 -0
- data/bin/mizuho +40 -0
- data/lib/mizuho/chapter.rb +54 -0
- data/lib/mizuho/generator.rb +106 -0
- data/lib/mizuho/heading.rb +46 -0
- data/lib/mizuho/parser.rb +99 -0
- data/lib/mizuho/template.rb +50 -0
- data/mizuho.gemspec +34 -0
- data/templates/asciidoc.css +358 -0
- data/templates/asciidoc.html.erb +86 -0
- data/templates/manualsonrails.css +165 -0
- data/templates/manualsonrails.html.erb +97 -0
- data/test/parser_spec.rb +190 -0
- data/test/spec_helper.rb +43 -0
- metadata +234 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<meta name="generator" content="AsciiDoc 8.2.7" />
|
7
|
+
<link rel="stylesheet" href="./xhtml11.css" type="text/css" />
|
8
|
+
<link rel="stylesheet" href="./xhtml11-quirks.css" type="text/css" />
|
9
|
+
<link rel="stylesheet" href="./layout1.css" type="text/css" />
|
10
|
+
<title>AsciiDoc Version 9</title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div id="layout-banner">
|
14
|
+
<div id="layout-title">AsciiDoc</div>
|
15
|
+
<div id="layout-description">Text based document generation</div>
|
16
|
+
</div>
|
17
|
+
<table>
|
18
|
+
<tr valign="top">
|
19
|
+
<td id="layout-menu">
|
20
|
+
<div>»<a href="index.html">Home</a></div>
|
21
|
+
<div>»<a href="manpage.html">Man Page</a></div>
|
22
|
+
<div>»<a href="userguide.html">User Guide</a></div>
|
23
|
+
<div>»<a href="http://powerman.name/doc/asciidoc">Cheatsheet</a></div>
|
24
|
+
<div>»<a href="a2x.1.html">a2x</a></div>
|
25
|
+
<div>»<a href="README.html">README</a></div>
|
26
|
+
<div>»<a href="CHANGELOG.html">ChangeLog</a></div>
|
27
|
+
<div>»<a href="INSTALL.html">Installation</a></div>
|
28
|
+
<div>»<a href="downloads.html">Downloads</a></div>
|
29
|
+
<div>»<a href="faq.html">FAQ</a></div>
|
30
|
+
<div>»<a href="support.html">Support</a></div>
|
31
|
+
<div id="page-source">»<a href="version9.txt">Page Source</a></div>
|
32
|
+
</td>
|
33
|
+
<td>
|
34
|
+
<div id="layout-content">
|
35
|
+
<div id="header">
|
36
|
+
<h1>AsciiDoc Version 9</h1>
|
37
|
+
</div>
|
38
|
+
<div id="preamble">
|
39
|
+
<div class="sectionbody">
|
40
|
+
<div class="para"><p>Installing and configuring the latest version of <em>AsciiDoc</em> across
|
41
|
+
various distributions and platforms has never been easy and lots of
|
42
|
+
contributors have put in <a href="downloads.html#X1">lots of effort</a> to do
|
43
|
+
just this — this never ending and largely thankless task is the bane
|
44
|
+
of the Open Source developer and user alike because invevitably
|
45
|
+
distribution specific packages are either missing or are soon out of
|
46
|
+
date.</p></div>
|
47
|
+
<div class="para"><p>But it doesn't have to be like this — <em>AsciiDoc</em> is a pure Python
|
48
|
+
application and could be distributed from the
|
49
|
+
<a href="http://pypi.python.org/">Cheese Shop</a> as a stand-alone platform
|
50
|
+
independent <a href="http://peak.telecommunity.com/DevCenter/PythonEggs">Python
|
51
|
+
Egg</a>. The 9.x branch aims to attack this problem.</p></div>
|
52
|
+
<div class="para"><p>The feature plan for 9.0 is:</p></div>
|
53
|
+
<div class="ilist"><ul>
|
54
|
+
<li>
|
55
|
+
<p>
|
56
|
+
<em>AsciiDoc</em> easy_installable (done, not fully tested).
|
57
|
+
</p>
|
58
|
+
</li>
|
59
|
+
<li>
|
60
|
+
<p>
|
61
|
+
<em>AsciiDoc</em> as a Python module with a decent API (now a module, no API
|
62
|
+
yet).
|
63
|
+
</p>
|
64
|
+
</li>
|
65
|
+
<li>
|
66
|
+
<p>
|
67
|
+
<em>AsciiDoc</em> 100% Python: no shell or unportable scripting (not done).
|
68
|
+
</p>
|
69
|
+
</li>
|
70
|
+
</ul></div>
|
71
|
+
<div class="para"><p>Later in the 9.x branch:</p></div>
|
72
|
+
<div class="ilist"><ul>
|
73
|
+
<li>
|
74
|
+
<p>
|
75
|
+
plugin system for frontend and backends.
|
76
|
+
</p>
|
77
|
+
</li>
|
78
|
+
<li>
|
79
|
+
<p>
|
80
|
+
plugin system for style-sheets.
|
81
|
+
</p>
|
82
|
+
</li>
|
83
|
+
<li>
|
84
|
+
<p>
|
85
|
+
distutils commands to produce <em>AsciiDoc</em> rendered documentation of
|
86
|
+
Python packages (minimal support now in buildutils).
|
87
|
+
</p>
|
88
|
+
</li>
|
89
|
+
</ul></div>
|
90
|
+
<div class="para"><p><a href="http://ygingras.net">Yannick Gingras</a> is the maintainer of the 9.x branch;
|
91
|
+
he can be contacted by <a href="mailto:ygingras@ygingras.net">email</a> or, preferably,
|
92
|
+
on the <a href="support.html">mailing list</a>.</p></div>
|
93
|
+
<div class="para"><p>There is no release of the 9.x branch yet but adventurous users can
|
94
|
+
still get the source with Mercurial:</p></div>
|
95
|
+
<div class="literalblock">
|
96
|
+
<div class="content">
|
97
|
+
<pre><tt>hg clone static-http://ygingras.net/files/asciidoc.hg asciidoc-9x</tt></pre>
|
98
|
+
</div></div>
|
99
|
+
<div class="para"><p>Using sources from the Mercurial repository will require
|
100
|
+
<a href="http://peak.telecommunity.com/DevCenter/setuptools">Setuptools</a> and the
|
101
|
+
<a href="http://pypi.python.org/pypi/hg.setuptools/">Mercurial plugin</a> for
|
102
|
+
Setuptools.</p></div>
|
103
|
+
<div class="admonitionblock">
|
104
|
+
<table><tr>
|
105
|
+
<td class="icon">
|
106
|
+
<img src="./images/icons/note.png" alt="Note" />
|
107
|
+
</td>
|
108
|
+
<td class="content">The 9.x branch is still experimental. You should install it
|
109
|
+
inside a <a href="http://pypi.python.org/pypi/virtualenv/">virtualenv</a> to
|
110
|
+
prevent damages to your global Python environment.</td>
|
111
|
+
</tr></table>
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
<div id="footer">
|
116
|
+
<div id="footer-text">
|
117
|
+
Version 8.2.7<br />
|
118
|
+
Last updated 2008-07-04 23:29:49 NZDT
|
119
|
+
</div>
|
120
|
+
<div id="footer-badges">
|
121
|
+
<a href="http://validator.w3.org/check?uri=referer">
|
122
|
+
<img style="border:none; width:88px; height:31px;"
|
123
|
+
src="http://www.w3.org/Icons/valid-xhtml11"
|
124
|
+
alt="Valid XHTML 1.1!" />
|
125
|
+
</a>
|
126
|
+
<a href="http://jigsaw.w3.org/css-validator/check/referer">
|
127
|
+
<img style="border:none; width:88px; height:31px;"
|
128
|
+
src="http://jigsaw.w3.org/css-validator/images/vcss"
|
129
|
+
alt="Valid CSS!" />
|
130
|
+
</a>
|
131
|
+
<a href="http://www.mozilla.org/products/firefox/">
|
132
|
+
<img style="border:none; width:110px; height:32px;"
|
133
|
+
src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/110x32/safer.gif"
|
134
|
+
alt="Get Firefox!" />
|
135
|
+
</a>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
</div>
|
139
|
+
</td>
|
140
|
+
</tr>
|
141
|
+
</table>
|
142
|
+
</body>
|
143
|
+
</html>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
AsciiDoc Version 9
|
2
|
+
==================
|
3
|
+
|
4
|
+
Installing and configuring the latest version of AsciiDoc across
|
5
|
+
various distributions and platforms has never been easy and lots of
|
6
|
+
contributors have put in link:downloads.html#X1[lots of effort] to do
|
7
|
+
just this -- this never ending and largely thankless task is the bane
|
8
|
+
of the Open Source developer and user alike because invevitably
|
9
|
+
distribution specific packages are either missing or are soon out of
|
10
|
+
date.
|
11
|
+
|
12
|
+
But it doesn't have to be like this -- AsciiDoc is a pure Python
|
13
|
+
application and could be distributed from the
|
14
|
+
http://pypi.python.org/[Cheese Shop] as a stand-alone platform
|
15
|
+
independent http://peak.telecommunity.com/DevCenter/PythonEggs[Python
|
16
|
+
Egg]. The 9.x branch aims to attack this problem.
|
17
|
+
|
18
|
+
The feature plan for 9.0 is:
|
19
|
+
|
20
|
+
- AsciiDoc easy_installable (done, not fully tested).
|
21
|
+
- AsciiDoc as a Python module with a decent API (now a module, no API
|
22
|
+
yet).
|
23
|
+
- AsciiDoc 100% Python: no shell or unportable scripting (not done).
|
24
|
+
|
25
|
+
Later in the 9.x branch:
|
26
|
+
|
27
|
+
- plugin system for frontend and backends.
|
28
|
+
- plugin system for style-sheets.
|
29
|
+
- distutils commands to produce AsciiDoc rendered documentation of
|
30
|
+
Python packages (minimal support now in buildutils).
|
31
|
+
|
32
|
+
http://ygingras.net[Yannick Gingras] is the maintainer of the 9.x branch;
|
33
|
+
he can be contacted by mailto:ygingras@ygingras.net[email] or, preferably,
|
34
|
+
on the link:support.html[mailing list].
|
35
|
+
|
36
|
+
There is no release of the 9.x branch yet but adventurous users can
|
37
|
+
still get the source with Mercurial:
|
38
|
+
|
39
|
+
hg clone static-http://ygingras.net/files/asciidoc.hg asciidoc-9x
|
40
|
+
|
41
|
+
Using sources from the Mercurial repository will require
|
42
|
+
http://peak.telecommunity.com/DevCenter/setuptools[Setuptools] and the
|
43
|
+
http://pypi.python.org/pypi/hg.setuptools/[Mercurial plugin] for
|
44
|
+
Setuptools.
|
45
|
+
|
46
|
+
NOTE: The 9.x branch is still experimental. You should install it
|
47
|
+
inside a http://pypi.python.org/pypi/virtualenv/[virtualenv] to
|
48
|
+
prevent damages to your global Python environment.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
AsciiDoc Code Filter
|
2
|
+
====================
|
3
|
+
|
4
|
+
This simple minded filter highlights source code keywords and
|
5
|
+
comments.
|
6
|
+
|
7
|
+
NOTE: The filter is to demonstrate how to write a filter -- it's much
|
8
|
+
to simplistic to be passed off as a code syntax highlighter. If you
|
9
|
+
want a full featured highlighter use the 'source highlighter filter.
|
10
|
+
|
11
|
+
|
12
|
+
Files
|
13
|
+
-----
|
14
|
+
code-filter.py::
|
15
|
+
The filter Python script.
|
16
|
+
code-filter.conf::
|
17
|
+
The AsciiDoc filter configuration file.
|
18
|
+
code-filter-test.txt::
|
19
|
+
Short AsciiDoc document to test the filter.
|
20
|
+
|
21
|
+
|
22
|
+
Installation
|
23
|
+
------------
|
24
|
+
The code filter is installed in the distribution `filters` directory
|
25
|
+
as part of the standard AsciiDoc install.
|
26
|
+
|
27
|
+
Test it on the `code-filter-test.txt` file:
|
28
|
+
|
29
|
+
$ asciidoc -v code-filter-test.txt
|
30
|
+
$ firefox code-filter-test.txt &
|
31
|
+
|
32
|
+
|
33
|
+
Help
|
34
|
+
----
|
35
|
+
Execute the filter with the help option:
|
36
|
+
|
37
|
+
$ ./code-filter.py --help
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Code Filter Test
|
2
|
+
================
|
3
|
+
|
4
|
+
[python]
|
5
|
+
code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
6
|
+
''' A multi-line
|
7
|
+
comment.'''
|
8
|
+
def sub_word(mo):
|
9
|
+
''' Single line comment.'''
|
10
|
+
word = mo.group('word') # Inline comment
|
11
|
+
if word in keywords[language]:
|
12
|
+
return quote + word + quote
|
13
|
+
else:
|
14
|
+
return word
|
15
|
+
code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#
|
2
|
+
# AsciiDoc code filter configuration file.
|
3
|
+
#
|
4
|
+
# Documented in code-filter-readme.txt
|
5
|
+
#
|
6
|
+
|
7
|
+
[blockdef-filter]
|
8
|
+
code-style=template="listingblock",presubs=(),postsubs=("callouts",),posattrs=("style","language"),filter="code-filter.py -b {basebackend} -l {language}"
|
@@ -0,0 +1,239 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
'''
|
3
|
+
NAME
|
4
|
+
code-filter - AsciiDoc filter to highlight language keywords
|
5
|
+
|
6
|
+
SYNOPSIS
|
7
|
+
code-filter -b backend -l language [ -t tabsize ]
|
8
|
+
[ --help | -h ] [ --version | -v ]
|
9
|
+
|
10
|
+
DESCRIPTION
|
11
|
+
This filter reads source code from the standard input, highlights language
|
12
|
+
keywords and comments and writes to the standard output.
|
13
|
+
|
14
|
+
The purpose of this program is to demonstrate how to write an AsciiDoc
|
15
|
+
filter -- it's much to simplistic to be passed off as a code syntax
|
16
|
+
highlighter. Use the 'source-highlight-filter' instead.
|
17
|
+
|
18
|
+
|
19
|
+
OPTIONS
|
20
|
+
--help, -h
|
21
|
+
Print this documentation.
|
22
|
+
|
23
|
+
-b
|
24
|
+
Backend output file format: 'docbook', 'linuxdoc', 'html', 'css'.
|
25
|
+
|
26
|
+
-l
|
27
|
+
The name of the source code language: 'python', 'ruby', 'c++', 'c'.
|
28
|
+
|
29
|
+
-t tabsize
|
30
|
+
Expand source tabs to tabsize spaces.
|
31
|
+
|
32
|
+
--version, -v
|
33
|
+
Print program version number.
|
34
|
+
|
35
|
+
BUGS
|
36
|
+
- Code on the same line as a block comment is treated as comment.
|
37
|
+
Keywords inside literal strings are highlighted.
|
38
|
+
- There doesn't appear to be an easy way to accomodate linuxdoc so
|
39
|
+
just pass it through without markup.
|
40
|
+
|
41
|
+
AUTHOR
|
42
|
+
Written by Stuart Rackham, <srackham@gmail.com>
|
43
|
+
|
44
|
+
URLS
|
45
|
+
http://sourceforge.net/projects/asciidoc/
|
46
|
+
http://www.methods.co.nz/asciidoc/
|
47
|
+
|
48
|
+
COPYING
|
49
|
+
Copyright (C) 2002-2006 Stuart Rackham. Free use of this software is
|
50
|
+
granted under the terms of the GNU General Public License (GPL).
|
51
|
+
'''
|
52
|
+
|
53
|
+
import os, sys, re, string
|
54
|
+
|
55
|
+
VERSION = '1.1.2'
|
56
|
+
|
57
|
+
# Globals.
|
58
|
+
language = None
|
59
|
+
backend = None
|
60
|
+
tabsize = 8
|
61
|
+
keywordtags = {
|
62
|
+
'html':
|
63
|
+
('<strong>','</strong>'),
|
64
|
+
'css':
|
65
|
+
('<strong>','</strong>'),
|
66
|
+
'docbook':
|
67
|
+
('<emphasis role="strong">','</emphasis>'),
|
68
|
+
'linuxdoc':
|
69
|
+
('','')
|
70
|
+
}
|
71
|
+
commenttags = {
|
72
|
+
'html':
|
73
|
+
('<i>','</i>'),
|
74
|
+
'css':
|
75
|
+
('<i>','</i>'),
|
76
|
+
'docbook':
|
77
|
+
('<emphasis>','</emphasis>'),
|
78
|
+
'linuxdoc':
|
79
|
+
('','')
|
80
|
+
}
|
81
|
+
keywords = {
|
82
|
+
'python':
|
83
|
+
('and', 'del', 'for', 'is', 'raise', 'assert', 'elif', 'from',
|
84
|
+
'lambda', 'return', 'break', 'else', 'global', 'not', 'try', 'class',
|
85
|
+
'except', 'if', 'or', 'while', 'continue', 'exec', 'import', 'pass',
|
86
|
+
'yield', 'def', 'finally', 'in', 'print'),
|
87
|
+
'ruby':
|
88
|
+
('__FILE__', 'and', 'def', 'end', 'in', 'or', 'self', 'unless',
|
89
|
+
'__LINE__', 'begin', 'defined?' 'ensure', 'module', 'redo', 'super',
|
90
|
+
'until', 'BEGIN', 'break', 'do', 'false', 'next', 'rescue', 'then',
|
91
|
+
'when', 'END', 'case', 'else', 'for', 'nil', 'retry', 'true', 'while',
|
92
|
+
'alias', 'class', 'elsif', 'if', 'not', 'return', 'undef', 'yield'),
|
93
|
+
'c++':
|
94
|
+
('asm', 'auto', 'bool', 'break', 'case', 'catch', 'char', 'class',
|
95
|
+
'const', 'const_cast', 'continue', 'default', 'delete', 'do', 'double',
|
96
|
+
'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern',
|
97
|
+
'false', 'float', 'for', 'friend', 'goto', 'if', 'inline', 'int',
|
98
|
+
'long', 'mutable', 'namespace', 'new', 'operator', 'private',
|
99
|
+
'protected', 'public', 'register', 'reinterpret_cast', 'return',
|
100
|
+
'short', 'signed', 'sizeof', 'static', 'static_cast', 'struct',
|
101
|
+
'switch', 'template', 'this', 'throw', 'true', 'try', 'typedef',
|
102
|
+
'typeid', 'typename', 'union', 'unsigned', 'using', 'virtual', 'void',
|
103
|
+
'volatile', 'wchar_t', 'while')
|
104
|
+
}
|
105
|
+
block_comments = {
|
106
|
+
'python': ("'''","'''"),
|
107
|
+
'ruby': None,
|
108
|
+
'c++': ('/*','*/')
|
109
|
+
}
|
110
|
+
inline_comments = {
|
111
|
+
'python': '#',
|
112
|
+
'ruby': '#',
|
113
|
+
'c++': '//'
|
114
|
+
}
|
115
|
+
|
116
|
+
def print_stderr(line):
|
117
|
+
sys.stderr.write(line+os.linesep)
|
118
|
+
|
119
|
+
def sub_keyword(mo):
|
120
|
+
'''re.subs() argument to tag keywords.'''
|
121
|
+
word = mo.group('word')
|
122
|
+
if word in keywords[language]:
|
123
|
+
stag,etag = keywordtags[backend]
|
124
|
+
return stag+word+etag
|
125
|
+
else:
|
126
|
+
return word
|
127
|
+
|
128
|
+
def code_filter():
|
129
|
+
'''This function does all the work.'''
|
130
|
+
global language, backend
|
131
|
+
inline_comment = inline_comments[language]
|
132
|
+
blk_comment = block_comments[language]
|
133
|
+
if blk_comment:
|
134
|
+
blk_comment = (re.escape(block_comments[language][0]),
|
135
|
+
re.escape(block_comments[language][1]))
|
136
|
+
stag,etag = commenttags[backend]
|
137
|
+
in_comment = 0 # True if we're inside a multi-line block comment.
|
138
|
+
tag_comment = 0 # True if we should tag the current line as a comment.
|
139
|
+
line = sys.stdin.readline()
|
140
|
+
while line:
|
141
|
+
line = string.rstrip(line)
|
142
|
+
line = string.expandtabs(line,tabsize)
|
143
|
+
# Escape special characters.
|
144
|
+
line = string.replace(line,'&','&')
|
145
|
+
line = string.replace(line,'<','<')
|
146
|
+
line = string.replace(line,'>','>')
|
147
|
+
# Process block comment.
|
148
|
+
if blk_comment:
|
149
|
+
if in_comment:
|
150
|
+
if re.match(r'.*'+blk_comment[1]+r'$',line):
|
151
|
+
in_comment = 0
|
152
|
+
else:
|
153
|
+
if re.match(r'^\s*'+blk_comment[0]+r'.*'+blk_comment[1],line):
|
154
|
+
# Single line block comment.
|
155
|
+
tag_comment = 1
|
156
|
+
elif re.match(r'^\s*'+blk_comment[0],line):
|
157
|
+
# Start of multi-line block comment.
|
158
|
+
tag_comment = 1
|
159
|
+
in_comment = 1
|
160
|
+
else:
|
161
|
+
tag_comment = 0
|
162
|
+
if tag_comment:
|
163
|
+
if line: line = stag+line+etag
|
164
|
+
else:
|
165
|
+
if inline_comment:
|
166
|
+
pos = string.find(line,inline_comment)
|
167
|
+
else:
|
168
|
+
pos = -1
|
169
|
+
if pos >= 0:
|
170
|
+
# Process inline comment.
|
171
|
+
line = re.sub(r'\b(?P<word>\w+)\b',sub_keyword,line[:pos]) \
|
172
|
+
+ stag + line[pos:] + etag
|
173
|
+
else:
|
174
|
+
line = re.sub(r'\b(?P<word>\w+)\b',sub_keyword,line)
|
175
|
+
sys.stdout.write(line + os.linesep)
|
176
|
+
line = sys.stdin.readline()
|
177
|
+
|
178
|
+
def usage(msg=''):
|
179
|
+
if msg:
|
180
|
+
print_stderr(msg)
|
181
|
+
print_stderr('Usage: code-filter -b backend -l language [ -t tabsize ]')
|
182
|
+
print_stderr(' [ --help | -h ] [ --version | -v ]')
|
183
|
+
|
184
|
+
def main():
|
185
|
+
global language, backend, tabsize
|
186
|
+
# Process command line options.
|
187
|
+
import getopt
|
188
|
+
opts,args = getopt.getopt(sys.argv[1:],
|
189
|
+
'b:l:ht:v',
|
190
|
+
['help','version'])
|
191
|
+
if len(args) > 0:
|
192
|
+
usage()
|
193
|
+
sys.exit(1)
|
194
|
+
for o,v in opts:
|
195
|
+
if o in ('--help','-h'):
|
196
|
+
print __doc__
|
197
|
+
sys.exit(0)
|
198
|
+
if o in ('--version','-v'):
|
199
|
+
print('code-filter version %s' % (VERSION,))
|
200
|
+
sys.exit(0)
|
201
|
+
if o == '-b': backend = v
|
202
|
+
if o == '-l':
|
203
|
+
v = string.lower(v)
|
204
|
+
if v == 'c': v = 'c++'
|
205
|
+
language = v
|
206
|
+
if o == '-t':
|
207
|
+
try:
|
208
|
+
tabsize = int(v)
|
209
|
+
except:
|
210
|
+
usage('illegal tabsize')
|
211
|
+
sys.exit(1)
|
212
|
+
if tabsize <= 0:
|
213
|
+
usage('illegal tabsize')
|
214
|
+
sys.exit(1)
|
215
|
+
if backend is None:
|
216
|
+
usage('backend option is mandatory')
|
217
|
+
sys.exit(1)
|
218
|
+
if not keywordtags.has_key(backend):
|
219
|
+
usage('illegal backend option')
|
220
|
+
sys.exit(1)
|
221
|
+
if language is None:
|
222
|
+
usage('language option is mandatory')
|
223
|
+
sys.exit(1)
|
224
|
+
if not keywords.has_key(language):
|
225
|
+
usage('illegal language option')
|
226
|
+
sys.exit(1)
|
227
|
+
# Do the work.
|
228
|
+
code_filter()
|
229
|
+
|
230
|
+
if __name__ == "__main__":
|
231
|
+
try:
|
232
|
+
main()
|
233
|
+
except (KeyboardInterrupt, SystemExit):
|
234
|
+
pass
|
235
|
+
except:
|
236
|
+
print_stderr("%s: unexpected exit status: %s" %
|
237
|
+
(os.path.basename(sys.argv[0]), sys.exc_info()[1]))
|
238
|
+
# Exit with previous sys.exit() status or zero if no sys.exit().
|
239
|
+
sys.exit(sys.exc_info()[1])
|