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
Binary file
@@ -0,0 +1,158 @@
1
+ Music Filter
2
+ ============
3
+
4
+ The AsciiDoc distribution includes a Music Block filter that
5
+ translates music in http://lilypond.org/[LilyPond] or
6
+ http://abcnotation.org.uk/[ABC] notation to standard classical
7
+ notation in the form of a trimmed PNG image which is automatically
8
+ inserted into the AsciiDoc output document (see the <<X1,examples
9
+ below>>).
10
+
11
+ Actually the filter (`./filters/music2png.py`) can be used outside
12
+ AsciiDoc to convert LilyPond or ABC music files to PNG images.
13
+ Execute the following command to see how to use it:
14
+
15
+ $ ./filters/music2png.py --help
16
+
17
+ The Music Filter can be used as a model for filters that convert a
18
+ block of text into a file that is linked or embedded into the AsciiDoc
19
+ output document.
20
+
21
+ [[X1]]
22
+ [caption="Example 1: "]
23
+ .Music Block containing ABC notation
24
+ =====================================================================
25
+
26
+ This Music Block:
27
+
28
+ ---------------------------------------------------------------------
29
+ [music,music1.png]
30
+ ---------------------------------------------------------------------
31
+ T:The Butterfly
32
+ R:slip jig
33
+ C:Tommy Potts
34
+ H:Fiddle player Tommy Potts made this tune from two older slip jigs,
35
+ H:one of which is called "Skin the Peelers" in Roche's collection.
36
+ H:This version by Peter Cooper.
37
+ D:Bothy Band: 1975.
38
+ M:9/8
39
+ K:Em
40
+ vB2(E G2)(E F3)|B2(E G2)(E F)ED|vB2(E G2)(E F3)|(B2d) d2(uB A)FD:|
41
+ |:(vB2c) (e2f) g3|(uB2d) (g2e) (dBA)|(B2c) (e2f) g2(ua|b2a) (g2e) (dBA):|
42
+ |:~B3 (B2A) G2A|~B3 BA(uB d)BA|~B3 (B2A) G2(A|B2d) (g2e) (dBA):|
43
+ ---------------------------------------------------------------------
44
+ ---------------------------------------------------------------------
45
+
46
+ Renders:
47
+
48
+ [music,music1.png]
49
+ ---------------------------------------------------------------------
50
+ T:The Butterfly
51
+ R:slip jig
52
+ C:Tommy Potts
53
+ H:Fiddle player Tommy Potts made this tune from two older slip jigs,
54
+ H:one of which is called "Skin the Peelers" in Roche's collection.
55
+ H:This version by Peter Cooper.
56
+ D:Bothy Band: 1975.
57
+ M:9/8
58
+ K:Em
59
+ vB2(E G2)(E F3)|B2(E G2)(E F)ED|vB2(E G2)(E F3)|(B2d) d2(uB A)FD:|
60
+ |:(vB2c) (e2f) g3|(uB2d) (g2e) (dBA)|(B2c) (e2f) g2(ua|b2a) (g2e) (dBA):|
61
+ |:~B3 (B2A) G2A|~B3 BA(uB d)BA|~B3 (B2A) G2(A|B2d) (g2e) (dBA):|
62
+ ---------------------------------------------------------------------
63
+ =====================================================================
64
+
65
+
66
+ [[X2]]
67
+ [caption="Example 2: "]
68
+ .Music Block containing LilyPond notation
69
+ =====================================================================
70
+ This example contains LilyPond musical markup, it uses the 'link'
71
+ attribute so you can click on the music image to display the source
72
+ notation. The `music2.ly` source file is automatically created and
73
+ retained by the `music2png.py` filter when the `-m` option is used.
74
+
75
+ ---------------------------------------------------------------------
76
+ ["music", "music2.png", "ly", link="music2.ly"]
77
+ ---------------------------------------------------------------------
78
+ \version "2.10.0"
79
+ \paper {
80
+ ragged-right = ##t
81
+ }
82
+ {
83
+ \time 3/4
84
+ \clef bass
85
+ c2 e4 g2. f4 e d c2 r4
86
+ }
87
+ ---------------------------------------------------------------------
88
+ ---------------------------------------------------------------------
89
+
90
+ Renders:
91
+
92
+ ["music", "music2.png", "ly", link="music2.ly"]
93
+ ---------------------------------------------------------------------
94
+ \version "2.10.0"
95
+ \paper {
96
+ ragged-right = ##t
97
+ }
98
+ {
99
+ \time 3/4
100
+ \clef bass
101
+ c2 e4 g2. f4 e d c2 r4
102
+ }
103
+ ---------------------------------------------------------------------
104
+ =====================================================================
105
+
106
+ NOTE: If you get an error processing the above example it may be that
107
+ it is not compatible with your version of LilyPond. Use the LilyPond
108
+ `convert-ly(1)` utility to update the source to the version that you
109
+ are using.
110
+
111
+
112
+ Using the Filter
113
+ ----------------
114
+ Insert a delimited Music Block containing valid ABC notation into your
115
+ AsciiDoc document:
116
+
117
+ - The Music Block delimiter is the word `music` followed by four or
118
+ more tilde characters.
119
+ - The Music Block attribute list must contain a file name for the PNG
120
+ output image file followed by the input format (either 'abc' for ABC
121
+ or 'ly' for LilyPond). If the format is omitted ABC notation is
122
+ assumed.
123
+ - The filter invokes `music2png` with the `-m` option so that music
124
+ images will only be regenerated if the block content has changed.
125
+ - The optional named block attributes 'link', 'width' and 'height' are
126
+ also available (see link:userguide.html#X55[Image macro attributes]
127
+ in the AsciiDoc User Guide).
128
+
129
+
130
+ Limitations
131
+ -----------
132
+ - The `asciidoc(1)` output file cannot be `-` (stdout), you must
133
+ output to a named file.
134
+ - If the music image file is linked to the output document then the
135
+ image file name in the Music Block attribute list should be a
136
+ relative path name relative to the AsciiDoc output file.
137
+
138
+
139
+ Installation
140
+ ------------
141
+ In addition to AsciiDoc you will need to have installed:
142
+
143
+ - http://lilypond.org/web/[LilyPond] (most Linux distributions include
144
+ this package).
145
+ - http://www.imagemagick.org[ImageMagick] (most Linux distributions
146
+ include this package).
147
+
148
+ Test the music filter it by converting the test file to HTML with AsciiDoc:
149
+
150
+ $ asciidoc -v ./filters/music-filter-test.txt
151
+ $ firefox ./filters/music-filter-test.html &
152
+
153
+ The filter was developed and tested on Xubuntu Linux using LilyPond
154
+ 2.10.5 and ImageMagick 6.2.4.
155
+
156
+ NOTE: The filter does not work with LilyPond 2.2.6 because it did not
157
+ generate the requested output file name correctly (2.6.3 does not have
158
+ a problem).
@@ -0,0 +1,183 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <meta name="generator" content="AsciiDoc 8.2.7">
6
+ <title>Source Code Highlight Filter</title>
7
+ </head>
8
+ <body>
9
+ <h1>Source Code Highlight Filter</h1>
10
+ <p>
11
+ </p>
12
+ <p>The <em>AsciiDoc</em> distribution includes a source code syntax highlight
13
+ filter (<tt>source-highlight-filter.conf</tt>). It uses
14
+ <a href="http://www.gnu.org/software/src-highlite/">GNU source-highlight</a> to
15
+ highlight HTML outputs; DocBook outputs are highlighted by toolchains
16
+ that have <tt>programlisting</tt> element highlight support, for example
17
+ <em>dblatex</em>.</p>
18
+ <p><b>Tip:</b> If the source <em>language</em> attribute has been set (using an
19
+ <em>AttributeEntry</em> or from the command-line) you don't have to specify
20
+ it in each source code block.</p>
21
+ <hr />
22
+ <h2><a name="_examples"></a>Examples</h2>
23
+ <h3><a name="_source_code_paragraphs"></a>Source code paragraphs</h3>
24
+ <p>The <tt>source</tt> paragraph style will highlight a paragraph of source
25
+ code. These three code paragraphs:</p>
26
+ <table border="0" bgcolor="#e8e8e8" width="100%" cellpadding="10"><tr><td>
27
+ <pre>[source,python]
28
+ if n &lt; 0: print 'Hello World!'
29
+
30
+ :language: python
31
+
32
+ [source]
33
+ if n &lt; 0: print 'Hello World!'
34
+
35
+ [source,ruby,numbered]
36
+ [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
37
+ puts "#{a.inspect} =&gt; #{b.inspect}"</pre>
38
+ </td></tr></table>
39
+ <p>Render this highlighted source code:</p>
40
+ <!-- Generator: GNU source-highlight 2.4
41
+ by Lorenzo Bettini
42
+ http://www.lorenzobettini.it
43
+ http://www.gnu.org/software/src-highlite -->
44
+ <pre><tt><b><font color="#0000FF">if</font></b> n <font color="#990000">&lt;</font> <font color="#993399">0</font><font color="#990000">:</font> <b><font color="#0000FF">print</font></b> <font color="#FF0000">'Hello World!'</font>
45
+ </tt></pre>
46
+ <!-- Generator: GNU source-highlight 2.4
47
+ by Lorenzo Bettini
48
+ http://www.lorenzobettini.it
49
+ http://www.gnu.org/software/src-highlite -->
50
+ <pre><tt><b><font color="#0000FF">if</font></b> n <font color="#990000">&lt;</font> <font color="#993399">0</font><font color="#990000">:</font> <b><font color="#0000FF">print</font></b> <font color="#FF0000">'Hello World!'</font>
51
+ </tt></pre>
52
+ <!-- Generator: GNU source-highlight 2.4
53
+ by Lorenzo Bettini
54
+ http://www.lorenzobettini.it
55
+ http://www.gnu.org/software/src-highlite -->
56
+ <pre><tt><font color="#000000">00001:</font> <font color="#990000">[</font><b><font color="#0000FF">true</font></b><font color="#990000">,</font> <b><font color="#0000FF">false</font></b><font color="#990000">].</font><b><font color="#000000">cycle</font></b><font color="#990000">([</font><font color="#993399">0</font><font color="#990000">,</font> <font color="#993399">1</font><font color="#990000">,</font> <font color="#993399">2</font><font color="#990000">,</font> <font color="#993399">3</font><font color="#990000">,</font> <font color="#993399">4</font><font color="#990000">])</font> <b><font color="#0000FF">do</font></b> <font color="#990000">|</font>a<font color="#990000">,</font> b<font color="#990000">|</font>
57
+ <font color="#000000">00002:</font> puts <font color="#FF0000">"#{a.inspect} =&gt; #{b.inspect}"</font>
58
+ </tt></pre>
59
+ <h3><a name="_unnumbered_source_code_listing"></a>Unnumbered source code listing</h3>
60
+ <p>This source-highlight filtered block:</p>
61
+ <table border="0" bgcolor="#e8e8e8" width="100%" cellpadding="10"><tr><td>
62
+ <pre> [source,python]
63
+ ---------------------------------------------------------------------
64
+ ''' A multi-line
65
+ comment.'''
66
+ def sub_word(mo):
67
+ ''' Single line comment.'''
68
+ word = mo.group('word') # Inline comment
69
+ if word in keywords[language]:
70
+ return quote + word + quote
71
+ else:
72
+ return word
73
+ ---------------------------------------------------------------------</pre>
74
+ </td></tr></table>
75
+ <p>Renders this highlighted source code:</p>
76
+ <table border="0" bgcolor="#e8e8e8" width="100%" cellpadding="10"><tr><td>
77
+ <pre><!-- Generator: GNU source-highlight 2.4
78
+ by Lorenzo Bettini
79
+ http://www.lorenzobettini.it
80
+ http://www.gnu.org/software/src-highlite -->
81
+ <pre><tt><i><font color="#9A1900">''' A multi-line</font></i>
82
+ <i><font color="#9A1900"> comment.'''</font></i>
83
+ <b><font color="#0000FF">def</font></b> <b><font color="#000000">sub_word</font></b><font color="#990000">(</font>mo<font color="#990000">):</font>
84
+ <i><font color="#9A1900"> ''' Single line comment.'''</font></i>
85
+ word <font color="#990000">=</font> mo<font color="#990000">.</font><b><font color="#000000">group</font></b><font color="#990000">(</font><font color="#FF0000">'word'</font><font color="#990000">)</font> <i><font color="#9A1900"># Inline comment</font></i>
86
+ <b><font color="#0000FF">if</font></b> word <b><font color="#0000FF">in</font></b> keywords<font color="#990000">[</font>language<font color="#990000">]:</font>
87
+ <b><font color="#0000FF">return</font></b> quote <font color="#990000">+</font> word <font color="#990000">+</font> quote
88
+ <b><font color="#0000FF">else</font></b><font color="#990000">:</font>
89
+ <b><font color="#0000FF">return</font></b> word
90
+ </tt></pre></pre>
91
+ </td></tr></table>
92
+ <h3><a name="_numbered_source_code_listing"></a>Numbered source code listing</h3>
93
+ <p>This source-highlight filtered block:</p>
94
+ <table border="0" bgcolor="#e8e8e8" width="100%" cellpadding="10"><tr><td>
95
+ <pre> [source,ruby,numbered]
96
+ ---------------------------------------------------------------------
97
+ #
98
+ # Useful Ruby base class extensions.
99
+ #
100
+
101
+ class Array
102
+
103
+ # Execute a block passing it corresponding items in
104
+ # +self+ and +other_array+.
105
+ # If self has less items than other_array it is repeated.
106
+
107
+ def cycle(other_array) # :yields: item, other_item
108
+ other_array.each_with_index do |item, index|
109
+ yield(self[index % self.length], item)
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+ if $0 == __FILE__
116
+ # Array#cycle test
117
+ # true =&gt; 0
118
+ # false =&gt; 1
119
+ # true =&gt; 2
120
+ # false =&gt; 3
121
+ # true =&gt; 4
122
+ puts 'Array#cycle test'
123
+ [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
124
+ puts "#{a.inspect} =&gt; #{b.inspect}"
125
+ end
126
+ end
127
+ ---------------------------------------------------------------------</pre>
128
+ </td></tr></table>
129
+ <p>Renders this highlighted source code:</p>
130
+ <table border="0" bgcolor="#e8e8e8" width="100%" cellpadding="10"><tr><td>
131
+ <pre><!-- Generator: GNU source-highlight 2.4
132
+ by Lorenzo Bettini
133
+ http://www.lorenzobettini.it
134
+ http://www.gnu.org/software/src-highlite -->
135
+ <pre><tt><font color="#000000">00001:</font> <i><font color="#9A1900">#</font></i>
136
+ <font color="#000000">00002:</font> <i><font color="#9A1900"># Useful Ruby base class extensions.</font></i>
137
+ <font color="#000000">00003:</font> <i><font color="#9A1900">#</font></i>
138
+ <font color="#000000">00004:</font>
139
+ <font color="#000000">00005:</font> <b><font color="#0000FF">class</font></b> Array
140
+ <font color="#000000">00006:</font>
141
+ <font color="#000000">00007:</font> <i><font color="#9A1900"># Execute a block passing it corresponding items in</font></i>
142
+ <font color="#000000">00008:</font> <i><font color="#9A1900"># +self+ and +other_array+.</font></i>
143
+ <font color="#000000">00009:</font> <i><font color="#9A1900"># If self has less items than other_array it is repeated.</font></i>
144
+ <font color="#000000">00010:</font>
145
+ <font color="#000000">00011:</font> <b><font color="#0000FF">def</font></b> <b><font color="#000000">cycle</font></b><font color="#990000">(</font>other_array<font color="#990000">)</font> <i><font color="#9A1900"># :yields: item, other_item</font></i>
146
+ <font color="#000000">00012:</font> other_array<font color="#990000">.</font>each_with_index <b><font color="#0000FF">do</font></b> <font color="#990000">|</font>item<font color="#990000">,</font> index<font color="#990000">|</font>
147
+ <font color="#000000">00013:</font> <b><font color="#0000FF">yield</font></b><font color="#990000">(</font><b><font color="#0000FF">self</font></b><font color="#990000">[</font>index <font color="#990000">%</font> <b><font color="#0000FF">self</font></b><font color="#990000">.</font>length<font color="#990000">],</font> item<font color="#990000">)</font>
148
+ <font color="#000000">00014:</font> <b><font color="#0000FF">end</font></b>
149
+ <font color="#000000">00015:</font> <b><font color="#0000FF">end</font></b>
150
+ <font color="#000000">00016:</font>
151
+ <font color="#000000">00017:</font> <b><font color="#0000FF">end</font></b>
152
+ <font color="#000000">00018:</font>
153
+ <font color="#000000">00019:</font> <b><font color="#0000FF">if</font></b> <font color="#009900">$0</font> <font color="#990000">==</font> <b><font color="#0000FF">__FILE__</font></b>
154
+ <font color="#000000">00020:</font> <i><font color="#9A1900"># Array#cycle test</font></i>
155
+ <font color="#000000">00021:</font> <i><font color="#9A1900"># true =&gt; 0</font></i>
156
+ <font color="#000000">00022:</font> <i><font color="#9A1900"># false =&gt; 1</font></i>
157
+ <font color="#000000">00023:</font> <i><font color="#9A1900"># true =&gt; 2</font></i>
158
+ <font color="#000000">00024:</font> <i><font color="#9A1900"># false =&gt; 3</font></i>
159
+ <font color="#000000">00025:</font> <i><font color="#9A1900"># true =&gt; 4</font></i>
160
+ <font color="#000000">00026:</font> puts <font color="#FF0000">'Array#cycle test'</font>
161
+ <font color="#000000">00027:</font> <font color="#990000">[</font><b><font color="#0000FF">true</font></b><font color="#990000">,</font> <b><font color="#0000FF">false</font></b><font color="#990000">].</font><b><font color="#000000">cycle</font></b><font color="#990000">([</font><font color="#993399">0</font><font color="#990000">,</font> <font color="#993399">1</font><font color="#990000">,</font> <font color="#993399">2</font><font color="#990000">,</font> <font color="#993399">3</font><font color="#990000">,</font> <font color="#993399">4</font><font color="#990000">])</font> <b><font color="#0000FF">do</font></b> <font color="#990000">|</font>a<font color="#990000">,</font> b<font color="#990000">|</font>
162
+ <font color="#000000">00028:</font> puts <font color="#FF0000">"#{a.inspect} =&gt; #{b.inspect}"</font>
163
+ <font color="#000000">00029:</font> <b><font color="#0000FF">end</font></b>
164
+ <font color="#000000">00030:</font> <b><font color="#0000FF">end</font></b>
165
+ </tt></pre></pre>
166
+ </td></tr></table>
167
+ <hr />
168
+ <h2><a name="_installation"></a>Installation</h2>
169
+ <p>If you want to syntax highlight <em>AsciiDoc</em> HTML outputs you need to
170
+ install <a href="http://www.gnu.org/software/src-highlite/">GNU
171
+ source-highlight</a> (most distributions have this package). It's not
172
+ required if you are generating DocBook output (DocBook syntax
173
+ highlighting is handled by the DocBook toolchain).</p>
174
+ <p>Test the filter by converting the test file to HTML with <em>AsciiDoc</em>:</p>
175
+ <pre>$ asciidoc -v ./filters/source-highlight-filter-test.txt
176
+ $ firefox ./filters/source-highlight-filter-test.html &amp;</pre>
177
+ <p></p>
178
+ <p></p>
179
+ <hr /><p><small>
180
+ Last updated 2008-07-02 23:02:19 NZDT
181
+ </small></p>
182
+ </body>
183
+ </html>
@@ -0,0 +1,174 @@
1
+ Source Code Highlight Filter
2
+ ============================
3
+
4
+ The AsciiDoc distribution includes a source code syntax highlight
5
+ filter (`source-highlight-filter.conf`). It uses
6
+ http://www.gnu.org/software/src-highlite/[GNU source-highlight] to
7
+ highlight HTML outputs; DocBook outputs are highlighted by toolchains
8
+ that have `programlisting` element highlight support, for example
9
+ 'dblatex'.
10
+
11
+ TIP: If the source 'language' attribute has been set (using an
12
+ 'AttributeEntry' or from the command-line) you don't have to specify
13
+ it in each source code block.
14
+
15
+
16
+ Examples
17
+ --------
18
+ Source code paragraphs
19
+ ~~~~~~~~~~~~~~~~~~~~~~
20
+ The `source` paragraph style will highlight a paragraph of source
21
+ code. These three code paragraphs:
22
+
23
+ ---------------------------------------------------------------------
24
+ [source,python]
25
+ if n < 0: print 'Hello World!'
26
+
27
+ :language: python
28
+
29
+ [source]
30
+ if n < 0: print 'Hello World!'
31
+
32
+ [source,ruby,numbered]
33
+ [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
34
+ puts "#{a.inspect} => #{b.inspect}"
35
+ ---------------------------------------------------------------------
36
+
37
+ Render this highlighted source code:
38
+
39
+ [source,python]
40
+ if n < 0: print 'Hello World!'
41
+
42
+ :language: python
43
+
44
+ [source]
45
+ if n < 0: print 'Hello World!'
46
+
47
+ [source,ruby,numbered]
48
+ [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
49
+ puts "#{a.inspect} => #{b.inspect}"
50
+
51
+
52
+ Unnumbered source code listing
53
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54
+ This source-highlight filtered block:
55
+
56
+ ---------------------------------------------------------------------
57
+ [source,python]
58
+ ---------------------------------------------------------------------
59
+ ''' A multi-line
60
+ comment.'''
61
+ def sub_word(mo):
62
+ ''' Single line comment.'''
63
+ word = mo.group('word') # Inline comment
64
+ if word in keywords[language]:
65
+ return quote + word + quote
66
+ else:
67
+ return word
68
+ ---------------------------------------------------------------------
69
+ ---------------------------------------------------------------------
70
+
71
+ Renders this highlighted source code:
72
+
73
+ [source,python]
74
+ ---------------------------------------------------------------------
75
+ ''' A multi-line
76
+ comment.'''
77
+ def sub_word(mo):
78
+ ''' Single line comment.'''
79
+ word = mo.group('word') # Inline comment
80
+ if word in keywords[language]:
81
+ return quote + word + quote
82
+ else:
83
+ return word
84
+ ---------------------------------------------------------------------
85
+
86
+ Numbered source code listing
87
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88
+ This source-highlight filtered block:
89
+
90
+ ---------------------------------------------------------------------
91
+ [source,ruby,numbered]
92
+ ---------------------------------------------------------------------
93
+ #
94
+ # Useful Ruby base class extensions.
95
+ #
96
+
97
+ class Array
98
+
99
+ # Execute a block passing it corresponding items in
100
+ # +self+ and +other_array+.
101
+ # If self has less items than other_array it is repeated.
102
+
103
+ def cycle(other_array) # :yields: item, other_item
104
+ other_array.each_with_index do |item, index|
105
+ yield(self[index % self.length], item)
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ if $0 == __FILE__
112
+ # Array#cycle test
113
+ # true => 0
114
+ # false => 1
115
+ # true => 2
116
+ # false => 3
117
+ # true => 4
118
+ puts 'Array#cycle test'
119
+ [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
120
+ puts "#{a.inspect} => #{b.inspect}"
121
+ end
122
+ end
123
+ ---------------------------------------------------------------------
124
+ ---------------------------------------------------------------------
125
+
126
+ Renders this highlighted source code:
127
+
128
+ [source,ruby,numbered]
129
+ ---------------------------------------------------------------------
130
+ #
131
+ # Useful Ruby base class extensions.
132
+ #
133
+
134
+ class Array
135
+
136
+ # Execute a block passing it corresponding items in
137
+ # +self+ and +other_array+.
138
+ # If self has less items than other_array it is repeated.
139
+
140
+ def cycle(other_array) # :yields: item, other_item
141
+ other_array.each_with_index do |item, index|
142
+ yield(self[index % self.length], item)
143
+ end
144
+ end
145
+
146
+ end
147
+
148
+ if $0 == __FILE__
149
+ # Array#cycle test
150
+ # true => 0
151
+ # false => 1
152
+ # true => 2
153
+ # false => 3
154
+ # true => 4
155
+ puts 'Array#cycle test'
156
+ [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
157
+ puts "#{a.inspect} => #{b.inspect}"
158
+ end
159
+ end
160
+ ---------------------------------------------------------------------
161
+
162
+
163
+ Installation
164
+ ------------
165
+ If you want to syntax highlight AsciiDoc HTML outputs you need to
166
+ install http://www.gnu.org/software/src-highlite/[GNU
167
+ source-highlight] (most distributions have this package). It's not
168
+ required if you are generating DocBook output (DocBook syntax
169
+ highlighting is handled by the DocBook toolchain).
170
+
171
+ Test the filter by converting the test file to HTML with AsciiDoc:
172
+
173
+ $ asciidoc -v ./filters/source-highlight-filter-test.txt
174
+ $ firefox ./filters/source-highlight-filter-test.html &