glyph 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/AUTHORS.textile +8 -0
  2. data/CHANGELOG.textile +260 -0
  3. data/LICENSE.textile +26 -0
  4. data/README.textile +49 -21
  5. data/Rakefile +17 -7
  6. data/VERSION +1 -1
  7. data/book/config.yml +11 -5
  8. data/book/document.glyph +24 -13
  9. data/book/lib/macros/reference.rb +41 -14
  10. data/book/output/html/glyph.html +2298 -687
  11. data/book/output/pdf/glyph.pdf +6218 -2698
  12. data/book/script/authors +1 -0
  13. data/book/script/changelog +1 -0
  14. data/book/script/compile.rb +8 -0
  15. data/book/script/license +1 -0
  16. data/book/script/prof +1 -0
  17. data/book/script/prof_results.htm +21079 -0
  18. data/book/script/readme +1 -0
  19. data/book/snippets.yml +3 -4
  20. data/book/text/acknowledgement.glyph +8 -0
  21. data/book/text/authoring.glyph +548 -0
  22. data/book/text/changelog.glyph +76 -0
  23. data/book/text/extending.glyph +224 -0
  24. data/book/text/{getting_started.textile → getting_started.glyph} +30 -24
  25. data/book/text/{introduction.textile → introduction.glyph} +22 -12
  26. data/book/text/license.glyph +21 -0
  27. data/book/text/{ref_commands.textile → ref_commands.glyph} +30 -8
  28. data/book/text/ref_config.glyph +108 -0
  29. data/book/text/ref_macros.glyph +378 -0
  30. data/book/text/troubleshooting.glyph +179 -0
  31. data/config.yml +16 -4
  32. data/glyph.gemspec +83 -22
  33. data/lib/glyph.rb +164 -31
  34. data/lib/glyph/commands.rb +98 -23
  35. data/lib/glyph/document.rb +13 -7
  36. data/lib/glyph/glyph_language.rb +9 -1
  37. data/lib/glyph/glyph_language.treetop +1 -1
  38. data/lib/glyph/interpreter.rb +19 -9
  39. data/lib/glyph/macro.rb +88 -11
  40. data/lib/glyph/macro_validators.rb +48 -0
  41. data/lib/glyph/node.rb +13 -1
  42. data/lib/glyph/system_extensions.rb +0 -28
  43. data/macros/common.rb +125 -31
  44. data/macros/filters.rb +19 -13
  45. data/macros/html/block.rb +119 -68
  46. data/macros/html/inline.rb +29 -3
  47. data/macros/html/structure.rb +40 -40
  48. data/spec/files/article.glyph +5 -0
  49. data/spec/lib/commands_spec.rb +98 -3
  50. data/spec/lib/document_spec.rb +15 -2
  51. data/spec/lib/glyph_spec.rb +39 -10
  52. data/spec/lib/interpreter_spec.rb +8 -2
  53. data/spec/lib/macro_spec.rb +54 -6
  54. data/spec/lib/macro_validators_spec.rb +33 -0
  55. data/spec/lib/node_spec.rb +11 -3
  56. data/spec/macros/filters_spec.rb +5 -5
  57. data/spec/macros/macros_spec.rb +185 -8
  58. data/spec/macros/textile_spec.rb +217 -0
  59. data/spec/spec_helper.rb +25 -15
  60. data/spec/tasks/generate_spec.rb +3 -3
  61. data/spec/tasks/load_spec.rb +11 -1
  62. data/spec/tasks/project_spec.rb +0 -3
  63. data/styles/coderay.css +121 -0
  64. data/styles/default.css +54 -20
  65. data/{book/styles/css3.css → styles/pagination.css} +35 -7
  66. data/styles/ultraviolet/active4d.css +114 -0
  67. data/styles/ultraviolet/all_hallows_eve.css +72 -0
  68. data/styles/ultraviolet/amy.css +147 -0
  69. data/styles/ultraviolet/blackboard.css +88 -0
  70. data/styles/ultraviolet/brilliance_black.css +605 -0
  71. data/styles/ultraviolet/brilliance_dull.css +599 -0
  72. data/styles/ultraviolet/cobalt.css +149 -0
  73. data/styles/ultraviolet/dawn.css +121 -0
  74. data/styles/ultraviolet/eiffel.css +121 -0
  75. data/styles/ultraviolet/espresso_libre.css +109 -0
  76. data/styles/ultraviolet/idle.css +62 -0
  77. data/styles/ultraviolet/iplastic.css +80 -0
  78. data/styles/ultraviolet/lazy.css +73 -0
  79. data/styles/ultraviolet/mac_classic.css +123 -0
  80. data/styles/ultraviolet/magicwb_amiga.css +104 -0
  81. data/styles/ultraviolet/pastels_on_dark.css +188 -0
  82. data/styles/ultraviolet/slush_poppies.css +85 -0
  83. data/styles/ultraviolet/spacecadet.css +51 -0
  84. data/styles/ultraviolet/sunburst.css +180 -0
  85. data/styles/ultraviolet/twilight.css +137 -0
  86. data/styles/ultraviolet/zenburnesque.css +91 -0
  87. data/tasks/generate.rake +45 -26
  88. data/tasks/load.rake +21 -18
  89. data/tasks/project.rake +3 -1
  90. metadata +210 -41
  91. data/book/styles/default.css +0 -190
  92. data/book/text/authoring.textile +0 -351
  93. data/book/text/extending.textile +0 -148
  94. data/book/text/ref_config.textile +0 -0
  95. data/book/text/ref_macros.textile +0 -256
  96. data/book/text/troubleshooting.textile +0 -118
  97. data/styles/css3.css +0 -220
