glyph 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,10 @@
1
1
  <p>Glyph was designed and developed by <a href="http://www.h3rald.com">Fabio Cevasco</a> (h3rald).</p>
2
- <p>Special thanks to the following individuals who contributed to Glyph by reporting and fixing issues and/or proposing and implementing new features:</p>
2
+ <p>Special thanks to the following individuals who contributed to Glyph by reporting and fixing issues, proposing and implementing new features or provided Glyph-related resources and plugins:</p>
3
3
  <ul>
4
4
  <li><a href="http://www.jabbslad.com">Jamie Atkinson</a> (Jabbslad)</li>
5
5
  <li><a href="http://koraktor.github.com">Sebastian Staudt</a> (koraktor)</li>
6
6
  <li><a href="http://balcone.eveel.ru">Dmitry A. Ustalov</a> (eveel)</li>
7
7
  <li><a href="http://www.stuartellis.eu">Stuart Ellis</a> (stuartellis)</li>
8
+ <li>Eric Givens (darthzippy)</li>
8
9
  </ul>
9
10
 
@@ -4,9 +4,42 @@
4
4
 
5
5
 
6
6
  <div class="section">
7
- <h2 id="h_1">v0.4.1 &ndash; September 25th 2010</h2>
7
+ <h2 id="h_1">v0.4.2 &ndash; October 22th 2010</h2>
8
8
  <div class="section">
9
- <h3 id="h_2">5 Bugs Fixed</h3>
9
+ <h3 id="h_2">3 Features Implemented</h3>
10
+ <table><tr><th>ID</th>
11
+ <th>Description</th></tr>
12
+
13
+
14
+ <tr><td><a href="http://github.com/h3rald/glyph/issues/closed#issue/172">#172</a></td>
15
+ <td><p>A new output? macro macro can be used to test whether Glyph is compiling to a particular output format.</p></td></tr>
16
+
17
+ <tr><td><a href="http://github.com/h3rald/glyph/issues/closed#issue/175">#175</a></td>
18
+ <td><p>The conditional macro now support a third parameter (else branch).</p></td></tr>
19
+
20
+ <tr><td><a href="http://github.com/h3rald/glyph/issues/closed#issue/176">#176</a></td>
21
+ <td><p>A bunch of new aliases and shortcuts are available for the section macro.</p></td></tr></table>
22
+
23
+ </div>
24
+
25
+
26
+ <div class="section">
27
+ <h3 id="h_3">1 Bug Fixed</h3>
28
+ <table><tr><th>ID</th>
29
+ <th>Description</th></tr>
30
+
31
+
32
+ <tr><td><a href="http://github.com/h3rald/glyph/issues/closed#issue/178">#178</a></td>
33
+ <td><p>No error is raised anymore if less than the required parameters/attributes are supplied to a rewritten macro.</p></td></tr></table>
34
+
35
+ </div>
36
+
37
+ </div>
38
+
39
+ <div class="section">
40
+ <h2 id="h_4">v0.4.1 &ndash; September 23th 2010</h2>
41
+ <div class="section">
42
+ <h3 id="h_5">5 Bugs Fixed</h3>
10
43
  <table><tr><th>ID</th>
11
44
  <th>Description</th></tr>
12
45
 
@@ -31,9 +64,9 @@
31
64
  </div>
32
65
 
33
66
  <div class="section">
34
- <h2 id="h_3">v0.4.0 &ndash; September 3th 2010</h2>
67
+ <h2 id="h_6">v0.4.0 &ndash; September 3th 2010</h2>
35
68
  <div class="section">
36
- <h3 id="h_4">13 Features Implemented</h3>
69
+ <h3 id="h_7">13 Features Implemented</h3>
37
70
  <table><tr><th>ID</th>
38
71
  <th>Description</th></tr>
39
72
 
@@ -81,7 +114,7 @@
81
114
 
82
115
 
83
116
  <div class="section">
84
- <h3 id="h_5">7 Bugs Fixed</h3>
117
+ <h3 id="h_8">7 Bugs Fixed</h3>
85
118
  <table><tr><th>ID</th>
86
119
  <th>Description</th></tr>
87
120
 
@@ -112,9 +145,9 @@
112
145
  </div>
113
146
 
114
147
  <div class="section">
115
- <h2 id="h_6">v0.3.0 &ndash; June 13th 2010</h2>
148
+ <h2 id="h_9">v0.3.0 &ndash; June 13th 2010</h2>
116
149
  <div class="section">
117
- <h3 id="h_7">13 Features Implemented</h3>
150
+ <h3 id="h_10">13 Features Implemented</h3>
118
151
  <table><tr><th>ID</th>
119
152
  <th>Description</th></tr>
120
153
 
@@ -162,7 +195,7 @@
162
195
 
163
196
 
164
197
  <div class="section">
165
- <h3 id="h_8">3 Bugs Fixed</h3>
198
+ <h3 id="h_11">3 Bugs Fixed</h3>
166
199
  <table><tr><th>ID</th>
167
200
  <th>Description</th></tr>
168
201
 
@@ -181,9 +214,9 @@
181
214
  </div>
182
215
 
183
216
  <div class="section">
184
- <h2 id="h_9">v0.2.0 &ndash; May 9th 2010</h2>
217
+ <h2 id="h_12">v0.2.0 &ndash; May 9th 2010</h2>
185
218
  <div class="section">
186
- <h3 id="h_10">11 Features Implemented</h3>
219
+ <h3 id="h_13">11 Features Implemented</h3>
187
220
  <table><tr><th>ID</th>
