glyph 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/README.textile +80 -0
  2. data/Rakefile +51 -0
  3. data/VERSION +1 -0
  4. data/bin/glyph +7 -0
  5. data/book/config.yml +5 -0
  6. data/book/document.glyph +55 -0
  7. data/book/images/glyph.png +0 -0
  8. data/book/images/glyph.svg +351 -0
  9. data/book/lib/macros/reference.rb +98 -0
  10. data/book/output/html/glyph.html +1809 -0
  11. data/book/output/html/images/glyph.png +0 -0
  12. data/book/output/html/images/glyph.svg +351 -0
  13. data/book/output/pdf/glyph.pdf +4277 -0
  14. data/book/snippets.yml +13 -0
  15. data/book/styles/css3.css +220 -0
  16. data/book/styles/default.css +190 -0
  17. data/book/text/authoring.textile +351 -0
  18. data/book/text/extending.textile +148 -0
  19. data/book/text/getting_started.textile +152 -0
  20. data/book/text/introduction.textile +88 -0
  21. data/book/text/ref_commands.textile +74 -0
  22. data/book/text/ref_config.textile +0 -0
  23. data/book/text/ref_macros.textile +256 -0
  24. data/book/text/troubleshooting.textile +118 -0
  25. data/config.yml +63 -0
  26. data/document.glyph +29 -0
  27. data/glyph.gemspec +138 -0
  28. data/lib/glyph.rb +128 -0
  29. data/lib/glyph/commands.rb +124 -0
  30. data/lib/glyph/config.rb +152 -0
  31. data/lib/glyph/document.rb +145 -0
  32. data/lib/glyph/glyph_language.rb +530 -0
  33. data/lib/glyph/glyph_language.treetop +27 -0
  34. data/lib/glyph/interpreter.rb +84 -0
  35. data/lib/glyph/macro.rb +69 -0
  36. data/lib/glyph/node.rb +126 -0
  37. data/lib/glyph/system_extensions.rb +77 -0
  38. data/macros/common.rb +66 -0
  39. data/macros/filters.rb +69 -0
  40. data/macros/html/block.rb +119 -0
  41. data/macros/html/inline.rb +43 -0
  42. data/macros/html/structure.rb +138 -0
  43. data/spec/files/container.textile +5 -0
  44. data/spec/files/document.glyph +2 -0
  45. data/spec/files/document_with_toc.glyph +3 -0
  46. data/spec/files/included.textile +4 -0
  47. data/spec/files/ligature.jpg +449 -0
  48. data/spec/files/markdown.markdown +8 -0
  49. data/spec/files/test.sass +2 -0
  50. data/spec/lib/commands_spec.rb +83 -0
  51. data/spec/lib/config_spec.rb +79 -0
  52. data/spec/lib/document_spec.rb +100 -0
  53. data/spec/lib/glyph_spec.rb +76 -0
  54. data/spec/lib/interpreter_spec.rb +90 -0
  55. data/spec/lib/macro_spec.rb +60 -0
  56. data/spec/lib/node_spec.rb +76 -0
  57. data/spec/macros/filters_spec.rb +42 -0
  58. data/spec/macros/macros_spec.rb +159 -0
  59. data/spec/spec_helper.rb +92 -0
  60. data/spec/tasks/generate_spec.rb +31 -0
  61. data/spec/tasks/load_spec.rb +37 -0
  62. data/spec/tasks/project_spec.rb +41 -0
  63. data/styles/css3.css +220 -0
  64. data/styles/default.css +190 -0
  65. data/tasks/generate.rake +57 -0
  66. data/tasks/load.rake +55 -0
  67. data/tasks/project.rake +33 -0
  68. metadata +192 -0