@@ -0,0 +1,76 @@
1
+ %[=
2
+ macro :issue do
3
+ exact_parameters 2
4
+ ident, desc = @params
5
+ encode %{
6
+ tr[
7
+ td[\=>[http://github.com/h3rald/glyph/issues/closed#issue/#{ident}\|##{ident}]]
8
+ td[textile[#{desc}]]
9
+ ]
10
+ }
11
+ end
12
+
13
+ macro :features do
14
+ verb = (@name == :features) ? "Implemented" : "Fixed"
15
+ total = @node.children.length
16
+ encode %{
17
+ section[header[#{total} #{@name.to_s.capitalize} #{verb}]
18
+ table[
19
+ tr[
20
+ th[ID]
21
+ th[Description]
22
+ ]
23
+ #@value
24
+ ]
25
+ ]
26
+ }
27
+ end
28
+
29
+ macro :release do
30
+ exact_parameters 3
31
+ number, date, contents = @params
32
+ interpret %{
33
+ section[header[v#{number} – #{date}]
34
+ #{decode contents}
35
+ ]
36
+ }
37
+ end
38
+
39
+
40
+ macro_alias :bugs => :features
41
+
42
+ =]--[
43
+ ?[%[lite?]|*[=
44
+ %:[%>|"#@value macro"]
45
+ %:[#>|"#@value command"]
46
+ =]
47
+ ]
48
+ ]
49
+ release[0.2.0|May 9th 2010|
50
+ features[
51
+ issue[62|A new %>[highlight] is available to highlight source code (CodeRay or UltraViolet requireed).]
52
+ issue[76|It is now possible to use Glyph programmatically via the new @Glyph#filter@ and @Glyph#compile@ methods.]
53
+ issue[87|It is now possible to define snippets inside a Glyph source file using the %>[snippet:].]
54
+ issue[88|It is now possible to change configuration settings inside a Glyph source file using the %>[config:] (Jabbslad).]
55
+ issue[89|It is now possible to compile a single Glyph source file without creating a Glyph project.]
56
+ issue[92|6 new macros have been defined to allow conditional processing (\.%>[condition], %>[eq], %>[not], %>[and], %>[or], %>[match])]
57
+ issue[94|It is now possible to add _validators_ to macros, for example to check the number of parameters they take.]
58
+ issue[97|The #>[compile] command can now take an extra @--auto@ switch to trigger document auto-regeneration whenever a source file is changed (koraktor).]
59
+ issue[99|Added a @document.draft@ setting. If set to @true@, comments and TODOs are rendered in output files.]
60
+ issue[100|#[system_css]Glyph CSS files are no longer copied to new projects, but they can be referenced as if they were (see also =>[#css_not_copied|#93]).]
61
+ issue[108|It is now possible to define Glyph macros within Glyph source files using the %>[macro:].]
62
+ ]
63
+ bugs[
64
+ issue[86|Warning and error messages have been updated, and it is now possible to show additional debug information. Additionally, syntax errors are now handled before the document is processed.]
65
+ issue[93|#[css_not_copied]Default css files were not copied when creating a new project. The issue has been resolved by allowing the %>[style] to reference Glyph's system styles (see also =>[#system_css|#100]).]
66
+ issue[95|The #>[config] did not save data to YAML configuration files. This has been fixed ensuring that internal configuration overrides are not saved to the YAML file too.]
67
+ issue[98|Glyph is now fully compatible with Ruby 1.9.1 and JRuby 1.4.0.]
68
+ issue[101|Additional tests have been developed to improve Textile support. There should no longer be errors when using textile block elements inside Glyph macros.]
69
+ issue[103|Fixed a bug that caused test failures when deleting the test project directory.]
70
+ issue[104|Nested Glyph macros calling @Macro#interpret@ no longer ignore escape delimiters.]
71
+ issue[107|Added the possibility to encode (using the %>[encode]) and decode (using the %>[decode]) macros so that they can be interpreted later.]
72
+ ]
73
+ ]
74
+ release[0.1.0|April 8th 2010|
75
+ Initial release.
76
+ ]
@@ -0,0 +1,224 @@
1
+ Glyph was created wih extensibility in mind. You can freely extend &[glang] by creating or overriding macros, to do whatever you like. Macro definitions are written in pure Ruby code and placed in @.rb@ files within the @lib/macros/@ folder of your project.
2
+
3
+ tip[Alternatively, you can also define macros right in your document, using the %>[macro:].]
4
+
5
+ section[header[Anatomy of a Macro]
6
+
7
+ This is the source code of a fairly simple macro used to format a note :
8
+
9
+ <notextile>
10
+ highlight[=ruby|
11
+ macro :note do
12
+ %{<div class="#{@name}"><span class="note-title">#{@name.to_s.capitalize}</span>
13
+ #{@value}
14
+
15
+ </div>}
16
+ end=]
17
+ </notextile>
18
+
19
+ The @macro@ method takes a single @Symbol@ or @String@ parameter, corresponding to the name of the macro. In this case, the entire block (or _body_ of the macro) is a @String@ corresponding to what we want the macro to evaluate to: a @<div>@ tag containing a note.
20
+
21
+ The body of the macro is evaluated in the context of the =>[http://yardoc.org/docs/glyph/Glyph/Macro|@Glyph::Macro@] class, therefore its instance variables (like codeph[@name] or codeph[@value]) can be used directly.
22
+
23
+ box[Why using codeph[@name] instead of just "note"?|
24
+ For the @note@ macro, it absolutely makes no difference. However, by using codeph[@name] it is possible to re-use the same code for the @tip@, @important@ and @caution@ macros as well, which are in fact only aliases of the @note@ macro:
25
+
26
+ @macro_alias :important => :note@
27
+ @macro_alias :tip => :note@
28
+ @macro_alias :caution => :note@
29
+ ] --[End box]
30
+
31
+ The following table lists all the instance variables that can be used inside macros:
32
+
33
+ table[
34
+ tr[
35
+ th[Variable]
36
+ th[Description]
37
+ ]
38
+ tr[
39
+ td[codeph[@node]]
40
+ td[A =>[http://yardoc.org/docs/glyph/Node|@Node@] containing information about the macro, within the document syntax tree. Useful for accessing parent and child macros, and the current =>[http://yardoc.org/docs/glyph/Glyph/Document|@Document@]. Normally, macro nodes contain the following keys:
41
+ * @:name@, the name of the macro.
42
+ * @:value@, the value (i.e. the contents, within the delimiters) of the macro
43
+ * @:source@, a @String@ identifying the source of the macro (a file, a snippet, etc.)
44
+ * @:document@, the parsed document tree.
45
+
46
+ Note that the first three keys can also be accessed via instance variables.]
47
+ ]
48
+ tr[
49
+ td[codeph[@name]]
50
+ td[The name of the macro]
51
+ ]
52
+ tr[
53
+ td[codeph[@value]]
54
+ td[The full contents (including parameters and nested macros) inside the macro delimiters.]
55
+ ]
56
+ tr[
57
+ td[codeph[@source]]
58
+ td[A @String@ identifying the source of the macro (a file, a snippet, etc.) ]
59
+ ]
60
+ tr[
61
+ td[codeph[@params]]
62
+ td[The parameters passed to the macro. In other words, the value of the macro split by pipes (@\|@).]
63
+ ]
64
+ ] --[End Table]
65
+
66
+ ]
67
+
68
+ section[header[Bookmarks and Headers]
69
+
70
+ The =>[http://yardoc.org/docs/glyph/Glyph/Macro|@Glyph::Macro@] class also includes a few methods to check and store bookmarks and headers. Consider for example the following source code for the %>[anchor]:
71
+
72
+ <notextile>
73
+ highlight[=ruby|
74
+ macro :anchor do
75
+ ident, title = @params
76
+ macro_error "Bookmark '#{ident}' already exists" if bookmark? ident
77
+ bookmark :id => ident, :title => title
78
+ %{<a id="#{ident}">#{title}</a>}
79
+ end
80
+ =]
81
+ </notextile>
82
+
83
+ The @bookmark?@ method can be used to check the existance of a particular ID within the whole document, while the @bookmark@ method is used to store bookmark IDs and titles. In a similar way, you can use @header?@ and @header@ methods to check the existance of headers within the documents or store new ones.
84
+
85
+ ]
86
+
87
+ section[header[Using Placeholders]
88
+
89
+ Sometimes you may need to access some data that will not be available until the entire document has been fully parsed and analyzed. For example, in order to be able to validate internal links, it is necessary to know in advance if the bookmark ID referenced in the link exists or not, either before (that's easy) or even _after_ the link.
90
+
91
+ Here's the source code of the %>[link]:
92
+
93
+ <notextile>
94
+ highlight[=ruby|
95
+ macro :link do
96
+ href, title = @params
97
+ if href.match /^#/ then
98
+ anc = href.gsub(/^#/, '').to_sym
99
+ bmk = bookmark? anc
100
+ if bmk then
101
+ title \|\|= bmk[:title]
102
+ else
103
+ plac = placeholder do \|document\|
104
+ macro_error "Bookmark '#{anc}' does not exist" unless document.bookmarks[anc]
105
+ document.bookmarks[anc][:title]
106
+ end
107
+ title \|\|= plac
108
+ end
109
+ end
110
+ title \|\|= href
111
+ %{<a href="#{href}">#{title}</a>}
112
+ end
113
+ =]
114
+ </notextile>
115
+
116
+ If there's already a bookmark stored in the current document, then it is possible to retrieve its title and use it as link text. Otherwise, it is necessary to wait until the entire document has been fully processed and then check if the bookmark exists. To do so, use the @placeholder@ method. When called, this method returns an unique placeholder, which is then substituted with the value of the block, right before the document is finalized.
117
+
118
+ Within the @placeholder@ block, the @document@ parameter is, by all means, the fully analyzed document.
119
+ ]
120
+
121
+ section[header[Using Validators]
122
+ If you need to make sure that a macro is used properly, consider using =>[http://yardoc.org/docs/glyph/Glyph/Macro/Validators|validators]. These methods can be used anywhere within the macro code to check whether certain conditions are met or not. Some default validators are provided to check the number of parameters of a macro, and they are actually used in some system macros.
123
+
124
+ If you want to create your own validators, you can call the generic @validate@ method which takes the message to display in case of error, a Hash of options and a block containing the validation to perform.
125
+
126
+ box[Validating macro placement|
127
+ You can, of course, create your own validators to check whether a macro is used within another. While this may seem a good idea to enforce constraints into the way documents are created, it has one major drawback: if you define a macro with such validation, you're effectively limiting its usage, so for example you won't be able to use within snippets or other custom macros.
128
+
129
+ Suppose, for example, that the %>[header] is only allowed within a @section@ macro. This means that, for example:
130
+ * the macro cannot be used within @chapter@ or @appendix@ macros.
131
+ * the macro cannot be used in snippets
132
+
133
+ Even if you consider all the possibilities within the scope of the default macros provided with Glyph, this would also make the @header@ macro unusable within custom macros.
134
+ ]
135
+
136
+ ]
137
+
138
+ section[header[Interpreting Glyph Code]
139
+
140
+ What if you need to evaluate some Glyph code _within_ a macro? Say for example you want to transform a parameter in a link, and you want to make sure that link gets validated exactly like the others, in this case, you can use the @interpret@ method, as follows:
141
+
142
+ <notextile>
143
+ highlight[=ruby|
144
+ macro :fmi do
145
+ topic, href = @params
146
+ link = placeholder do \|document\|
147
+ interpret "link[#{href}]"
148
+ end
149
+ %{<span class="fmi">for more information on #{topic}, see #{link}</span>}
150
+ end
151
+ =]
152
+ </notextile>
153
+
154
+ When the @interpret@ method is called, the following happens:
155
+ # A new Glyph document is created from the @String@ passed to the method.
156
+ # The bookmarks, headers and placeholders are passed from the main document to the new one. Because they are stored in arrays and hashes, they are passed by reference, so for example any new bookmark stored in the new document will also become available in the main document.
157
+ # Any macro included in the @String@ is evaluated, and the resulting text is returned by the method. Note that this new document does not get finalized: in other words, placeholders will be left as they are, and they'll eventually be replaced when _the main document_ is finalized.
158
+
159
+ section[header[Encoding and Decoding Glyph Code|encode_decode]
160
+ When you use the @interpret@ method, keep in mind that the code is interpreted _before_ the macro execution ends. This may not always be what you want: if you're nesting macros interpreting @section@ and @header@ macros,for example, your Table of Contents may get messed up, with child sections showing up before their parents.
161
+
162
+ To avoid this, you can use the @encode@ and @decode@ methods, as shown in the macros defined for Glyph's =>[http://github.com/h3rald/glyph/blob/master/book/text/changelog.glyph|Changelog]:
163
+
164
+ <notextile>
165
+ highlight[=ruby|
166
+ macro :issue do
167
+ exact_parameters 2
168
+ ident, desc = @params
169
+ encode %{
170
+ tr[
171
+ td[\=>[http://github.com/h3rald/glyph/issues/closed#issue/#{ident}\|##{ident}]]
172
+ td[textile[#{desc}]]
173
+ ]
174
+ }
175
+ end
176
+
177
+ macro :features do
178
+ verb = (@name == :features) ? "Implemented" : "Fixed"
179
+ total = @node.children.length
180
+ encode %{
181
+ section[header[#{total} #{@name.to_s.capitalize} #{verb}]
182
+ table[
183
+ tr[
184
+ th[ID]
185
+ th[Description]
186
+ ]
187
+ #@value
188
+ ]
189
+ ]
190
+ }
191
+ end
192
+
193
+ macro :release do
194
+ exact_parameters 3
195
+ number, date, contents = @params
196
+ interpret %{
197
+ section[header[v#{number} &ndash; #{date}]
198
+ #{decode contents}
199
+ ]
200
+ }
201
+ end
202
+ =]
203
+ </notextile>
204
+
205
+ In this case, @issue@ macros are nested within a @features@ macro, which in turn is nested within a @release@ macro. Note that none of these macros have any side effect: they are just used for text expansion. Because we're always going to nest these macros in this way, there's no to have each one interpret Glyph code: it will be the @release@ macro's job to do so. Instead, the @features@ and @issue@ macros just encode text which will then be decoded by the @release@ macro, before being interpreted.
206
+
207
+ When you _encode_ a macro, its delimiters (@\[@, @\]@, and @\|@) will be escaped (into ‡\.‡¤\.91\.¤‡\.‡, ‡\.‡¤\.93\.¤‡\.‡, and ‡\.‡¤\.124\.¤‡\.‡ respectively), and when you _decode_ it, they will be unescaped. In a nutshell, you may want to use the encode/decode mechanism when:
208
+ * When you're nesting macros interpreting Glyph code, without side effects.
209
+ * When all you want is to copy some Glyph code from child macros into their parents.
210
+
211
+ note[These methods are also wrapped in the %>[encode] and in the %>[decode].]
212
+ ]
213
+ ]
214
+
215
+ section[header[Further Reading]
216
+
217
+ For more examples on how to create more complex macros, have a look at the =>[http://github.com/h3rald/glyph/tree/master/macros/|source code] of the existing ones.
218
+
219
+ To gain a deeper understanding on how macros are executed, have a look at the following Glyph classes:
220
+ * =>[http://yardoc.org/docs/glyph/Glyph/Macro|@Glyph::Macro@]
221
+ * =>[http://yardoc.org/docs/glyph/Glyph/Interpreter|@Glyph::Interpreter@]
222
+ * =>[http://yardoc.org/docs/glyph/Glyph/Document|@Glyph::Document@]
223
+ * =>[http://yardoc.org/docs/glyph/Glyph/Node|@Node@]
224
+ ]
@@ -12,15 +12,15 @@ That's it. You just created a new Glyph project in the @test_document@ directory
12
12
 
13
13
  box[Glyph's dependencies|
14
14
  Glyph requires the following gems:
15
- - extlib
16
- - gli
17
- - treetop
18
- - rake
15
+ * extlib
16
+ * gli
17
+ * treetop
18
+ * rake
19
19
 
20
20
  Additionally, some Glyph macros may require additional gems, such as:
21
- - RedCloth (_textile_ macro)
22
- - Maruku _or_ Kramdown _or_ BlueCloth (_markdown_ macro)
23
- - Haml (if you want to load .sass files with the _style_ macro)
21
+ * RedCloth (\.%>[textile])
22
+ * BlueCloth _or_ RDiscount _or_ Maruku _or_ Kramdown (\.%>[markdown])
23
+ * Haml (if you want to load .sass files with the %>[style])
24
24
  ]
25
25
 
26
26
  Every Glyph project is comprised of the following directories:
@@ -33,15 +33,15 @@ Every Glyph project is comprised of the following directories:
33
33
  Additionally, the following files are also created at top level:
34
34
  * @config.yml@ -- containing your =>[#cfg|Project Configuration].
35
35
  * @document.glyph@ -- containing your =>[#struct|Document Structure]
36
- * @snippets.yml@ -- containing your text snippets. todo[Link to Snippets section]
36
+ * @snippets.yml@ -- containing your text =>[#incl|snippets].
37
37
 
38
38
  ]
39
39
 
40
40
  section[header[Document Structure|struct]
41
41
 
42
- Every Glyph project contains a @document.glyph@ file that is typically used to define the document structure. The default @document.glyph@
43
- generated automatically when creating a new project is the following:
42
+ Every Glyph project contains a @document.glyph@ file that is typically used to define the document structure. The default @document.glyph@ generated automatically when creating a new project is the following:
44
43
 
44
+ <notextile>
45
45
  code[=
46
46
  document[
47
47
  head[style[default.css]]
@@ -72,17 +72,19 @@ document[
72
72
  ]
73
73
  ]
74
74
  ]=]
75
+ </notextile>
76
+
75
77
 
76
78
  Even without knowing anything about &[glang], you can easily figure out that this file defines a document with a Table of Contents, a Preface and some Chapters. @frontmatter\[\]@, @preface\[\]@, @chapter\[\]@, etc. are all Glyph _macros_ used to define -- in this case -- some structural elements. In practice, this means that if you plan to generate an HTML document, they'll be converted into @<div>@ tags.
77
79
 
78
80
  Be aware that other macros, on the other hand, are used to do something completely different, e.g.:
79
81
  * @toc\[\]@ generates the document's Table of Contents
80
- * codeph[=@\[\]=] or its alias @include\[\]@ is used to copy the contents of another file stored anywhere in the @/text@ directory.
82
+ * codeph[=@\[\]=] or its alias @include\[\]@ is used to copy the contents of another file stored anywhere in the @text/@ directory.
81
83
 
82
84
  Let's now analyze this @document.glyph@ more in detail.
83
85
  * The @document\[\]@ macro wraps every other macro. This is necessary to create the initial @<html>@ tag.
84
86
  * Similarly, @head\[\]@ and @body\[\]@ are used to generate the respective HTML tags. Actually, @head\[\]@ already sets some metadata for you, by default (author and copyright).
85
- * Within @head\[\]@, the @style\[\]@ macro is used to load the @default.css@ stylesheet, which is included by default the @/styles@ directory of every Glyph project.
87
+ * Within @head\[\]@, the @style\[\]@ macro is used to load the @default.css@ stylesheet, which is one of the =>[#default_styles|default Glyph styleseets].
86
88
  * Immediately after the @body\[\]@ macro, the @titlepage\[\]@ macro is used to define (guess...) the first page of your document. @title\[\]@, @author\[\]@ and @pubdate\[\]@ insert the title of the document, its author and the publication date (retrieved from the project's =>[#cfg|configuration settings]).
87
89
  * Then, the @frontmatter\[\]@, @bodymatter\[\]@ and @backmatter\[\]@ macros are used to further divide the portions of your document according to the rules of =>[http://en.wikipedia.org/wiki/Book_design|book design]. They are not mandatory, but they can be used, for example, to number your appendixes with letters instead of numbers and similar.
88
90
  * @preface\[\]@, @chapter\[\]@, @appendix\[\]@ are just a way to wrap content in @<div>@ tags, from an HTML point of view, but they are also necessary to nest the content of your document and generate the Table of Contents automatically, together with the @header\[\]@ macro.
@@ -100,9 +102,9 @@ When compiling, Glyph loads all these configuration files and merges them accord
100
102
  * A setting configured in the _Project Configuration_ overrides the same setting in both Global and System configuration.
101
103
  * A setting configured in the _Global Configuration_ overrides the same setting in the _System Configuration_
102
104
 
103
- Typically, you should use the _Project Configuration_ for all project-specific settings and the _Global Configuration_ for settings affecting all your projects (for example, you may want to set 'document.author' in the Global Configuration instead of setting it in the Project Configuration of all your Glyph projects). The _System Configuration_ is best left untouched.
105
+ Typically, you should use the _Project Configuration_ for all project-specific settings and the _Global Configuration_ for settings affecting all your projects (for example, you may want to set the $>[document.author] in the Global Configuration instead of setting it in the Project Configuration of all your Glyph projects). The _System Configuration_ is best left untouched.
104
106
 
105
- Instead of editing your configuration settings directly, you can use the @glyph config@ command, as follows:
107
+ Instead of editing your configuration settings directly, you can use the #>[config], as follows:
106
108
 
107
109
  @glyph config@ _setting_ _\[value\]_
108
110
 
@@ -112,23 +114,27 @@ To change the value of a configuration setting, specify a value right after the
112
114
 
113
115
  @glyph config document.author "John Smith"@
114
116
 
117
+ tip[It is also possible to change configuration settings inside your document, using the %>[config:].]
118
+
115
119
  In this way, the document author will be set to _John Smith_ for the current project. To save this setting globally, add a @-g@ option, like this:
116
120
 
117
121
  @glyph config -g document.author "John Smith"@
118
122
 
119
123
  box[Regarding configuration values and data types...|
120
124
  Glyph attempts to "guess" the data type of a configuration values by evaluation (@Kernel#instance_eval@) if the value:
121
- - is wrapped in quotes (@"@ or @'@) &rarr; String
122
- - starts with a colon (@:@) &rarr; Symbol
123
- - is wrapped in square brackets (@\[@ and @\]@) &rarr; Array
124
- - is wrapped in curly brackets (@\{@ and @\}@) &rarr; Hash
125
- - is _true_ or _false_ &rarr; Boolean
126
- - If the value is _nil_ &rarr; NilClass
125
+ * is wrapped in quotes (@"@ or @'@) &rarr; @String@
126
+ * starts with a colon (@:@) &rarr; @Symbol@
127
+ * is wrapped in square brackets (@\[@ and @\]@) &rarr; @Array@
128
+ * is wrapped in curly brackets (@{@ and @}@) &rarr; @Hash@
129
+ * is _true_ or _false_ &rarr; @Boolean@
130
+ * is _nil_ &rarr; @NilClass@
127
131
 
128
132
  Note that this guessing is far from being foolproof: If you type something like _{:test, 2}_, for example, you'll get an error.
129
133
  ]
130
134
 
131
- There are plenty of configuration settings that can be modified, but most of them are best if left alone (and in the System Configuration file). For a complete reference, see =>[#cfg_ref]. Normally, you may just want to change the following ones:
135
+ There are plenty of configuration settings that can be modified, but most of them are best if left alone (and in the System Configuration file).
136
+
137
+ For a complete reference, see =>[#cfg_ref]. Normally, you may just want to change the following ones:
132
138
 
133
139
  table[
134
140
  tr[
@@ -136,15 +142,15 @@ table[
136
142
  th[Description]
137
143
  ]
138
144
  tr[
139
- td[*document.author*]
145
+ th[@document.author@]
140
146
  td[The author of the document]
141
147
  ]
142
148
  tr[
143
- td[*document.title*]
149
+ th[@document.title@]
144
150
  td[The title of the document]
145
151
  ]
146
152
  tr[
147
- td[*document.filename*]
153
+ th[@document.filename@]
148
154
  td[The document file name]
149
155
  ]
150
156
  ]
@@ -1,10 +1,13 @@
1
- Glyph is a _Rapid Document Authoring Framework_.
1
+ --[
2
+ &:[prince|=>[http://www.princexml.com/|Prince]]
3
+
4
+ ]Glyph is a _Rapid Document Authoring Framework_.
2
5
 
3
6
  Think of it like a sort of =>[http://www.rubyonrails.org|Ruby on Rails] but for creating text documents instead of web sites. With Glyph, you can manage your documents tidily in _projects_ that can be used to generate deliverables in different formats such as HTML or PDF (through &[prince]).
4
7
 
5
8
  section[header[Main Features]
6
9
 
7
- Glyph uses a =>[#macros_nutshell|simple macro system] to perform a wide variety of advanced tasks:
10
+ Glyph uses a simple macro system to perform a wide variety of advanced tasks:
8
11
  * Generate block-level HTML tags not commonly managed by lightweight markups, like @head@, @body@, @div@ and @table@.
9
12
  * Create and validate internal and external links.
10
13
  * Include and validate images and figures.
@@ -13,11 +16,15 @@ Glyph uses a =>[#macros_nutshell|simple macro system] to perform a wide variety
13
16
  * Store common snippets of text in a single YAML file and use them anywhere in your document, as many times as you need.
14
17
  * Store configuration settings in a YAML file and use them anywhere in your document, as many times as you need.
15
18
  * Evaluate Ruby code within your document.
16
- * Call macros from other macros (including snippets), carefully avoiding mutual calls.
19
+ * Include content only if certain conditions are satisfied.
20
+ * Define macros, snippets and configuration settings directly within your document.
21
+ * Highlight source code.
22
+ * Call macros from other macros (including snippets), avoiding mutual calls.
17
23
  * Include text files in other text files.
18
- * Include the contents of configuration settings (author, title) in the document.
24
+ * Include the value of any configuration setting (like author, title) in the document.
19
25
  * Filter input explicitly or implicitly, based on file extensions when including files.
20
- * Manage comments and todo items.
26
+ * Manage draft comments and todo items.
27
+
21
28
  ]
22
29
 
23
30
  section[header[Installation]
@@ -28,12 +35,14 @@ section[header[Installation]
28
35
 
29
36
  section[header[Essential Glyph commands]
30
37
 
31
- Glyph is 100% command line. Its interface resambles =>[http://git-scm.com/|Git's] for its simplicity and power (thanks to the =>[http://github.com/davetron5000/gli|Gli] gem). Here are some example commands:
38
+ Glyph is 100% command line. Its interface resambles =>[http://git-scm.com/|Git's] for its simplicity and power (thanks to the =>[http://github.com/davetron5000/gli|gli] gem). Here are some example commands:
32
39
 
33
40
  * @glyph init@ -- to initialize a new Glyph project in the current (empty) directory.
34
41
  * @glyph add introduction.textile@ -- to create a new file called _introduction.textile_.
35
42
  * @glyph compile@ -- to compile the current document into a single HTML file.
43
+ * @glyph compile --auto@ -- to keep recompiling the current document every time a file is changed.
36
44
  * @glyph compile -f pdf@ -- to compile the current document into HTML and then transform it into PDF using &[prince].
45
+ * @glyph compile readme.glyph@ -- to compile a _readme.glyph_ located in the current directory into a single HTML file.
37
46
 
38
47
  ]
39
48
 
@@ -48,18 +57,17 @@ section[header[Something about Glyph]
48
57
  You can use Glyph macros in conjunction
49
58
  with _Textile_ or _Markdown_ to
50
59
  produce HTML files effortlessly.
51
- section[header[What about PDFs?|pdf]
60
+ section[header[What about PDFs?\|pdf]
52
61
  Once you have a single, well-formatted HTML
53
62
  file, converting it to PDF is
54
63
  extremely easy with a 3rd-party
55
- renderer like =>[http://www.princexml.com|Prince].
64
+ renderer like =>[http://www.princexml.com\|Prince].
56
65
  ]
57
66
  ]
58
67
  =]
59
68
 
60
69
  **HTML Output:**
61
70
 
62
- <notextile>
63
71
  code[=
64
72
  <div class="section">
65
73
  <h2 id="h_10">Something about Glyph</h2>
@@ -74,7 +82,7 @@ code[=
74
82
  like <a href="http://www.princexml.com">Prince</a>.</p>
75
83
  </div>
76
84
  </div>
77
- =]</notextile>
85
+ =]
78
86
  ]
79
87
 
80
88
  section[header[Resources]
@@ -82,7 +90,9 @@ section[header[Resources]
82
90
  * Home Page: =>[http://www.h3rald.com/glyph/]
83
91
  * Repository: =>[http://www.github.com/h3rald/glyph/]
84
92
  * Bug Tracking: =>[http://www.github.com/h3rald/glyph/issues]
85
- * Book (PDF): =>[http://github.com/h3rald/glyph/raw/master/book/output/pdf/glyph.pdf]
86
- * Reference Documentation: =>[http://yardoc.org/docs/h3rald-glyph/]
93
+ * Development Wiki =>[http://wiki.github.com/h3rald/glyph]
94
+ * RubyGem Download =>[http://www.rubygems.org/gems/glyph]
95
+ * Book (PDF): =>[http://github.com/h3rald/glyph/raw/\.%[Glyph::VERSION.strip]/book/output/pdf/glyph.pdf]
96
+ * Reference Documentation: =>[http://yardoc.org/docs/glyph/]
87
97
  * User Group: =>[http://groups.google.com/group/glyph-framework]
88
98
  ]