188
221
  <th>Description</th></tr>
189
222
 
@@ -225,7 +258,7 @@
225
258
 
226
259
 
227
260
  <div class="section">
228
- <h3 id="h_11">8 Bugs Fixed</h3>
261
+ <h3 id="h_14">8 Bugs Fixed</h3>
229
262
  <table><tr><th>ID</th>
230
263
  <th>Description</th></tr>
231
264
 
@@ -259,7 +292,7 @@
259
292
  </div>
260
293
 
261
294
  <div class="section">
262
- <h2 id="h_12">v0.1.0 &ndash; April 8th 2010</h2>
295
+ <h2 id="h_15">v0.1.0 &ndash; April 8th 2010</h2>
263
296
  Initial release.
264
297
 
265
298
  </div>
@@ -1,25 +1,16 @@
1
1
  <p>Copyright &copy; 2010 <strong>Fabio Cevasco</strong>, <a href="http://www.h3rald.com">http://www.h3rald.com</a></p>
2
-
3
- <div class="code">
4
- <pre>
5
- <code>
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ <p>Permission is hereby granted, free of charge, to any person obtaining a copy
7
3
  of this software and associated documentation files (the "Software"), to deal
8
4
  in the Software without restriction, including without limitation the rights
9
5
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
6
  copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7
+ furnished to do so, subject to the following conditions:</p>
8
+ <p>The above copyright notice and this permission notice shall be included in
9
+ all copies or substantial portions of the Software.</p>
10
+ <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
11
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
12
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
13
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
14
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
15
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.
23
- </code>
24
- </pre>
25
- </div>
16
+ THE SOFTWARE.</p>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -4,7 +4,7 @@
4
4
  :subtitle: Rapid Document Authoring Framework
5
5
  :author: Fabio Cevasco
6
6
  :draft: true
7
- :revision: v0.4.1
7
+ :revision: v0.4.2
8
8
  :filename: glyph
9
9
  :title: Glyph
10
10
  :styles: link
