radiant 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of radiant might be problematic. Click here for more details.

@@ -0,0 +1,25 @@
1
+ Redistribution and use in source and binary forms, with or without
2
+ modification, are permitted provided that the following conditions are met:
3
+
4
+ * Redistributions of source code must retain the above copyright notice,
5
+ this list of conditions and the following disclaimer.
6
+
7
+ * Redistributions in binary form must reproduce the above copyright notice,
8
+ this list of conditions and the following disclaimer in the documentation
9
+ and/or other materials provided with the distribution.
10
+
11
+ * Neither the name Textile nor the names of its contributors may be used to
12
+ endorse or promote products derived from this software without specific
13
+ prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,106 @@
1
+ p=. !redcloth3-title.png!
2
+
3
+ <div id="sidebar">
4
+
5
+ h4. Get RedCloth 3
6
+
7
+ p(example1). *Stable version:* "3.0.3":http://rubyforge.org/frs/download.php/2896/RedCloth-3.0.3.tar.gz
8
+
9
+ Take a complete tour of Textile at "A Textile Reference":http://hobix.com/textile/.
10
+
11
+ For fast syntax checking, try the "Quick Reference":http://hobix.com/textile/quick.html.
12
+
13
+ p(example1). Upgrade with "RubyGems":http://rubygems.rubyforge.org/! Try:
14
+ @gem install RedCloth@.
15
+
16
+ See the "project page":http://rubyforge.org/projects/redcloth/ for bug reporting, old releases and CVS instructions. "Documentation":http://redcloth.rubyforge.org/rdoc/ is also hosted at RubyForge.
17
+
18
+ h4. RedCloth Links
19
+
20
+ "Instiki":http://www.instiki.org is the greatest Wiki ever! Uses RedCloth for its markup!
21
+
22
+ "Hobix":http://hobix.com is a lovely little blogging package which uses RedCloth for blog entries.
23
+
24
+ <div id="css-buttons">
25
+
26
+ * "(css-button w3c)%W3C% xhtml 1.0(Valid XHTML 1.0!)":http://validator.w3.org/check?uri=referer
27
+ * "(css-button w3c w3c2)%W3C% valid css(Valid CSS!)":http://jigsaw.w3.org/css-validator/check/referer
28
+
29
+ </div>
30
+
31
+ </div>
32
+
33
+ RedCloth is a module for using Textile in Ruby. Textile is a text format. A very simple text format. Another stab at making readable text that can be converted to HTML.
34
+
35
+ h2. What is Textile?
36
+
37
+ Textile is a simple markup language.
38
+
39
+ table{width:400px}.
40
+ |_. textile|_. to|_. html|
41
+ | <notextile>_a phrase_</notextile> |->|_a phrase_|
42
+ | <notextile>*a phrase*</notextile> |->|*a phrase*|
43
+ | <notextile>_*a phrase*_</notextile> |->|_*a phrase*_|
44
+ | <notextile>"Google":http://google.com</notextile> |->|"Google":http://google.com|
45
+
46
+ No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you're writing and beautiful text for your readers. And if you need to break out into HTML, Textile will allow you to do so.
47
+
48
+ Textile also handles some subtleties of formatting which will enhance your document's readability:
49
+
50
+ * Single- and double-quotes around words or phrases are converted to curly quotations, much easier on
51
+ the eye. "Observe!"
52
+
53
+ * Double hyphens are replaced with an em-dash. Observe -- very nice!
54
+
55
+ * Single hyphens are replaced with en-dashes. Observe - so cute!
56
+
57
+ * Triplets of periods become an ellipsis. Observe...
58
+
59
+ * The letter 'x' becomes a dimension sign when used alone. Observe: 2 x 2.
60
+
61
+ * Conversion of <notextile>(TM)</notextile> to (TM), <notextile>(R)</notextile> to (R), <notextile>(C)</notextile> to (C).
62
+
63
+ For more on Textile's language, hop over to "A Textile Reference":http://hobix.com/textile/.
64
+
65
+ h2. Using RedCloth
66
+
67
+ The RedCloth class is an extension of Ruby's String class. Use it like you would a String:
68
+
69
+ <pre>
70
+ >> r = RedCloth.new "*strong text* and _emphasized text_"
71
+ => "*strong text* and _emphasized text_"
72
+ >> r.gsub!( 'text', 'words' )
73
+ => "*strong words* and _emphasized words_"
74
+ </pre>
75
+
76
+ To generate HTML from your RedCloth object, use the @RedCloth#to_html@ method:
77
+
78
+ <pre>
79
+ >> r.to_html
80
+ => "<p><strong>strong words</strong> and <em>emphasized words</em></p>"
81
+ </pre>
82
+
83
+
84
+ h2. Installing RedCloth
85
+
86
+ To install RedCloth via RubyGems:
87
+
88
+ <pre>
89
+ gem install RedCloth
90
+ </pre>
91
+
92
+ Or "download RedCloth":http://rubyforge.org/frs/download.php/2896/RedCloth-3.0.3.tar.gz and simply run the install.rb like so:
93
+
94
+ <pre>
95
+ ruby install.rb config
96
+ ruby install.rb setup
97
+ sudo ruby install.rb install
98
+ </pre>
99
+
100
+
101
+ h2. Acknowledgements
102
+
103
+ Textile is (c) 2003 Dean Allen. All rights reserved. You can read more "here":http://www.textism.com/tools/textile/.
104
+
105
+ RedCloth is also based on PyTextile, which is: Copyright (c) 2003, "Mark Pilgrim":http://diveintomark.org/. All rights reserved. You can read more about PyTextile "here":http://dealmeida.net/projects/textile.
106
+
@@ -0,0 +1,216 @@
1
+ ---
2
+ - A Textile Reference:
3
+ - Textile is a simple text markup. Simple symbols mark words' emphasis. Blocks of text
4
+ can be easily tagged as headers, quotes, or lists. A Textile document can then be
5
+ converted to HTML(Hypertext Markup Language) for viewing on the web.
6
+ - You can try Textile out on the "Textile home page":http://www.textism.com/tools/textile/.
7
+ Textile is also available as "RedCloth":http://whytheluckystiff.net/ruby/redcloth/ for
8
+ Ruby or "PyTextile":http://dealmeida.net/projects/textile for Python.
9
+ - Also refer to the "*Quick Reference*":javascript:quickRedReference(); for this guide.
10
+ - h4. Reading the Examples
11
+ - In each section below, examples are provided to clearly illustrate. In each example,
12
+ the Textile example is followed by the raw HTML it is translated into, followed by how
13
+ the HTML appears in the browser.
14
+ -
15
+ - Textile example
16
+ - Converted to HTML
17
+ - Browser-view
18
+ - Writing in Textile:
19
+ - Textile looks for paragraphs in your text. Paragraphs are separated by one blank line.
20
+ Every paragraph is translated as an HTML paragraph.
21
+ - !!example "A single paragraph.\n\nFollowed by another."
22
+ - h4. Using HTML in Textile
23
+ - You can certainly use HTML tags inside your Textile documents. HTML will only be escaped
24
+ if it's found in a @pre@ or @code@ block.
25
+ - !!example "I am <b>very</b> serious.\n\n<pre>\n I am <b>very</b> serious.\n</pre>"
26
+ - h4. Line Breaks
27
+ - Line breaks are ignored.
28
+ - !!example "I spoke.\nAnd none replied."
29
+ - Line breaks can be converted to HTML breaks by setting @hard_breaks@.
30
+ - h4. Entities
31
+ - Single- and double-quotes around words or phrases are converted to curly quotations, much easier on the eye.
32
+ - !!example '"Observe!"'
33
+ - Double hyphens are replaced with an em-dash.
34
+ - !!example Observe -- very nice!
35
+ - Single hyphens are replaced with en-dashes.
36
+ - !!example Observe - tiny and brief.
37
+ - Triplets of periods become an ellipsis.
38
+ - !!example Observe...
39
+ - The letter 'x' becomes a dimension sign when used alone.
40
+ - !!example 'Observe: 2 x 2.'
41
+ - Conversion of trademark and copyright symbols.
42
+ - !!example 'one(TM), two(R), three(C).'
43
+ - Quick Block Modifiers:
44
+ - Blocks of text default to being treated as paragraphs. But modifers can be affixed
45
+ to the beginning of a block to change its treatment.
46
+ - h4. Headers
47
+ - To make an entire paragraph into a Header, place "h<em>n</em>." at
48
+ its beginning, where _n_ is a number from 1-6.
49
+ - !!example h1. Header 1
50
+ - !!example h2. Header 2
51
+ - !!example h3. Header 3
52
+ - h4. Block Quotes
53
+ - To make an entire paragraph into a block quotation, place
54
+ "bq." before it.
55
+ - !!example "An old text\n\nbq. A block quotation.\n\nAny old text"
56
+ - h4. Footnotes
57
+ - Numeric references within text to footnotes appear between square brackets.
58
+ - !!example This is covered elsewhere[1].
59
+ - To create the footnote that corresponds to its reference within the text, begin a new paragraph with fn and the
60
+ footnote's number, followed by a dot and a space.
61
+ - !!example fn1. Down here, in fact.
62
+ - Quick Phrase Modifiers:
63
+ - h4. Structural Emphasis
64
+ - Emphasis to text is added by surrounding a phrase with underscores. In HTML, this often
65
+ appears as <em>italics</em>.
66
+ - !!example I _believe_ every word.
67
+ - Strength can be give to text by surrounding with asterisks. In HTML, this strength appears
68
+ as <strong>bold</strong>.
69
+ - !!example And then? She *fell*!
70
+ - Both italics and bold can be forced by doubling the underscores or asterisks.
71
+ - !!example "I __know__.\nI **really** __know__."
72
+ - Use double question marks to indicate _citation_. The title of a book, for instance.
73
+ - !!example "??Cat's Cradle?? by Vonnegut"
74
+ - Code phrases can be surrounded by at-symbols.
75
+ - !!example "Convert with @r.to_html@"
76
+ - To indicate a passage which has been deleted, surround the passage with hypens.
77
+ - !!example "I'm -sure- not sure."
78
+ - Pluses around a passage indicate its insertion.
79
+ - !!example "You are a +pleasant+ child."
80
+ - To superscript a phrase, surround with carets.
81
+ - !!example "a^2^ + b^2^ = c^2^"
82
+ - To subscript, surround with tildes.
83
+ - !!example "log~2~x"
84
+ - h4. HTML-Specific
85
+ - Lastly, if you find yourself needing to customize the style of a passage, use percent symbols
86
+ to translate the passage as an HTML span.
87
+ - !!example I'm %unaware% of most soft drinks.
88
+ - This way, you can apply style settings, as described in the next section to arbitrary phrases.
89
+ - !!example "I'm %{color:red}unaware%\nof most soft drinks."
90
+ - Attributes:
91
+ - Tailoring Textile to suit your needs is quite easy. Attributes allow you to provide CSS(Cascading
92
+ Style Sheets) information about any phrase.
93
+ - h4. Block Attributes
94
+ - A block can be tagged with a CSS class by circling the class in parentheses and
95
+ placing it just before the period which marks the block.
96
+ - !!example p(example1). An example
97
+ - An element ID can be given by prefixing the ID with a pound symbol and using it in place of
98
+ the class.
99
+ - !!example p(#big-red). Red here
100
+ - Class and ID can be combined by placing the class first.
101
+ - !!example p(example1#big-red2). Red here
102
+ - Style settings can be provided directly by surrounding them in curly braces.
103
+ - !!example p{color:blue;margin:30px}. Spacey blue
104
+ - Language designations can be given between angel brackets.
105
+ - !!example p[fr]. rouge
106
+ - h4. Phrase Attributes
107
+ - All block attributes can be applied to phrases as well by placing them just inside the
108
+ opening modifier.
109
+ - !!example "I seriously *{color:red}blushed*\nwhen I _(big)sprouted_ that\ncorn stalk from my\n%[es]cabeza%."
110
+ - h4. Block Alignments
111
+ - Text inside blocks can be aligned in four basic ways.
112
+ - !!example p<. align left
113
+ - !!example p>. align right
114
+ - !!example p=. centered
115
+ - !!example p<>. justified
116
+ - Indentation can also be specified by provide a single left paren for every 1em to the left. A single right
117
+ paren for every 1em to the right.
118
+ - !!example p(. left ident 1em
119
+ - !!example p((. left ident 2em
120
+ - !!example p))). right ident 3em
121
+ - h4. Combining Alignments
122
+ - Identation may be coupled with alignment.
123
+ - !!example "h2()>. Bingo."
124
+ - And, furthermore, coupled with language settings and CSS styles.
125
+ - !!example "h3()>[no]{color:red}. Bingo"
126
+ - h4. HTML in Textile
127
+ - Textile is designed for quickening the simple markups. For more complex formatting, you are encouraged
128
+ to break out into HTML.
129
+ - For example, long code blocks belong between @pre@ and @code@ tags. Please also indent your code inside
130
+ the tags to be sure that all Textile processors out there will ignore the contents.
131
+ - !!example |
132
+ <pre>
133
+ <code>
134
+ a.gsub!( /</, '' )
135
+ </code>
136
+ </pre>
137
+ - You may also choose to surround sections with @div@ tags to separate your document into sections.
138
+ "Instiki":http://www.instiki.org/ uses this technique to float a sidebar to the right.
139
+ - !!example |
140
+ <div style="float:right;">
141
+
142
+ h3. Sidebar
143
+
144
+ "Hobix":http://hobix.com/
145
+ "Ruby":http://ruby-lang.org/
146
+
147
+ </div>
148
+
149
+ The main text of the
150
+ page goes here and will
151
+ stay to the left of the
152
+ sidebar.
153
+
154
+ - Lists:
155
+ - h4. Numeric Lists
156
+ - To make a numbered list, place each item in its own paragraph, preceded by "#".
157
+ - !!example "# A first item\n# A second item\n# A third"
158
+ - These lists may be nested by increasing the number of pound symbols preceding child entries.
159
+ - !!example "# Fuel could be:\n## Coal\n## Gasoline\n## Electricity\n# Humans need only:\n## Water\n## Protein"
160
+ - h4. Bulleted Lists
161
+ - Bulleted lists use an asterisk in place of the pound.
162
+ - !!example "* A first item\n* A second item\n* A third"
163
+ - These lists may be nested in like manner.
164
+ - !!example "* Fuel could be:\n** Coal\n** Gasoline\n** Electricity\n* Humans need only:\n** Water\n** Protein"
165
+ - External References:
166
+ - h4. Hypertext Links
167
+ - Basic links are comprised of a phrase which is linked to a URL(Universal Resource Locator). Place the
168
+ descriptive phrase in quotation marks. Follow it immediately by a colon and the URL.
169
+ - !!example I searched "Google":http://google.com.
170
+ - Notice, the link won't include any trailing punctuation.
171
+ - h4. Link Aliases
172
+ - If you are using the same link several times in your document, or you'd just like to be a tad more
173
+ organized, you can use a link alias. Place the URL anywhere in your document, beginning with its
174
+ alias in square brackets. Then, use the alias in place of the URL, using the link format above.
175
+ - !!example |
176
+ I am crazy about "Hobix":hobix
177
+ and "it's":hobix "all":hobix I ever
178
+ "link to":hobix!
179
+
180
+ [hobix]http://hobix.com
181
+ - h4. Embedded Images
182
+ - You can embed an image in your Textile document by surrounding its URL with exclamation marks.
183
+ - !!example "!http://hobix.com/sample.jpg!"
184
+ - URLs may be relative.
185
+ - A title for the image can also be provided in parens, just before the closing exclamation.
186
+ - !!example "!openwindow1.gif(Bunny.)!"
187
+ - The title also acts as *alt* text should the image not be found.
188
+ - Links can be attached to images with a colon.
189
+ - !!example "!openwindow1.gif!:http://hobix.com/"
190
+ - h4. Image Alignments
191
+ - Alignments can be applied as well to images.
192
+ - !!example "!>obake.gif!\n\nAnd others sat all round the small\nmachine and paid it to sing to them."
193
+ - h4. Acronyms
194
+ - Definitions for acronyms can be provided by following an acronym with its definition in parens.
195
+ - !!example We use CSS(Cascading Style Sheets).
196
+ - Tables:
197
+ - Simple tables can be built by separating fields with pipe characters
198
+ - !!example "| name | age | sex |\n| joan | 24 | f |\n| archie | 29 | m |\n| bella | 45 | f |"
199
+ - Specify header cells by marking them with an underscore and period.
200
+ - !!example "|_. name |_. age |_. sex |\n| joan | 24 | f |\n| archie | 29 | m |\n| bella | 45 | f |"
201
+ - h4. Cell Attributes
202
+ - The period used above marks the end of a cell's attributes. Other attributes can be applied as well.
203
+ - !!example "|_. attribute list |\n|<. align left |\n|>. align right|\n|=. center |\n|<>. justify |\n|^. valign top |\n|~. bottom |"
204
+ - You can also specify colspans with a backslash, followed by the cell width.
205
+ - !!example "|\\2. spans two cols |\n| col 1 | col 2 |"
206
+ - Rowspan is specified by a forward slash, followed by the row height.
207
+ - !!example "|/3. spans 3 rows | a |\n| b |\n| c |"
208
+ - All block attributes can be applied to table cells as well.
209
+ - !!example "|{background:#ddd}. Grey cell|"
210
+ - h4. Table and Row Attributes
211
+ - Table-wide attributes can be applied before the first row of the table. On its own line, followed by
212
+ a period.
213
+ - !!example "table{border:1px solid black}.\n|This|is|a|row|\n|This|is|a|row|"
214
+ - Attributes can be applied to a single row by supplying the attribute before the row starts, using a
215
+ @table@ modifier and following it by a period.
216
+ - !!example "|This|is|a|row|\n{background:#ddd}. |This|is|grey|row|"
@@ -0,0 +1,359 @@
1
+ $:.unshift '../lib'
2
+ require 'yaml'
3
+ require 'redcloth'
4
+
5
+ class String
6
+ #
7
+ # Flexible HTML escaping
8
+ #
9
+ def htmlesc!( mode )
10
+ gsub!( '&', '&amp;' )
11
+ gsub!( '"', '&quot;' ) if mode != :NoQuotes
12
+ gsub!( "'", '&#039;' ) if mode == :Quotes
13
+ gsub!('<', '&lt;')
14
+ gsub!('>', '&gt;')
15
+ end
16
+ end
17
+
18
+ def a_name( phrase )
19
+ phrase.downcase.
20
+ gsub( /\W+/, '-' )
21
+ end
22
+
23
+ file_name = ARGV.shift
24
+ case file_name
25
+ when 'README'
26
+ puts <<-HTML
27
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
28
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
29
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
30
+ <head>
31
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
32
+ <title>RedCloth [Textile Humane Web Text for Ruby]</title>
33
+ <style type="text/css">
34
+ BODY {
35
+ margin: 10px 60px 40px 60px;
36
+ font-family: georgia, serif;
37
+ font-size: 12pt;
38
+ }
39
+ TABLE {
40
+ padding: 15px;
41
+ width: 250px;
42
+ }
43
+ TH {
44
+ text-align: left;
45
+ }
46
+ TD {
47
+ border-top: solid 1px #eee;
48
+ }
49
+ H4 {
50
+ border: solid 1px #caa;
51
+ margin: 10px 15px 5px 10px;
52
+ padding: 5px;
53
+ color: white;
54
+ background-color: #333;
55
+ font-weight: bold;
56
+ font-size: 12pt;
57
+ }
58
+ P {
59
+ margin: 10px 15px 5px 15px;
60
+ }
61
+ P.example1 {
62
+ background-color: #FEE;
63
+ font-weight: bold;
64
+ font-size: 9pt;
65
+ padding: 5px;
66
+ }
67
+ P.example2 {
68
+ border: solid 1px #DDD;
69
+ background-color: #EEE;
70
+ font-size: 9pt;
71
+ padding: 5px;
72
+ }
73
+ .big {
74
+ font-size: 15pt;
75
+ }
76
+ #big-red {
77
+ font-size: 15pt;
78
+ color: red;
79
+ }
80
+ #big-red2 {
81
+ font-size: 15pt;
82
+ color: red;
83
+ }
84
+ #sidebar {
85
+ float: right;
86
+ font-family: verdana, arial, sans-serif;
87
+ font-size: 10pt;
88
+ border-left: solid 1px #999;
89
+ margin-left: 10px;
90
+ width: 200px;
91
+ }
92
+ /* VARIATION BUTTON STYLING (v2.0) - SIZABLE SIZE */
93
+ #css-buttons ul{list-style: none;margin: 0 0 10px 0;padding: 0;}
94
+ #css-buttons li{border: 1px solid #999; margin: 5px 0 0 20px; width:9.0em;}
95
+ head:first-child+body #css-buttons li{padding-right:2px;}
96
+ #css-buttons li a{color: #333; text-decoration: none;}
97
+
98
+ .css-button {
99
+ display:block;
100
+ font: 0.8em verdana, arial, sans-serif;
101
+ padding: 2px 0 2px 0px; border: 1px solid white;
102
+ text-decoration: none; width:100%;
103
+ background: #ddd;color: #333;
104
+ }
105
+
106
+ .css-button span {
107
+ font: bold 1.0em verdana, arial, sans-serif;
108
+ padding: 2px 3px 2px 3px; color: #fff;
109
+ }
110
+
111
+ /* BUTTON LOGO STYLING */
112
+ .rss span{background:#f60;}
113
+ .w3c span {background: #fff; color: #069; font: bold 1.1em helvetica, arial, Sans-Serif;}
114
+ .w3c2{background: #fc6;color: black !important;}
115
+ </style>
116
+ </head>
117
+ <body>
118
+ HTML
119
+ puts RedCloth.new( File.open( file_name ).read ).to_html
120
+ puts "</body>"
121
+ puts "</html>"
122
+ when 'QUICK-REFERENCE'
123
+ YAML::add_private_type( "example" ) do |type, val|
124
+ esc = val.dup
125
+ esc.htmlesc!( :NoQuotes )
126
+ [ :example, esc.gsub( /\n/, '<br />' ),
127
+ RedCloth.new( val ).to_html ]
128
+ end
129
+
130
+ content = YAML::load( File.open( 'REFERENCE' ) )
131
+
132
+ sections = content.collect { |c| c.keys.first }
133
+ sections.shift
134
+
135
+ puts <<-HTML
136
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
137
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
138
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
139
+ <head>
140
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
141
+ <title>Textile Quick Reference</title>
142
+ <style type="text/css">
143
+ BODY {
144
+ margin: 5px;
145
+ }
146
+ TABLE {
147
+ font-family: georgia, serif;
148
+ font-size: 10pt;
149
+ padding: 5px;
150
+ width: 200px;
151
+ }
152
+ TH {
153
+ padding-top: 10px;
154
+ }
155
+ TD {
156
+ border-top: solid 1px #eee;
157
+ }
158
+ H1 {
159
+ font-size: 18pt;
160
+ }
161
+ H4 {
162
+ color: #999;
163
+ background-color: #fee;
164
+ border: solid 1px #caa;
165
+ margin: 10px 15px 5px 10px;
166
+ padding: 5px;
167
+ }
168
+ P {
169
+ margin: 2px 5px 2px 5px;
170
+ }
171
+ TD.example1 PRE {
172
+ background-color: #FEE;
173
+ font-family: georgia, serif;
174
+ font-size: 8pt;
175
+ padding: 5px;
176
+ padding: 5px;
177
+ }
178
+ TD.example3 {
179
+ border: solid 1px #DDD;
180
+ background-color: #EEE;
181
+ font-size: 8pt;
182
+ padding: 5px;
183
+ }
184
+ .big {
185
+ font-size: 12pt;
186
+ }
187
+ #big-red {
188
+ font-size: 12pt;
189
+ color: red;
190
+ }
191
+ #big-red2 {
192
+ font-size: 15pt;
193
+ color: red;
194
+ }
195
+ </style>
196
+ </head>
197
+ <body>
198
+ <table>
199
+ <tr><th colspan='3'><h1>Textile Quick Reference</h1></th></tr>
200
+ <tr><th colspan='3'>Sections: #{ sections.collect { |s| "<a href='##{ a_name( s ) }'>#{ s.gsub( /\s/, '&nbsp;' ) }</a>" }.join( ' | ' ) }</th></tr>
201
+ HTML
202
+
203
+ ct = 0
204
+ content.each do |section|
205
+ section.each do |header, parags|
206
+ puts "<tr><th colspan='5'><a name='#{ a_name( header ) }'>#{ header }</a></th></tr>" if ct.nonzero?
207
+ parags.each do |p|
208
+ if p.is_a?( Array ) and p[0] == :example
209
+ puts "<tr><td class='example1'><pre>#{ p[1] }</pre></td><td>&rarr;</td>" +
210
+ "<td class='example2'>#{ p[2] }</td></tr>"
211
+ end
212
+ end
213
+ end
214
+ ct += 1
215
+ end
216
+ puts "</table>"
217
+ puts "</body>"
218
+ puts "</html>"
219
+
220
+ when 'REFERENCE'
221
+ YAML::add_private_type( "example" ) do |type, val|
222
+ esc = val.dup
223
+ esc.htmlesc!( :NoQuotes )
224
+ [ esc.gsub( /\n/, '<br />' ),
225
+ RedCloth.new( val ).to_html.
226
+ gsub( /;(\w)/, '; \1' ).
227
+ htmlesc!( :NoQuotes ).
228
+ gsub( /\n/, '<br />' ),
229
+ RedCloth.new( val ).to_html ]
230
+ end
231
+
232
+ content = YAML::load( File.open( file_name ) )
233
+
234
+ sections = content.collect { |c| c.keys.first }
235
+ sections.shift
236
+
237
+ puts <<-HTML
238
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
239
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
240
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
241
+ <head>
242
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
243
+ <title>Textile Reference</title>
244
+ <style type="text/css">
245
+ BODY {
246
+ margin: 10px 30px;
247
+ }
248
+ TABLE {
249
+ font-family: georgia, serif;
250
+ font-size: 11pt;
251
+ padding: 15px;
252
+ }
253
+ TH {
254
+ border-bottom: solid 1px black;
255
+ font-size: 24pt;
256
+ font-weight: bold;
257
+ padding-top: 30px;
258
+ }
259
+ H1 {
260
+ font-size: 42pt;
261
+ }
262
+ H4 {
263
+ color: #666;
264
+ background-color: #fee;
265
+ border: solid 1px #caa;
266
+ margin: 10px 0px 5px 0px;
267
+ padding: 5px;
268
+ }
269
+ P {
270
+ margin: 10px 15px 5px 15px;
271
+ }
272
+ TD.sections {
273
+ background: black;
274
+ color: white;
275
+ font-family: georgia, serif;
276
+ font-weight: bold;
277
+ font-size: 9pt;
278
+ padding: 5px;
279
+ }
280
+ TD.sections A { color: #CCEEFF; }
281
+ TD.sections A:link { color: #CCEEFF; }
282
+ TD.sections A:visited { color: #CCEEFF; }
283
+ TD.sections A:active { color: #EEEEEE; }
284
+ TD.sections A:hover { color: #EEEEEE; }
285
+
286
+ TD.example1 PRE {
287
+ background-color: #B30;
288
+ color: white;
289
+ font-family: georgia, serif;
290
+ font-weight: bold;
291
+ font-size: 9pt;
292
+ padding: 5px;
293
+ }
294
+ TD.example2 P {
295
+ border: solid 1px #DDD;
296
+ background-color: #EEE;
297
+ font-family: georgia, serif;
298
+ font-size: 9pt;
299
+ padding: 5px;
300
+ }
301
+ TD.example3 {
302
+ border: solid 1px #EED;
303
+ background-color: #FFE;
304
+ padding: 5px;
305
+ }
306
+ .big {
307
+ font-size: 15pt;
308
+ }
309
+ #big-red {
310
+ font-size: 15pt;
311
+ color: red
312
+ }
313
+ </style>
314
+ <script type="text/javascript">
315
+ function quickRedReference() {
316
+ window.open(
317
+ "quick.html",
318
+ "redRef",
319
+ "height=600,width=550,channelmode=0,dependent=0," +
320
+ "directories=0,fullscreen=0,location=0,menubar=0," +
321
+ "resizable=0,scrollbars=1,status=1,toolbar=0"
322
+ );
323
+ }
324
+ </script>
325
+ </head>
326
+ <body>
327
+ <table>
328
+ HTML
329
+
330
+ ct = 0
331
+ content.each do |section|
332
+ section.each do |header, parags|
333
+ if ct.zero?
334
+ puts "<tr><th colspan='3'><h1>#{ header }</h1></th></tr>"
335
+ puts "<tr><td class='sections' colspan='3'>Sections: #{ sections.collect { |s| "<a href='##{ a_name( s ) }'>#{ s.gsub( /\s/, '&nbsp;' ) }</a>" }.join( ' | ' ) }</td></tr>"
336
+ else
337
+ puts "<tr><th colspan='3'><a name='#{ a_name( header ) }'><small>#{ ct }.</small></a><br />#{ header }</th></tr>"
338
+ end
339
+ parags.each do |p|
340
+ if p.is_a? Array
341
+ puts "<tr><td class='example1' valign='top'><pre>#{ p[0] }</pre></td><td>&rarr;</td>" +
342
+ "<td class='example2'><p>#{ p[1] }</p></td></tr><tr><td colspan='2'></td>" +
343
+ "<td class='example3'>#{ p[2] }</td></tr>"
344
+ else
345
+ puts "<tr><td class='explain' colspan='3'>"
346
+ puts RedCloth.new( p ).to_html
347
+ puts "</td></tr>"
348
+ end
349
+ end
350
+ unless ct.zero?
351
+ puts "<tr><td colspan='5' style='border-bottom: solid 1px #eee;'></td></tr>"
352
+ end
353
+ end
354
+ ct += 1
355
+ end
356
+ puts "</table>"
357
+ puts "</body>"
358
+ puts "</html>"
359
+ end