File without changes
@@ -0,0 +1,256 @@
1
+ section[header[Common Macros]
2
+
3
+ ref_macro[comment|
4
+ Evaluates to nothing. Used to add comments in a Glyph document that will not be displayed in output files.
5
+
6
+ aliases[--]
7
+ example[--\[This is a comment. It will not be displayed in the output\]]
8
+ ]
9
+
10
+ ref_macro[todo|
11
+ Saves the value as a TODO item, which can be printed using the #>[todo].
12
+
13
+ example[todo\[Remember to do this.\]]
14
+ ]
15
+
16
+ ref_macro[snippet|
17
+ Evaluates to the snippet referenced by its value.
18
+
19
+ aliases[&]
20
+ example[&\[glang\]]
21
+ ]
22
+
23
+ ref_macro[include|
24
+ Evaluates to the contents of a text file stored in the @text/@ directory referenced by its value. If &[filter_by_ext], filters the contents of the file using the =>[#f_macros|filter macro] corresponding to the file extension.
25
+
26
+ aliases[@]
27
+ example[@\[introduction.textile\]]
28
+ ]
29
+
30
+ ref_macro[ruby|
31
+ Evaluates its value as Ruby code (using @Kernel#instance_eval@).
32
+
33
+ aliases[%]
34
+ examples[
35
+ %\[Time.now\]
36
+ %\[Glyph::VERSION\]
37
+ ]
38
+ ]
39
+
40
+ ref_macro[config|
41
+ Evaluates to the configuration setting referenced by its value.
42
+
43
+ aliases[$]
44
+ example[$\[document.author\]]
45
+ ]
46
+
47
+ ref_macro[escape|
48
+ Evaluates to its value. Commonly used with the escaping delimiters @\[=@ and @=\]@.
49
+
50
+ aliases[.]
51
+ example[.\[=Macros are escaped here =>\[#test\].=\]]
52
+ ]
53
+
54
+ ] --[End common macros]
55
+
56
+ section[header[Filter Macros|f_macros]
57
+
58
+ ref_macro[textile|
59
+ Uses the RedCloth gem to transform the value into HTML or LaTeX, depending on the value of the $>[filters.target].
60
+
61
+ &[called_on_files] with a @.textile@ extension.
62
+
63
+ example[textile\[This is a *strong emphasis*.\]]
64
+ ]
65
+
66
+ ref_macro[markdown|
67
+ Uses a markdown converter (BlueCloth, RDiscount, Maruku or Kramdown) to transform the value into HTML if the $>[filters.target] is set to @html@.
68
+
69
+ &[called_on_files] with a @.markdown@ or a @.md@ extension.
70
+
71
+ example[markdown\[This is *emphasized* text.\]]
72
+ ]
73
+
74
+ ] --[End filter macros]
75
+
76
+ section[header[Block Macros]
77
+
78
+ ref_macro[note|
79
+ Creates a note @div@ containing the value.
80
+
81
+ aliases[important, caution, tip]
82
+ example[note\[This is a note.\]]
83
+ ]
84
+
85
+ ref_macro[box|
86
+ Creates a titled box @div@.
87
+
88
+ *Example:*
89
+
90
+ code[
91
+ box\[Why boxes?\|
92
+ Boxes can be used to make a section of text stand out from the rest of the document.
93
+ \]
94
+ ]
95
+ ]
96
+
97
+ ref_macro[code|
98
+ Used to render a block of code within @pre@ and @code@ tags. For inline code, see the %>[codeph].
99
+
100
+ *Example:*
101
+
102
+ code[
103
+ code\[
104
+ def hello
105
+ puts "Hello World"
106
+ end
107
+ \]
108
+ ]
109
+
110
+ ]
111
+
112
+ ref_macro[title|
113
+ Renders the title of the document (based on the $>[document.title]) within a @h1@ tag.
114
+
115
+ example[title\[\]]
116
+ ]
117
+
118
+ ref_macro[subtitle|
119
+ Renders the subtitle of the document (based on the $>[document.subtitle]) within a @h2@ tag.
120
+
121
+ example[subtitle\[\]]
122
+ ]
123
+
124
+ ref_macro[pubdate|
125
+ Evaluates to a date string (in the format: _current-month_ _current-year_; or _%B_ _%Y_), within a @div@ tag.
126
+
127
+ example[pubdate\[\]]
128
+ ]
129
+
130
+ ref_macro[img|
131
+ Includes an image in the document, optionally scaled according to the specified width and height. The image must be stored within the @images/@ directory of the current project.
132
+
133
+ examples[
134
+ img\[icon.png\]
135
+ img\[holidays/landscape.jpg\|70%\]
136
+ img\[logo.svg\|50%\|50%\]
137
+ ]
138
+ ]
139
+
140
+ ref_macro[fig|
141
+ Includes an image in the document, with an optional caption.
142
+
143
+ examples[
144
+ fig\[diagram.png\]
145
+ fig\[graph.png\|Monthly pageviews\]
146
+ ]
147
+ ]
148
+
149
+ ref_macro[table|
150
+ Evaluates to an HTML table. Used in conjunction with the =>[#m_tr|@tr@], =>[#m_td|@td@] and =>[#m_th|@th@] macros.
151
+
152
+ *Example:*
153
+
154
+ code[
155
+ table\[
156
+ tr\[
157
+ th\[Name\]
158
+ th\[Value\]
159
+ \]
160
+ tr\[
161
+ td\[A\]
162
+ td\[1\]
163
+ \]
164
+ tr\[
165
+ td\[B\]
166
+ td\[2\]
167
+ \]
168
+ \]
169
+ ]
170
+
171
+ ]
172
+
173
+ ref_macro[tr|See =>[#m_table].]
174
+ ref_macro[th|See =>[#m_table].]
175
+ ref_macro[td|See =>[#m_table].]
176
+
177
+
178
+ ] --[End block macros]
179
+
180
+ section[header[Inline Macros]
181
+
182
+ ref_macro[anchor|
183
+ Creates a named anchor (or bookmark).
184
+
185
+ aliases[bookmark, #]
186
+ example[#\[test\|Test Bookmark\]]
187
+ ]
188
+
189
+ ref_macro[link|
190
+ Creates an hyperlink (\.fmi[creating links|#links]).
191
+
192
+ aliases[=>]
193
+ examples[
194
+ =>\[#introduction\]
195
+ =>\[#troub\|Troubleshooting\]
196
+ =>\[http://www.h3rald.com\|H3RALD.com\]
197
+ ]
198
+ ]
199
+
200
+ ref_macro[codeph|
201
+ Wraps the value in a @code@ tag.
202
+
203
+ example[codeph\[Kernel.instance_eval\]]
204
+
205
+ ]
206
+
207
+ ref_macro[fmi|
208
+ Creates a _For More Information_ link (for an example usage, see the %>[link]).
209
+
210
+ example[fmi\[creating links\|#links\]]
211
+ ]
212
+
213
+ ] --[End inline macros]
214
+
215
+ section[header[Structure Macros]
216
+
217
+ ref_macro[div|
218
+ Creates a @div@ tag.
219
+
220
+ *Aliases:* todo[List div aliases]
221
+ ]
222
+
223
+ ref_macro[header|
224
+ Creates an @h2@, @h3@, @h4@, etc. header (\.fmi[using headers|#sec_head]).
225
+
226
+ examples[
227
+ header\[Introduction\]
228
+ header\[Getting Started\|gs\]
229
+ ]
230
+ ]
231
+
232
+ ref_macro[document|
233
+ The root macro used in every Glyph document.
234
+ ]
235
+
236
+ ref_macro[body|
237
+ Creates a @body@ tag.
238
+ ]
239
+
240
+ ref_macro[head|
241
+ Creates a @head@ tag, pre-populated with @title@ and author/copyright meta tags.
242
+ ]
243
+
244
+ ref_macro[style|
245
+ Embeds the content of a CSS or Sass file within a @style@ tag (\.fmi[stylesheets|#stylesheets]).
246
+
247
+ example[style\[default.css\]]
248
+ ]
249
+
250
+ ref_macro[toc|
251
+ Generates a _Table of Contents_ based on how sections and headers are nested in the current document.
252
+
253
+ example[toc\[\]]
254
+ ]
255
+
256
+ ] --[End structure macros]
@@ -0,0 +1,118 @@
1
+ This chapter lists the most common error messages that can be returned when running a Glyph command. It does not aim to be an exhaustive list, especially if you =>[#extending|extended] Glyph by creating your own macros.
2
+
3
+ section[header[Generic Errors]
4
+
5
+ error_table[
6
+ ref_error[Document contains syntax errors|
7
+ This error is returned if the document was not parsed because of one or more syntax error.
8
+
9
+ *At present, no indication on the exact location of the error(s) is provided*, so the only way to determine what went wrong is to try compiling a single file at a time (@glyph compile -s source-file@), and examine more closely the source of the files that do not compile.
10
+ ]
11
+ ref_error[Invalid alias: macro '_macro-name_' already exists|
12
+ The alias name supplied to the @macro_alias@ method has already been used for another macro or alias.
13
+ ]
14
+ ref_error[Undefined macro '_macro-name_'|
15
+ The document contains a macro that does not exist, i.e. it is not a standard or used-defined =>[#macro_ref|Glyph macro or alias].
16
+ ]
17
+ ref_error[An error occurred when generating _file-name_.pdf|
18
+ Returned if Prince could not generate the PDF file or if Prince is not installed. Normally, Prince provides additional details on the specific error(s).
19
+ ]
20
+ ref_error[Glyph cannot generate PDF. Please specify a valid pdf_renderer setting|
21
+ Returned if the @pdf_renderer@ setting has not be set to a valid PDF renderer. Currently, the only supported value for this setting is @prince@.
22
+ ]
23
+ ref_error[The current directory is not a valid Glyph project|
24
+ Returned if a glyph command was executed outside a valid glyph project directory.
25
+ ]
26
+ ref_error[Invalid snippet file|
27
+ The @snippet.yml@ file contains invalid data. Most likely, it does not evaluate to a Ruby Hash.
28
+ ]
29
+ ref_error[Directory '_directory-name_' is not empty|
30
+ Returned when executing @glyph init@ in a directory that is not empty.
31
+ ]
32
+ ref_error[File '_file-name_' already exists|
33
+ Returned if the name of an existing file was specified as a parameter for the @glyph add@ command.
34
+ ]
35
+ ]
36
+ ] --[End Generic Errors]
37
+
38
+
39
+
40
+ section[header[Command Errors]
41
+
42
+ error_table[
43
+
44
+ ref_error[Please specify a file name|
45
+ No file name was specified for the @glyph add@ command.
46
+ ]
47
+
48
+ ref_error[Output target not specified|
49
+ Returned if no target was specified for the @glyph compile@ command _and_ if the @document.output@ configuration setting is not set.
50
+ ]
51
+
52
+ ref_error[Unknown output target '_target-name_'|
53
+ An unsupported output target was specified for the @glyph compile@ command. Only the following output targets are supported:
54
+ - @html@
55
+ - @pdf@
56
+ ]
57
+
58
+ ref_error[Too few/too many arguments|
59
+ Returned if the @glyph config@ command was used with no arguments or more than two arguments respectively.
60
+ ]
61
+
62
+ ref_error[Unknown setting '_setting-name_'|
63
+ The name of an unknown setting was specified for the @glyph config@ command.
64
+ ]
65
+ ]
66
+ ] --[End Command Errors]
67
+
68
+
69
+
70
+ section[header[Macro Errors]
71
+
72
+ The following errors are displayed in the form:
73
+
74
+ _macro-path_ _message_
75
+
76
+ Where:
77
+ * _macro-path_ is the full path to the macro that returned the error, within the document syntax tree, e.g. @document/body/bodymatter/chapter/section/header/&@ if the error occurrent in a snippet within the header of a section in the @bodymatter@ part of the document.
78
+ * _message_ is the error message.
79
+
80
+ error_table[
81
+
82
+ ref_error[Mutual inclusion|
83
+ This error is returned if a catch-22 situation occurs with macro inclusion, for example if the body of a snippet includes a reference to the same snippet.
84
+ ]
85
+ ref_error[Snippet '_snippet-id_' does not exist|
86
+ Returned by the %>[snippet] if an invalid snippet was supplied.
87
+ ]
88
+ ref_error[File '_file-name_' not found|
89
+ Returned by the %>[include] if an invalid file was supplied.
90
+ ]
91
+ ref_error[Filter macro '_macro-name_' not found|
92
+ Returned by the %>[include] macro if the @filters.by_file_extension@ setting is set to @true@ but the file extension of the included file is not recognized as a filter macro.
93
+ ]
94
+ ref_error[RedCloth gem not installed. Please run: gem insall RedCloth|
95
+ Returned by the %>[textile] if the RedCloth gem is not installed.
96
+ ]
97
+ ref_error[No MarkDown converter installed. Please run: gem insall bluecloth|
98
+ Returned by the %>[markdown] if no valid Markup converter gem is installed.
99
+
100
+ Glyph checks for: BlueCloth, Maruku, Kramdown and RDiscount.
101
+ ]
102
+ ref_error[Image/Figure not found|
103
+ Retured by the %>[img] or the %>[fig] respectively, if the specified image file could not be found within the @images/@ folder.
104
+ ]
105
+ ref_error[Bookmark '_bookmark-name_' already exists|
106
+ Returned by the %>[anchor] or by the %>[header] if the anchor ID supplied as parameter has already been used in the document.
107
+ ]
108
+ ref_error[Bookmark '_bookmark-name_' already exists|
109
+ Returned by the %>[link] if the anchor ID supplied as parameter has not been used in the document.
110
+ ]
111
+ ref_error[Stylesheet '_file-name_' not found|
112
+ Returned by the %>[style] if the .css or .sass file supplied as parameter was not found in the @styles/@ directory.
113
+ ]
114
+ ref_error[Haml is not installed. Please run: gem install haml|
115
+ Returned by the %>[style] macro if a .sass file was passed as parameter but the Haml gem is not installed.
116
+ ]
117
+ ]
118
+ ] --[End Macro Errors]
data/config.yml ADDED
@@ -0,0 +1,63 @@
1
+ :document:
2
+ :source: 'document.glyph'
3
+ :author: ""
4
+ :title: ""
5
+ :filename: ""
6
+ :output: ""
7
+ :output_targets: [:html, :pdf]
8
+ :structure:
9
+ :hidden:
10
+ - :imprint
11
+ - :dedication
12
+ - :inspiration
13
+ - :postscript
14
+ - :colophon
15
+ - :promotion
16
+ :special:
17
+ - :preface
18
+ - :foreword
19
+ - :introduction
20
+ - :acknowledgement
21
+ - :prologue
22
+ - :epilogue
23
+ - :addendum
24
+ - :glossary
25
+ - :bibliography
26
+ - :references
27
+ - :index
28
+ - :lot
29
+ - :lof
30
+ :frontmatter:
31
+ - :preface
32
+ - :imprint
33
+ - :dedication
34
+ - :inspiration
35
+ - :foreword
36
+ - :introduction
37
+ - :acknowledgement
38
+ - :prologue
39
+ :bodymatter:
40
+ - :volume
41
+ - :book
42
+ - :part
43
+ - :chapter
44
+ :backmatter:
45
+ - :epilogue
46
+ - :afterword
47
+ - :postscript
48
+ - :appendix
49
+ - :addendum
50
+ - :glossary
51
+ - :colophon
52
+ - :bibliography
53
+ - :promotion
54
+ - :references
55
+ - :index
56
+ - :lot
57
+ - :lof
58
+ :pdf_renderer: 'prince'
59
+ :filters:
60
+ :by_file_extension: true
61
+ :target: 'html'
62
+ :redcloth:
63
+ :restrictions: []
data/document.glyph ADDED
@@ -0,0 +1,29 @@
1
+ document[
2
+ head[style[default.css]]
3
+ body[
4
+ titlepage[
5
+ title[]
6
+ author[]
7
+ pubdate[]
8
+ ]
9
+ frontmatter[
10
+ toc[]
11
+ preface[header[Preface]
12
+ @[preface.textile]
13
+ ]
14
+ ]
15
+ bodymatter[
16
+ chapter[header[Chapter #1]
17
+ @[chapter_1.textile]
18
+ ]
19
+ chapter[header[Chapter #2]
20
+ @[chapter_2.textile]
21
+ ]
22
+ ]
23
+ backmatter[
24
+ appendix[header[Appendix A]
25
+ @[appendix_a.textile]
26
+ ]
27
+ ]
28
+ ]
29
+ ]