@@ -1,10 +1,11 @@
1
1
  txt[
2
2
  Glyph was designed and developed by =>[http://www.h3rald.com|Fabio Cevasco] (h3rald).
3
3
 
4
- Special thanks to the following individuals who contributed to Glyph by reporting and fixing issues and/or proposing and implementing new features:
4
+ Special thanks to the following individuals who contributed to Glyph by reporting and fixing issues, proposing and implementing new features or provided Glyph-related resources and plugins:
5
5
  * =>[http://www.jabbslad.com|Jamie Atkinson] (Jabbslad)
6
6
  * =>[http://koraktor.github.com|Sebastian Staudt] (koraktor)
7
7
  * =>[http://balcone.eveel.ru|Dmitry A. Ustalov] (eveel)
8
8
  * =>[http://www.stuartellis.eu|Stuart Ellis] (stuartellis)
9
+ * Eric Givens (darthzippy)
9
10
  ]
10
11
 
@@ -2,9 +2,11 @@
2
2
  macro :features do
3
3
  verb = (@name == :features) ? "Implemented" : "Fixed"
4
4
  total = @node.child_macros.length
5
+ name = @name.to_s.capitalize
6
+ name.chop! if total == 1
5
7
  interpret %{
6
8
  section[
7
- @title[#{total} #{@name.to_s.capitalize} #{verb}]
9
+ @title[#{total} #{name} #{verb}]
8
10
  table[
9
11
  tr[
10
12
  th[ID]
@@ -35,7 +37,17 @@ rw:[issue|
35
37
  %:[#>|"#{value} command"]
36
38
  %:[$>|"#{value} setting"]
37
39
  ]
38
- release[0.4.1|September 25th 2010|
40
+ release[0.4.2|October 22th 2010|
41
+ features[
42
+ issue[172|A new %>[output?] macro can be used to test whether Glyph is compiling to a particular output format.]
43
+ issue[175|The conditional macro now support a third parameter (else branch).]
44
+ issue[176|A bunch of new aliases and shortcuts are available for the section macro.]
45
+ ]
46
+ bugs[
47
+ issue[178|No error is raised anymore if less than the required parameters/attributes are supplied to a rewritten macro.]
48
+ ]
49
+ ]
50
+ release[0.4.1|September 23th 2010|
39
51
  bugs[
40
52
  issue[169|*.scss files are now supported by the %>[style].]
41
53
  issue[170|Improved default CodeRay stylesheet.]
@@ -1,16 +1,13 @@
1
1
  p[Copyright &copy; 2010 strong[Fabio Cevasco], =>[http://www.h3rald.com]]
2
- codeblock[
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ p[Permission is hereby granted, free of charge, to any person obtaining a copy
4
3
  of this software and associated documentation files (the "Software"), to deal
5
4
  in the Software without restriction, including without limitation the rights
6
5
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
6
  copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7
+ furnished to do so, subject to the following conditions:]
8
+ p[The above copyright notice and this permission notice shall be included in
9
+ all copies or substantial portions of the Software.]
10
+ p[THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
11
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
12
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
13
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@@ -141,6 +141,15 @@ Checks a string against a regular expression.
141
141
  @params[-p[0|The expression to negate]]
142
142
  ]
143
143
 
144
+ ref_macro[
145
+ @n[output?]
146
+ @desc[Evaluates to true if Glyph is generating output in the specified format(s).]
147
+ @example[=?[output?[web\|web5]\|This text is printed only when generating web or web5 output.]=]
148
+ @params[
149
+ -p[0, ...|a valid output target.]
150
+ ]
151
+ ]
152
+
144
153
  ref_macro[
145
154
  @n[or]
146
155
  @desc[Conditional @or@ operator, to be used with the %>[condition].]
@@ -1,3 +1,23 @@
1
+ rw:[filtered_section|
2
+ ref_macro[
3
+ @n[{{markup}}_section]
4
+ @desc[Creates a section (see %>[section]) whose content can be formatted with {{markup}} markup.]
5
+ @aliases[{{aliases}}]
6
+ @block_example[=
7
+ {{markup}}_section[
8
+ @title[Test Section]
9
+ @id[test]
10
+ Some *{{markup}}* text.
11
+ ]
12
+ =]
13
+ @params[-p[0|The text of the section]]
14
+ @attrs[
15
+ -a[title|The title of the section &[opt]]
16
+ -a[id|The ID of the section &[opt]]
17
+ -a[notoc|If not blank, the header will not appear in the Table of Contents. &[opt]]
18
+ ]
19
+ ]
20
+ ]
1
21
  ref_macro[
2
22
  @n[markdown]
3
23
  @desc[
@@ -10,6 +30,11 @@ Uses a Markdown converter (BlueCloth, RDiscount, Maruku or Kramdown) to transfor
10
30
  @params[-p[0|The Markdown text to filter.]]
11
31
  ]
12
32
 
33
+ filtered_section[
34
+ @markup[markdown]
35
+ @aliases[§md, md_section]
36
+ ]
37
+
13
38
  ref_macro[
14
39
  @n[textile]
15
40
  @desc[
@@ -22,9 +47,14 @@ Uses the RedCloth gem to transform the value into HTML or LaTeX, depending on th
22
47
  @params[-p[0|The Textile text to filter.]]
23
48
  ]
24
49
 
50
+ filtered_section[
51
+ @markup[textile]
52
+ @aliases[§txt, txt_section]
53
+ ]
54
+
25
55
  ref_macro[
26
56
  @n[highlight]
27
- @desc[Highlights a piece of source code (second parameter) according to the specified language (first parameter). fmi[code highligting|#source_code].]
57
+ @desc[Highlights a piece of source code according to the specified language. fmi[code highligting|#source_code].]
28
58
  @block_example[=
29
59
  highlight[ruby\|
30
60
  def hello
@@ -32,4 +62,8 @@ highlight[ruby\|
32
62
  end
33
63
  ]
34
64
  =]
65
+ @params[
66
+ -p[0|A programming language supported by the underlying highlighter.]
67
+ -p[1|The code to highlight.]
68
+ ]
35
69
  ]
@@ -64,7 +64,7 @@ Used to create a book. By default, it includes the following macros:
64
64
 
65
65
  ref_macro[
66
66
  @n[section]
67
- @desc[Creates a section (@<div>@ tag).]
67
+ @desc[Creates a section (@<div>@ or @<section>@ tag).]
68
68
  @aliases[%[=Glyph['system.structure'].values.flatten.uniq.map{\|a\| a.to_s }.push("section").sort.join(', ')=]]
69
69
  @block_example[=
70
70
  section[
@@ -12,18 +12,18 @@ Consider the following code:
12
12
  ]
13
13
  highlight[=html|
14
14
  ?[$[document.draft]\|
15
- This is a first draft of the Glyph Book]
16
- ?[not[$[document.draft]]\|
15
+ This is a first draft of the Glyph Book\|
17
16
  This is the official version of the Glyph Book]
18
17
  =]
19
18
  txt[
20
19
  In this case, if @document.draft@ is set to @true@, "This is a first draft of the Glyph Book" will be displayed; if not, "This is the official version of the Glyph Book" will be displayed instead.
21
20
 
22
- The %>[condition] takes two parameters:
23
- * the first one is the condition to evaluate
24
- * the second one is the text to include in the document only if the condition is satisfied.
21
+ The %>[condition] takes up to three parameters:
22
+ # the condition to evaluate
23
+ # the text to include in the document only if the condition is satisfied.
24
+ # _(Optional)_ the text to include in the document if the condition is _not_ satisfied.
25
25
 
26
- Note that _both_ parameters can contain macros, of course, so you can write things like:
26
+ Note that _all_ parameters can contain macros, of course, so you can write things like:
27
27
  ]
28
28
  highlight[=html|
29
29
  ?[and[
@@ -1,4 +1,7 @@
1
1
  txt[
2
2
  The @text@ folder of any Glyph folder contains all the text source files used to produce a document. Although there are no restrictions on the extension of the files in this folder, you may want to use @.glyph@, especially if =>[http://www.vim.org|Vim] is your favorite text editor.
3
+
3
4
  The reason is simple: a Glyph syntax file is =>[http://www.vim.org/scripts/script.php?script_id=3086|available on vim.org]. Although not essential, syntax highlighting does help when editing Glyph files.
5
+
6
+ If you use TextMate, you may want to check out Eric Givens' =>[http://github.com/darthzippy/glyph.tmbundle|Glyph TextMate Bundle].
4
7
  ]
@@ -1,5 +1,5 @@
1
1
  txt[
2
- There are _a lot_ of macros that can be used in the same way as @section@, one for each element commonly used in =>[http://en.wikipedia.org/wiki/Book_design|book design]. Each one of them is a simple wrapper for a @<div>@ tag with a @class@ attribute set to its name.
2
+ There are _a lot_ of macros that can be used in the same way as @section@, one for each element commonly used in =>[http://en.wikipedia.org/wiki/Book_design|book design].
3
3
 
4
4
  The following table lists the identifiers of all section-like macros, divided according to the part of the book they should be placed in:
5
5
  ]
@@ -24,5 +24,5 @@ The following table lists the identifiers of all section-like macros, divided ac
24
24
  p[strong[&Dagger;]: Any subsection of this section is not listed in the Table of Contents.]
25
25
 
26
26
  note[
27
- code[frontmatter], code[bodymatter] and code[backmatter] are also macro identifiers, but they are exposed as attributes for the %>[book] and the %>[article], so if you're using either of these two macros as your root macro for your document, there's no need to use them explicitly.
27
+ code[frontmatter], code[bodymatter] and code[backmatter] are also macro identifiers, but they are also exposed as attributes for the %>[book] and the %>[article], so if you're using either of these two macros as your root macro for your document, there's no need to use them explicitly.
28
28
  ]
@@ -1,5 +1,5 @@
1
1
 
2
- p[Glyph documents are normally organized as a hierarchical tree of nested chapters, appendixes, sections, etc. To define a section, use the %>[section], like so:]
2
+ p[Glyph documents are normally organized as a hierarchical tree of nested chapters, appendixes, sections, etc. To define a section, use the %>[section] (aliased by code[§]), like so:]
3
3
 
4
4
  highlight[=html|
5
5
  section[
@@ -30,3 +30,25 @@ Note an important difference from HTML: there is no need for an explicit level f
30
30
  txt[
31
31
  By default, in Glyph the first header level is _2_, so the two headers are rendered as @h2@ and @h3@, respectively (@--\[...\]@ macros are _comments_, therefore they are not included in the final output).
32
32
  ]
33
+ section[
34
+ @title[Markup-aware sections]
35
+ txt[Although Glyph can be used on its own to produce valid HTML or XML code, you may often want to use &[markups] to save some typing. Typically, you'll end up writing a lot of code like this:]
36
+
37
+ highlight[=html|
38
+ section[
39
+ @title[My Textile section]
40
+ textile[
41
+ Textile markup can be used _here_.
42
+ ]
43
+ ]
44
+ =]
45
+ txt[To save you even more typing, you can use the %>[textile_section] (aliased by @txt_section@ and @§txt@) and the %>[markdown_section] (aliased by @md_section@ and @§md@). By doing so, the previous code snippet can be written like this:]
46
+ highlight[=html|
47
+ §txt[
48
+ @title[My Textile section]
49
+ Textile markup can be used _here_.
50
+ ]
51
+ =]
52
+ tip[txt[On an Italian keyboard, you can type a @§@ character by pressing *SHIFT + &ugrave;*. Unfortunately, that's about the only useful thing an Italian keyboard does. If you use Vim, you can map it to some key sequence like @''s@, like this: @map! ''s <C-V>u00A7@.]]
53
+
54
+ ]
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{glyph}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Fabio Cevasco"]
12
- s.date = %q{2010-09-23}
12
+ s.date = %q{2010-10-22}
13
13
  s.default_executable = %q{glyph}
14
14
  s.description = %q{Glyph is a framework for structured document authoring.}
15
15
  s.email = %q{h3rald@h3rald.com}
@@ -220,32 +220,32 @@ Gem::Specification.new do |s|
220
220
  s.rubygems_version = %q{1.3.7}
221
221
  s.summary = %q{Glyph -- A Ruby-powered Document Authoring Framework}
222
222
  s.test_files = [
223
- "spec/macros/web5_spec.rb",
223
+ "spec/macros/core_spec.rb",
224
224
  "spec/macros/web_spec.rb",
225
- "spec/macros/macros_spec.rb",
226
- "spec/macros/textile_spec.rb",
225
+ "spec/macros/html5_spec.rb",
227
226
  "spec/macros/filters_spec.rb",
227
+ "spec/macros/web5_spec.rb",
228
+ "spec/macros/textile_spec.rb",
228
229
  "spec/macros/xml_spec.rb",
229
- "spec/macros/core_spec.rb",
230
- "spec/macros/html5_spec.rb",
231
- "spec/files/custom_command.rb",
232
- "spec/lib/parser_spec.rb",
233
- "spec/lib/macro_spec.rb",
234
- "spec/lib/config_spec.rb",
235
- "spec/lib/reporter_spec.rb",
230
+ "spec/macros/macros_spec.rb",
231
+ "spec/lib/interpreter_spec.rb",
236
232
  "spec/lib/analyzer_spec.rb",
233
+ "spec/lib/commands_spec.rb",
234
+ "spec/lib/node_spec.rb",
235
+ "spec/lib/bookmark_spec.rb",
236
+ "spec/lib/macro_spec.rb",
237
237
  "spec/lib/macro_validators_spec.rb",
238
- "spec/lib/interpreter_spec.rb",
238
+ "spec/lib/config_spec.rb",
239
239
  "spec/lib/glyph_spec.rb",
240
- "spec/lib/bookmark_spec.rb",
241
- "spec/lib/document_spec.rb",
240
+ "spec/lib/parser_spec.rb",
242
241
  "spec/lib/syntax_node_spec.rb",
243
- "spec/lib/node_spec.rb",
244
- "spec/lib/commands_spec.rb",
245
- "spec/spec_helper.rb",
242
+ "spec/lib/document_spec.rb",
243
+ "spec/lib/reporter_spec.rb",
246
244
  "spec/tasks/load_spec.rb",
245
+ "spec/tasks/generate_spec.rb",
247
246
  "spec/tasks/project_spec.rb",
248
- "spec/tasks/generate_spec.rb"
247
+ "spec/files/custom_command.rb",
248
+ "spec/spec_helper.rb"
249
249
  ]
250
250
 
251
251
  if s.respond_to? :specification_version then
@@ -212,11 +212,11 @@ module Glyph
212
212
  body = text.dup
213
213
  # Parameters
214
214
  body.gsub!(/\{\{(\d+)\}\}/) do
215
- raw_param($1.to_i).strip
215
+ raw_param($1.to_i).to_s.strip
216
216
  end
217
217
  # Attributes
218
218
  body.gsub!(/\{\{([^\[\]\|\\\s]+)\}\}/) do
219
- raw_attr($1.to_sym).strip
219
+ raw_attr($1.to_sym).to_s.strip
220
220
  end
221
221
  interpret body
222
222
  end
@@ -57,12 +57,13 @@ module Glyph
57
57
  # @option options [Boolean] :strip whether the value is stripped or not
58
58
  # @return [String, nil] the value of the attribute
59
59
  # @since 0.3.0
60
- def attribute(name, options={:strip => true})
60
+ def attribute(name, options={:strip => true, :null_if_blank => true})
61
61
  return @attributes[name.to_sym] if @attributes && @attributes[name.to_sym]
62
62
  return nil unless @node.attribute(name)
63
63
  @attributes = {} unless @attributes
64
64
  @attributes[name] = @node.attribute(name).evaluate(@node, :attrs => true).to_s
65
65
  @attributes[name].strip! if options[:strip]
66
+ @attributes[name] = nil if @attributes[name].blank? && options[:null_if_blank]
66
67
  @attributes[name]
67
68
  end
68
69
 
@@ -72,12 +73,13 @@ module Glyph
72
73
  # @option options [Boolean] :strip whether the value is stripped or not
73
74
  # @return [String, nil] the value of the parameter
74
75
  # @since 0.3.0
75
- def parameter(n, options={:strip => true})
76
+ def parameter(n, options={:strip => true, :null_if_blank => true})
76
77
  return @parameters[n] if @parameters && @parameters[n]
77
78
  return nil unless @node.parameter(n)
78
79
  @parameters = Array.new(@node.parameters.length) unless @parameters
79
80
  @parameters[n] = @node.parameter(n).evaluate(@node, :params => true).to_s
80
81
  @parameters[n].strip! if options[:strip]
82
+ @parameters[n] = nil if @parameters[n].blank? && options[:null_if_blank]
81
83
  @parameters[n]
82
84
  end
83
85
 
@@ -86,12 +88,13 @@ module Glyph
86
88
  # @option options [Boolean] :strip whether the value is stripped or not
87
89
  # @return [Hash] the macro attributes
88
90
  # @since 0.3.0
89
- def attributes(options={:strip => true})
91
+ def attributes(options={:strip => true, :null_if_blank => true})
90
92
  return @attributes if @attributes
91
93
  @attributes = {}
92
94
  @node.attributes.each do |value|
93
95
  @attributes[value[:name]] = value.evaluate(@node, :attrs => true)
94
96
  @attributes[value[:name]].strip! if options[:strip]
97
+ @attributes[value[:name]] = nil if @attributes[value[:name]].blank? && options[:null_if_blank]
95
98
  end
96
99
  @attributes
97
100
  end
@@ -101,12 +104,13 @@ module Glyph
101
104
  # @option options [Boolean] :strip whether the value is stripped or not
102
105
  # @return [Array] the macro parameters
103
106
  # @since 0.3.0
104
- def parameters(options={:strip => true})
107
+ def parameters(options={:strip => true, :null_if_blank => true})
105
108
  return @parameters if @parameters
106
109
  @parameters = []
107
110
  @node.parameters.each do |value|
108
111
  @parameters << value.evaluate(@node, :params => true)
109
112
  @parameters.last.strip! if options[:strip]
113
+ @parameters.last = nil if @parameters.last.blank? && options[:null_if_blank]
110
114
  end
111
115
  @parameters
112
116
  end
@@ -158,7 +158,8 @@ module Glyph
158
158
  list = ""
159
159
  added_headers ||= []
160
160
  n1.descend do |n2, level|
161
- if n2.is_a?(Glyph::MacroNode) && Glyph['system.structure.headers'].include?(n2[:name]) then
161
+ #if n2.is_a?(Glyph::MacroNode) && Glyph['system.structure.headers'].include?(n2[:name]) then
162
+ if n2.is_a?(Glyph::MacroNode) && n2[:name].in?(Glyph.titled_sections) then
162
163
  if Glyph.multiple_output_files? then
163
164
  # Only consider topics/booklets when building TOC for web/web5
164
165
  next if !n2.attribute(:src) && n2.child_macros.select{|child| child.attribute(:src)}.blank?
@@ -201,7 +202,8 @@ module Glyph
201
202
  level = 1
202
203
  @node.ascend do |n|
203
204
  break if n.respond_to?(:attribute) && n.attribute(:class) && n.attribute(:class).children.join.strip == "topic"
204
- if n.is_a?(Glyph::MacroNode) && Glyph["system.structure.headers"].include?(n[:name]) then
205
+ #if n.is_a?(Glyph::MacroNode) && Glyph["system.structure.headers"].include?(n[:name]) then
206
+ if n.is_a?(Glyph::MacroNode) && n[:name].in?(Glyph.titled_sections) then
205
207
  level+=1
206
208
  end
207
209
  end
@@ -121,10 +121,21 @@ module Glyph
121
121
  ALIASES[:by_alias][name.to_sym]
122
122
  end
123
123
 
124
+ # Returns the names of the macro aliases referencing the supplied definition
125
+ # @param [String, Symbol] name the macro name to check
124
126
  def macro_aliases_for(name)
125
127
  ALIASES[:by_def][name.to_sym]
126
128
  end
127
129
 
130
+ # Returns a list of macro names corresponding to sections
131
+ # that commonly have a title
132
+ def titled_sections
133
+ (Glyph['system.structure.frontmatter']+
134
+ Glyph['system.structure.bodymatter']+
135
+ Glyph['system.structure.backmatter']+
136
+ [:section]).uniq
137
+ end
138
+
128
139
  # Returns true if the macro names point to the same definition
129
140
  # @param [String, Symbol] ident1 the first macro to compare
130
141
  # @param [String, Symbol] ident2 the second macro to compare
@@ -131,9 +131,9 @@ end
131
131
 
132
132
  macro :condition do
133
133
  min_parameters 1
134
- max_parameters 2
134
+ max_parameters 3
135
135
  res = param(0)
136
- (res.blank? || res == "false") ? "" : param(1).to_s
136
+ (res.blank? || res == "false") ? param(2).to_s : param(1).to_s
137
137
  end
138
138
 
139
139
  macro :eq do
@@ -195,6 +195,10 @@ macro "rewrite:" do
195
195
  nil
196
196
  end
197
197
 
198
+ macro "output?" do
199
+ Glyph['document.output'].in? parameters
200
+ end
201
+
198
202
  macro_alias '--' => :comment
199
203
  macro_alias '&' => :snippet
200
204
  macro_alias '&:' => 'snippet:'
@@ -70,6 +70,28 @@ macro :markdown do
70
70
  end
71
71
  end
72
72
 
73
+ rewrite "textile_section",
74
+ %{section[
75
+ @src[{{src}}]
76
+ @id[{{id}}]
77
+ @notoc[{{notoc}}]
78
+ @title[{{title}}]
79
+ textile[
80
+ {{0}}
81
+ ]
82
+ ]}
83
+
84
+ rewrite "markdown_section",
85
+ %{section[
86
+ @src[{{src}}]
87
+ @id[{{id}}]
88
+ @notoc[{{notoc}}]
89
+ @title[{{title}}]
90
+ markdown[
91
+ {{0}}
92
+ ]
93
+ ]}
94
+
73
95
  macro :highlight do
74
96
  exact_parameters 2
75
97
  lang = param(0)
@@ -123,3 +145,7 @@ end
123
145
 
124
146
  macro_alias :md => :markdown
125
147
  macro_alias :txt => :textile
148
+ macro_alias :txt_section => :textile_section
149
+ macro_alias :md_section => :markdown_section
150
+ macro_alias "§txt" => :textile_section
151
+ macro_alias "§md" => :markdown_section
@@ -181,6 +181,7 @@ end
181
181
  (Glyph['system.structure.frontmatter'] + Glyph['system.structure.bodymatter'] + Glyph['system.structure.backmatter']).
182
182
  each {|s| macro_alias s => :section }
183
183
 
184
+ macro_alias "§" => :section
184
185
  macro_alias :frontcover => :section
185
186
  macro_alias :titlepage => :section
186
187
  macro_alias :halftitlepage => :section
@@ -130,6 +130,7 @@ end
130
130
  (Glyph['system.structure.frontmatter'] + Glyph['system.structure.bodymatter'] + Glyph['system.structure.backmatter']).
131
131
  each {|s| macro_alias s => :section }
132
132
 
133
+ macro_alias "§" => :section
133
134
  macro_alias :frontcover => :section
134
135
  macro_alias :titlepage => :section
135
136
  macro_alias :halftitlepage => :section
@@ -231,10 +231,11 @@ test_project - Outline
231
231
  reset_quiet
232
232
  create_project
233
233
  out = run_command(["stats", "-ms"])
234
- out.should match "-- Total Macro Definitions: 44"
234
+ total_macros = (Glyph::MACROS.keys - Glyph::ALIASES[:by_alias].keys).uniq.length
235
+ out.should match "-- Total Macro Definitions: #{total_macros}"
235
236
  out.should match "-- Unused Snippets: test"
236
237
  out = run_command(["stats"])
237
- out.should match "-- Total Macro Definitions: 44"
238
+ out.should match "-- Total Macro Definitions: #{total_macros}"
238
239
  out.should_not match "-- Unused Snippets: test"
239
240
  out.should match "-- Total Unreferenced Bookmarks: 3"
240
241
  out = run_command(["stats", "-lb", "--bookmark=md"])
@@ -176,6 +176,32 @@ describe Glyph::Macro do
176
176
  m.node.attribute(:b)[:value].should == nil
177
177
  end
178
178
 
179
+ it "should treat empty parameters/attributes as null" do
180
+ Glyph.macro :test_ap do
181
+ result = ""
182
+ if attr(:a) then
183
+ result << "(a)"
184
+ else
185
+ result << "(!a)"
186
+ end
187
+ if param(0) then
188
+ result << "(0)"
189
+ else
190
+ result << "(!0)"
191
+ end
192
+ if param(1) then
193
+ result << "(1)"
194
+ else
195
+ result << "(!1)"
196
+ end
197
+ result
198
+ end
199
+ output_for("test_ap[]").should == "(!a)(!0)(!1)"
200
+ output_for("test_ap[@a[]|]").should == "(!a)(!0)(!1)"
201
+ output_for("test_ap[@a[.]|]").should == "(a)(!0)(!1)"
202
+ output_for("test_ap[@a[.].|.]").should == "(a)(0)(1)"
203
+ end
204
+
179
205
  it "should expose a path method to determine its location" do
180
206
  tree = Glyph::Parser.new(%{
181
207
  test1[
@@ -74,6 +74,11 @@ describe "Macro:" do
74
74
  Glyph['test_config'].should == true
75
75
  end
76
76
 
77
+ it "condition (else)" do
78
+ output_for("?[true|OK|NOT OK]").should == "OK"
79
+ output_for("?[false|OK|NOT OK]").should == "NOT OK"
80
+ end
81
+
77
82
  it "comment" do
78
83
  output_for("--[config:[some_random_setting|test]]").should == ""
79
84
  Glyph[:some_random_setting].should == nil
@@ -182,6 +187,7 @@ Test -- Test Snippet
182
187
  define_em_macro
183
188
  interpret("rewrite:[rw_test|em[{{0}}\\.em[{{a}}]]]").process
184
189
  output_for("rw_test[test @a[em[A!]]]").should == "<em>test<em><em>A!</em></em></em>"
190
+ output_for("rw_test[]").should == "<em><em></em></em>"
185
191
  end
186
192
 
187
193
  it "rewrite should detect mutual definitions" do
@@ -191,4 +197,14 @@ Test -- Test Snippet
191
197
  end.should raise_error(Glyph::MacroError)
192
198
  end
193
199
 
200
+ it "output?" do
201
+ out = Glyph['document.output']
202
+ Glyph['document.output'] = "html"
203
+ output_for("?[output?[html|web]|YES!]").should == "YES!"
204
+ Glyph['document.output'] = "web"
205
+ output_for("?[output?[html|web]|YES!]").should == "YES!"
206
+ Glyph['document.output'] = "web5"
207
+ output_for("?[output?[html|web]|YES!|NO...]").should == "NO..."
208
+ end
209
+
194
210
  end
@@ -73,5 +73,11 @@ interpret text
73
73
  check.call 'coderay', cr_result if cr
74
74
  end
75
75
 
76
+ it "textile_section, markdown_section" do
77
+ output_for("§txt[*test*]").should == "<div class=\"section\">\n<p><strong>test</strong></p>\n\n</div>"
78
+ output_for("§md[*test*]").should == "<div class=\"section\">\n<p><em>test</em></p>\n\n</div>"
79
+ output_for("textile_section[@title[test]...]").should == "<div class=\"section\">\n<h2 id=\"h_1\">test</h2>\n<p>&#8230;</p>\n\n</div>"
80
+ end
81
+
76
82
 
77
83
  end
@@ -1,49 +1,38 @@
1
- .CodeRay {
2
- -webkit-border-radius: 5px;
3
- -moz-border-radius: 5px;
4
- border-radius: 5px;
5
- background-color: #222;
6
- font-family: 'Courier New', 'Terminal', monospace;
7
- color: #E6E0DB;
8
- padding: 20px;
9
- overflow: auto;
10
- font-size: 0.8em;
11
- margin: 20px 0 20px 0; }
12
- .CodeRay pre {
13
- line-height: 1.2em;
14
- margin: 0px;
15
- padding: 0px; }
16
- .CodeRay .no {
17
- font-weight: bold;
18
- color: #595959; }
19
- .CodeRay .an {
20
- color: #E7BE69; }
21
- .CodeRay .c {
22
- color: #BC9358;
23
- font-style: italic; }
24
- .CodeRay .ch {
25
- color: #509E4F; }
26
- .CodeRay .cl, .CodeRay .co {
27
- color: #FFF; }
28
- .CodeRay .fl {
29
- color: #A4C260; }
30
- .CodeRay .fu {
31
- color: #FFC56D; }
32
- .CodeRay .gv {
33
- color: #D0CFFE; }
34
- .CodeRay .i {
35
- color: #A4C260; }
36
- .CodeRay .iv {
37
- color: #D0CFFE; }
38
- .CodeRay .pp {
39
- color: #E7BE69; }
40
- .CodeRay .r {
41
- color: #CB7832; }
42
- .CodeRay .rx, .CodeRay .s {
43
- color: #A4C260; }
44
- .CodeRay .sy {
45
- color: #6C9CBD; }
46
- .CodeRay .ta {
47
- color: #E7BE69; }
48
- .CodeRay .pc {
49
- color: #6C9CBD; }
1
+ .CodeRay pre {
2
+ line-height: 1.2em;
3
+ margin: 0px;
4
+ color: #FFF; }
5
+ .CodeRay .no {
6
+ font-weight: bold;
7
+ color: #595959; }
8
+ .CodeRay .an {
9
+ color: #E7BE69; }
10
+ .CodeRay .c {
11
+ color: #BC9358;
12
+ font-style: italic; }
13
+ .CodeRay .ch {
14
+ color: #509E4F; }
15
+ .CodeRay .cl, .CodeRay .co {
16
+ color: #FFF; }
17
+ .CodeRay .fl {
18
+ color: #A4C260; }
19
+ .CodeRay .fu {
20
+ color: #FFC56D; }
21
+ .CodeRay .gv {
22
+ color: #D0CFFE; }
23
+ .CodeRay .i {
24
+ color: #A4C260; }
25
+ .CodeRay .iv {
26
+ color: #D0CFFE; }
27
+ .CodeRay .pp {
28
+ color: #E7BE69; }
29
+ .CodeRay .r {
30
+ color: #CB7832; }
31
+ .CodeRay .rx, .CodeRay .s {
32
+ color: #A4C260; }
33
+ .CodeRay .sy {
34
+ color: #6C9CBD; }
35
+ .CodeRay .ta {
36
+ color: #E7BE69; }
37
+ .CodeRay .pc {
38
+ color: #6C9CBD; }
@@ -1,10 +1,10 @@
1
1
  @import "definitions.scss";
2
2
  .CodeRay {
3
- @include codeblock;
4
3
  pre {
5
4
  line-height: 1.2em;
6
5
  margin: 0px;
7
- padding: 0px; }
6
+ color: #FFF;
7
+ }
8
8
  .no {
9
9
  font-weight: bold;
10
10
  color: #595959;
@@ -1,6 +1,6 @@
1
1
  * {
2
- border: none;
3
2
  font-family: inherit;
3
+ border: none;
4
4
  font-size: 100%;
5
5
  font-style: inherit;
6
6
  margin: 0;
@@ -201,7 +201,7 @@ a {
201
201
  a:hover {
202
202
  color: #005b91; }
203
203
 
204
- pre > code {
204
+ .code > pre {
205
205
  -webkit-border-radius: 5px;
206
206
  -moz-border-radius: 5px;
207
207
  border-radius: 5px;
@@ -209,11 +209,10 @@ pre > code {
209
209
  font-family: 'Courier New', 'Terminal', monospace;
210
210
  color: #E6E0DB;
211
211
  padding: 20px;
212
- overflow: auto;
213
- font-size: 0.8em;
212
+ overflow: auto hidden;
214
213
  margin: 20px 0 20px 0; }
215
214
 
216
- code {
215
+ code, .CodeRay {
217
216
  font-size: 0.8em; }
218
217
 
219
218
  span.line-numbers {
@@ -1,8 +1,8 @@
1
1
  @import "definitions.scss";
2
2
 
3
3
  * {
4
- border: none;
5
4
  font-family: inherit;
5
+ border: none;
6
6
  font-size: 100%;
7
7
  font-style: inherit;
8
8
  margin: 0;
@@ -207,11 +207,11 @@ a {
207
207
  &:hover {
208
208
  color: $link-hover-color; } }
209
209
 
210
- pre > code {
211
- @include codeblock; }
210
+ .code > pre {
211
+ @include codeblock; }
212
212
 
213
- code {
214
- font-size: 0.8em; }
213
+ code, .CodeRay {
214
+ font-size: 0.8em; }
215
215
 
216
216
  span.line-numbers {
217
217
  margin: 0;
@@ -14,7 +14,5 @@ $link-hover-color: #005B91;
14
14
  font-family: 'Courier New', 'Terminal', monospace;
15
15
  color: #E6E0DB;
16
16
  padding: 20px;
17
- overflow: auto;
18
- font-size: 0.8em;
19
- margin: 20px 0 20px 0;
20
- }
17
+ overflow: auto hidden;
18
+ margin: 20px 0 20px 0; }
@@ -1,3 +1,3 @@
1
- sass pagination.scss > pagination.css
2
- sass default.scss > default.css
3
- sass coderay.scss > coderay.css
1
+ sass pagination.scss pagination.css
2
+ sass default.scss default.css
3
+ sass coderay.scss coderay.css
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glyph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Fabio Cevasco
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-23 00:00:00 -06:00
18
+ date: 2010-10-22 00:00:00 +02:00
19
19
  default_executable: glyph
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -433,29 +433,29 @@ signing_key:
433
433
  specification_version: 3
434
434
  summary: Glyph -- A Ruby-powered Document Authoring Framework
435
435
  test_files:
436
- - spec/macros/web5_spec.rb
436
+ - spec/macros/core_spec.rb
437
437
  - spec/macros/web_spec.rb
438
- - spec/macros/macros_spec.rb
439
- - spec/macros/textile_spec.rb
438
+ - spec/macros/html5_spec.rb
440
439
  - spec/macros/filters_spec.rb
440
+ - spec/macros/web5_spec.rb
441
+ - spec/macros/textile_spec.rb
441
442
  - spec/macros/xml_spec.rb
442
- - spec/macros/core_spec.rb
443
- - spec/macros/html5_spec.rb
444
- - spec/files/custom_command.rb
445
- - spec/lib/parser_spec.rb
446
- - spec/lib/macro_spec.rb
447
- - spec/lib/config_spec.rb
448
- - spec/lib/reporter_spec.rb
443
+ - spec/macros/macros_spec.rb
444
+ - spec/lib/interpreter_spec.rb
449
445
  - spec/lib/analyzer_spec.rb
446
+ - spec/lib/commands_spec.rb
447
+ - spec/lib/node_spec.rb
448
+ - spec/lib/bookmark_spec.rb
449
+ - spec/lib/macro_spec.rb
450
450
  - spec/lib/macro_validators_spec.rb
451
- - spec/lib/interpreter_spec.rb
451
+ - spec/lib/config_spec.rb
452
452
  - spec/lib/glyph_spec.rb
453
- - spec/lib/bookmark_spec.rb
454
- - spec/lib/document_spec.rb
453
+ - spec/lib/parser_spec.rb
455
454
  - spec/lib/syntax_node_spec.rb
456
- - spec/lib/node_spec.rb
457
- - spec/lib/commands_spec.rb
458
- - spec/spec_helper.rb
455
+ - spec/lib/document_spec.rb
456
+ - spec/lib/reporter_spec.rb
459
457
  - spec/tasks/load_spec.rb
460
- - spec/tasks/project_spec.rb
461
458
  - spec/tasks/generate_spec.rb
459
+ - spec/tasks/project_spec.rb
460
+ - spec/files/custom_command.rb
461
+ - spec/spec_helper.rb