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
@@ -0,0 +1,86 @@
1
+ <%
2
+ # Template based on Asciidoc's default layout. This isn't
3
+ def visit_heading(heading, max_levels = 2, result = "")
4
+ if multi_page?
5
+ result << %Q{
6
+ <div class="toclevel#{heading.level - 1}">
7
+ <a href="#{h heading.basename}#{h heading.anchor}">#{heading.title}</a>
8
+ </div>
9
+ }.strip
10
+ else
11
+ result << %Q{
12
+ <div class="toclevel#{heading.level - 1}">
13
+ <a href="#{h heading.anchor}">#{heading.title}</a>
14
+ </div>
15
+ }.strip
16
+ end
17
+ if heading.level <= max_levels
18
+ heading.children.each do |h|
19
+ visit_heading(h, max_levels, result)
20
+ end
21
+ end
22
+ return result
23
+ end
24
+
25
+ def current_heading
26
+ return table_of_contents.find do |h|
27
+ h.title == current_chapter.title
28
+ end
29
+ end
30
+ %>
31
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
32
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
33
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
34
+ <head>
35
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
36
+ <meta name="generator" content="AsciiDoc 8.2.7" />
37
+ <style type="text/css">
38
+ <%= include_file('asciidoc.css') %>
39
+ </style>
40
+ <title><% if multi_page? && !is_preamble? %><%=h current_chapter.title_without_numbers %> :: <% end %><%=h title %></title>
41
+ </head>
42
+ <body>
43
+ <h1><%=h title %></h1>
44
+ <% if multi_page? && is_preamble? %>
45
+ <%= contents %>
46
+ <% end %>
47
+ <div id="toc">
48
+ <% if !multi_page? || is_preamble? %>
49
+ <h2>Table of contents</h2>
50
+ <%- for heading in table_of_contents -%>
51
+ <%= visit_heading(heading) %>
52
+ <%- end -%>
53
+ <% else %>
54
+ <div class="toclevel1 return_to_table_of_contents">
55
+ <a href="<%=h chapters.first.basename %>">&laquo; Return to table of contents</a>
56
+ </div>
57
+ <%= visit_heading(current_heading, 3) %>
58
+ <% end %>
59
+ </div>
60
+ <% if !multi_page? || !is_preamble? %>
61
+ <% if multi_page? %><h2><%=h current_chapter.title %></h2><% end %>
62
+ <%= contents %>
63
+ <% end %>
64
+ <%- if multi_page? -%>
65
+ <table id="chapter_navigation">
66
+ <tr>
67
+ <td class="left-floaty">
68
+ <% if prev_chapter %>
69
+ <a href="<%=h prev_chapter.basename %>">&laquo; <%= prev_chapter.title %></a>
70
+ <% end %>
71
+ </td>
72
+ <td class="center">
73
+ <% if !is_preamble? %>
74
+ <a href="<%=h chapters.first.basename %>">Table of contents</a>
75
+ <% end %>
76
+ </td>
77
+ <td class="right-floaty">
78
+ <% if next_chapter %>
79
+ <a href="<%=h next_chapter.basename %>"><%= next_chapter.title %> &raquo;</a>
80
+ <% end %>
81
+ </td>
82
+ </tr>
83
+ </table>
84
+ <%- end -%>
85
+ </body>
86
+ </html>
@@ -0,0 +1,165 @@
1
+ div#container {
2
+ max-width: 900px;
3
+ padding-bottom: 3em;
4
+ }
5
+
6
+ div#content {
7
+ margin-left: 200px;
8
+ }
9
+
10
+ div#container.notoc {
11
+ max-width: 600px;
12
+ }
13
+
14
+ .notoc div#content {
15
+ margin-left: 0;
16
+ }
17
+
18
+ pre {
19
+ line-height: 1.4em;
20
+ }
21
+
22
+ #content p tt {
23
+ background: #eeeeee;
24
+ border: solid 1px #cccccc;
25
+ padding: 3px;
26
+ }
27
+
28
+ dt {
29
+ font-weight: bold;
30
+ }
31
+
32
+ #content dt tt {
33
+ font-size: 10pt;
34
+ }
35
+
36
+ dd {
37
+ margin-left: 3em;
38
+ }
39
+
40
+ #content dt tt, #content pre tt {
41
+ background: none;
42
+ padding: 0;
43
+ border: 0;
44
+ }
45
+
46
+ #content .olist ol {
47
+ margin-left: 2em;
48
+ }
49
+
50
+ #header {
51
+ position: relative;
52
+ max-width: 840px;
53
+ margin-left: auto;
54
+ margin-right: auto;
55
+ }
56
+
57
+ #header.notoc {
58
+ max-width: 580px;
59
+ }
60
+
61
+ #logo {
62
+ position: absolute;
63
+ left: 10px;
64
+ top: 10px;
65
+ width: 110px;
66
+ height: 140px;
67
+ }
68
+
69
+ div#header h1#site_title {
70
+ background: url('http://web.rubyonrails.com/images/ruby_on_rails_by_mike_rundle2.gif') top left no-repeat;
71
+ position: absolute;
72
+ width: 392px;
73
+ height: 55px;
74
+ left: 145px;
75
+ top: 20px;
76
+ margin: 0;
77
+ padding: 0;
78
+ }
79
+
80
+ #site_title span {
81
+ display: none;
82
+ }
83
+
84
+ #site_title_tagline {
85
+ display: none;
86
+ }
87
+
88
+ ul#navMain {
89
+ position: absolute;
90
+ margin: 0;
91
+ padding: 0;
92
+ top: 97px;
93
+ left: 145px;
94
+ }
95
+
96
+ .left-floaty, .right-floaty {
97
+ padding: 15px;
98
+ }
99
+
100
+ .admonitionblock,
101
+ .tableblock {
102
+ margin-left: 1em;
103
+ margin-right: 1em;
104
+ margin-top: 0.25em;
105
+ margin-bottom: 1em;
106
+ }
107
+
108
+ .admonitionblock .icon {
109
+ padding-right: 8px;
110
+ }
111
+
112
+ .admonitionblock .content {
113
+ border: solid 1px #ffda78;
114
+ background: #fffebd;
115
+ padding: 10px;
116
+ padding-top: 8px;
117
+ padding-bottom: 8px;
118
+ }
119
+
120
+ .admonitionblock .title {
121
+ font-size: 140%;
122
+ margin-bottom: 0.5em;
123
+ }
124
+
125
+ .tableblock table {
126
+ border: solid 1px #aaaaff;
127
+ background: #f0f0ff;
128
+ }
129
+
130
+ .tableblock th {
131
+ background: #e0e0e0;
132
+ }
133
+
134
+ .tableblock th,
135
+ .tableblock td {
136
+ padding: 3px;
137
+ padding-left: 5px;
138
+ padding-right: 5px;
139
+ }
140
+
141
+ .sidebarblock {
142
+ margin-top: 0.25em;
143
+ margin: 1em;
144
+ border: solid 1px #ccccbb;
145
+ padding: 8px;
146
+ background: #ffffe0;
147
+ }
148
+
149
+ .sidebarblock .sidebar-title {
150
+ font-size: 140%;
151
+ font-weight: 600;
152
+ margin-bottom: 0.3em;
153
+ }
154
+
155
+ .sidebarblock .sidebar-content > .para:last-child > p {
156
+ margin-bottom: 0;
157
+ }
158
+
159
+ .sidebarblock .sidebar-title a {
160
+ text-decoration: none;
161
+ }
162
+
163
+ .sidebarblock .sidebar-title a:hover {
164
+ text-decoration: underline;
165
+ }
@@ -0,0 +1,97 @@
1
+ <%-
2
+ manuals_index_url = ENV['MANUALSONRAILS_INDEX_URL'] || "http://manuals.rubyonrails.org/"
3
+ show_toc = ENV['MANUALSONRAILS_TOC'] != 'no'
4
+ -%>
5
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
6
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
7
+ <head>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
9
+ <title><%- if multi_page? && !is_preamble? -%><%=h current_chapter.plain_title %> :: <% end %><%=h title %></title>
10
+ <!--[if lt IE 8]>
11
+ <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
12
+ <![endif]-->
13
+ <link href="http://manuals.rubyonrails.org/stylesheets/base.css" media="screen" rel="Stylesheet" type="text/css" />
14
+ <link href="http://manuals.rubyonrails.org/stylesheets/forms.css" media="screen" rel="Stylesheet" type="text/css" />
15
+ <link href="http://manuals.rubyonrails.org/stylesheets/more.css" media="screen" rel="Stylesheet" type="text/css" />
16
+ <style type="text/css">
17
+ <%= include_file('manualsonrails.css') %>
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <div id="header" <% if !show_toc %> class="notoc"<% end %>>
22
+ <div id="logo">
23
+ <a href="http://www.rubyonrails.org/" title="Ruby on Rails"><img src="http://web.rubyonrails.com/images/rails_logo_remix.gif" alt="Rails" height="140" width="110" /></a>
24
+ </div>
25
+
26
+ <h1 id="site_title"><span>Ruby on Rails</span></h1>
27
+ <h2 id="site_title_tagline">Sustainable productivity for web-application development</h2>
28
+
29
+ <ul id="navMain">
30
+ <li class="first-child"><a href="http://www.rubyonrails.org/" title="Ruby on Rails" class="ruby_on_rails">Ruby on Rails</a></li>
31
+ <li><a class="manuals" href="<%=h manuals_index_url %>" title="Manuals Index">Manuals Index</a></li>
32
+ </ul>
33
+ </div>
34
+
35
+ <div id="container"<% if !show_toc %> class="notoc"<% end %>>
36
+ <% if show_toc %>
37
+ <div id="sidebar">
38
+ <h2>Chapters</h2>
39
+ <%- if multi_page? -%>
40
+ <a href="<%=h chapters.first.basename %>">Preamble</a>
41
+ <%- end -%>
42
+ <ol>
43
+ <%- if multi_page? -%>
44
+ <%- for heading in table_of_contents -%>
45
+ <li>
46
+ <a href="<%=h heading.basename %>"><%= heading.title_without_numbers %></a>
47
+ <%- if !heading.children.empty? -%>
48
+ <ul>
49
+ <% for h in heading.children %>
50
+ <li><a href="<%=h h.basename %><%=h h.anchor %>"><%= h.title_without_numbers %></a></li>
51
+ <% end %>
52
+ </ul>
53
+ <%- end -%>
54
+ </li>
55
+ <%- end -%>
56
+ <%- else -%>
57
+ <%- for heading in table_of_contents -%>
58
+ <li>
59
+ <a href="<%=h heading.anchor %>"><%= heading.title_without_numbers %></a>
60
+ <%- if !heading.children.empty? -%>
61
+ <ul>
62
+ <% for h in heading.children %>
63
+ <li><a href="<%=h h.anchor %>"><%= h.title_without_numbers %></a></li>
64
+ <% end %>
65
+ </ul>
66
+ <%- end -%>
67
+ </li>
68
+ <%- end -%>
69
+ <%- end -%>
70
+ </ol>
71
+ </div>
72
+ <% end %>
73
+ <div id="content">
74
+ <%- if multi_page? && !is_preamble? -%>
75
+ <h2 id="<%=h current_chapter.anchor_id %>"><%= current_chapter.title %></h2>
76
+ <%- else -%>
77
+ <h1><%=h title %></h1>
78
+ <%- end -%>
79
+ <%= contents %>
80
+ <%- if multi_page? -%>
81
+ <div id="chapter_navigation">
82
+ <%- if prev_chapter -%>
83
+ <div class="left-floaty">
84
+ <a href="<%=h prev_chapter.basename %>">&laquo; <%= prev_chapter.title %></a>
85
+ </div>
86
+ <%- end -%>
87
+ <%- if next_chapter -%>
88
+ <div class="right-floaty">
89
+ <a href="<%=h next_chapter.basename %>"><%= next_chapter.title %> &raquo;</a>
90
+ </div>
91
+ <%- end -%>
92
+ </div>
93
+ <%- end -%>
94
+ </div>
95
+ </div>
96
+ </body>
97
+ </html>
@@ -0,0 +1,190 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'mizuho/parser'
3
+
4
+ shared_examples_for "an Asciidoc document with 3 chapters" do
5
+ it "extracts the chapter contents" do
6
+ @chapter_one.contents.should =~ /Chapter 1 contents/
7
+ @chapter_two.contents.should =~ /Chapter 2 contents/
8
+ end
9
+
10
+ specify "the extracted chapter contents include (sub)section contents as well" do
11
+ @chapter_two.contents.should =~ /Subsection/
12
+ @chapter_two.contents.should =~ /This is a subsection/
13
+ end
14
+
15
+ it "doesn't HTML-escape auto-generated HTML formatting tags in the title" do
16
+ @html_chapter.title.should =~ %r(<strong>Look</strong>)
17
+ end
18
+
19
+ it "HTML-escapes non-autogenerated HTML tags in the title" do
20
+ @html_chapter.title.should =~ %r(&lt;i&gt;hurray&lt;/i&gt;)
21
+ end
22
+
23
+ it "HTML-escapes non-HTML special characters in the title" do
24
+ @html_chapter.title.should =~ %r(&lt;3)
25
+ end
26
+ end
27
+
28
+ describe Mizuho::Parser do
29
+ it "extracts the title" do
30
+ parser = generate_and_parse(%Q{
31
+ = Hello world
32
+ A sample document.
33
+ })
34
+ parser.title.should == "Hello world"
35
+ end
36
+
37
+ specify "the extracted title is not HTML escaped" do
38
+ parser = generate_and_parse(%Q{
39
+ = *Look at this!* 2 < 1!
40
+ A sample document.
41
+ })
42
+ parser.title.should == "<strong>Look at this!</strong> 2 < 1!"
43
+ end
44
+
45
+ describe "construction of table of contents" do
46
+ before :each do
47
+ @parser = generate_and_parse(%Q{
48
+ = Hello world
49
+ A sample document.
50
+
51
+ == Scientists Erase Specific Memories In Mice
52
+ It sounds like science fiction, but scientists say it might
53
+ one day be possible to erase undesirable memories from the
54
+ brain, selectively and safely.
55
+
56
+ === How it works
57
+ After exposing mice to emotionally powerful stimuli, such
58
+ as a mild shock to their paws, the scientists then observed
59
+ how well or poorly the animals subsequently recalled the
60
+ particular trauma as their brain's expression of CaMKII was
61
+ manipulated up and down. When the brain was made to
62
+ overproduce CaMKII at the exact moment the mouse was prodded
63
+ to retrieve the traumatic memory, the memory wasn't just
64
+ blocked, it appeared to be fully erased.
65
+
66
+ == Researchers Developing Cancer-Fighting Beer
67
+ Ever picked up a cold, frosty beer on a hot summer's day
68
+ and thought that it simply couldn't get any better? Well,
69
+ think again. A team of researchers at Rice University in
70
+ Houston is working on helping Joe Six Pack fight aging and
71
+ cancer with every swill of beer.
72
+
73
+ === Comment by samzenpus
74
+ Thank you science! Now we just need cigarettes that cure baldness.
75
+
76
+ == *Look*, non-HTML special characters <3, <i>hurray</i>
77
+ })
78
+ @toc = @parser.table_of_contents
79
+ end
80
+
81
+ it "contains all headers" do
82
+ @toc.should have(3).items
83
+
84
+ @toc[0].title.should =~ /Scientists Erase Specific Memories In Mice/
85
+ @toc[0].children.should have(1).item
86
+ @toc[0].children[0].title.should =~ /How it works/
87
+
88
+ @toc[1].title.should =~ /Researchers Developing Cancer-Fighting Beer/
89
+ @toc[1].children.should have(1).item
90
+ @toc[1].children[0].title.should =~ /Comment by samzenpus/
91
+
92
+ @toc[2].title.should =~ /Look/
93
+ @toc[2].children.should be_empty
94
+ end
95
+
96
+ it "records the corresponding header levels" do
97
+ @toc[0].level.should == 2
98
+ @toc[0].children[0].level.should == 3
99
+ @toc[1].level.should == 2
100
+ @toc[1].children[0].level.should == 3
101
+ @toc[2].level.should == 2
102
+ end
103
+
104
+ it "doesn't HTML-escape auto-generated HTML formatting tags in the title" do
105
+ @toc[2].title.should =~ %r(<strong>Look</strong>)
106
+ end
107
+
108
+ it "HTML-escapes non-autogenerated HTML tags in the title" do
109
+ @toc[2].title.should =~ %r(&lt;i&gt;hurray&lt;/i&gt;)
110
+ end
111
+
112
+ it "HTML-escapes non-HTML special characters in the title" do
113
+ @toc[2].title.should =~ %r(&lt;3)
114
+ end
115
+
116
+ it "prepends heading titles with a corresponding section number" do
117
+ @toc[0].title.should =~ /^1\. /
118
+ @toc[0].children[0].title.should =~ /^1\.1\. /
119
+
120
+ @toc[1].title.should =~ /^2\. /
121
+ @toc[1].children[0].title.should =~ /^2\.1\. /
122
+
123
+ @toc[2].title.should =~ /^3\. /
124
+ end
125
+ end
126
+
127
+ describe "chapter extraction" do
128
+ def test_input(with_preamble)
129
+ return %Q{
130
+ = Hello world
131
+
132
+ #{"A preamble." if with_preamble}
133
+
134
+ == Chapter 1
135
+ Chapter 1 contents.
136
+
137
+ == Chapter 2
138
+ Chapter 2 contents.
139
+
140
+ === Subsection
141
+ This is a subsection.
142
+
143
+ == *Look*, non-HTML special characters <3, <i>hurray</i>
144
+ }
145
+ end
146
+
147
+
148
+ describe "when there is a premable" do
149
+ before :each do
150
+ @parser = generate_and_parse(test_input(true))
151
+ @chapters = @parser.chapters
152
+ @chapter_one = @chapters[1]
153
+ @chapter_two = @chapters[2]
154
+ @html_chapter = @chapters[3]
155
+ end
156
+
157
+ it "consists of a preamble followed by level 2 headings" do
158
+ @chapters.should have(4).items
159
+ end
160
+
161
+ specify "the preamble chapter has no title" do
162
+ @chapters.first.title.should be_nil
163
+ end
164
+
165
+ it_should_behave_like "an Asciidoc document with 3 chapters"
166
+ end
167
+
168
+ describe "when there is no preamble" do
169
+ def default_test_input
170
+ return test_input(false)
171
+ end
172
+
173
+ before :each do
174
+ @parser = generate_and_parse(test_input(false))
175
+ @chapters = @parser.chapters
176
+ @chapter_one = @chapters[0]
177
+ @chapter_two = @chapters[1]
178
+ @html_chapter = @chapters[2]
179
+ end
180
+
181
+ it "consists of only level 2 headings" do
182
+ @chapters.should have(3).items
183
+ end
184
+
185
+ it_should_behave_like "an Asciidoc document with 3 chapters"
186
+ end
187
+ end
188
+
189
+ it "fixes cross-chapter references when in multi-page output mode"
190
+ end