glyph 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/.gitignore +7 -0
  2. data/AUTHORS.textile +8 -7
  3. data/CHANGELOG.textile +89 -8
  4. data/LICENSE.textile +1 -2
  5. data/README.textile +89 -61
  6. data/Rakefile +12 -10
  7. data/VERSION +1 -1
  8. data/benchmark.rb +1 -1
  9. data/book/config.yml +18 -4
  10. data/book/document.glyph +269 -45
  11. data/book/images/glyph/commands_tasks.png +0 -0
  12. data/book/images/{document_generation.png → glyph/document_generation.png} +0 -0
  13. data/book/images/glyph/glyph.eps +123 -0
  14. data/book/images/glyph/glyph.png +0 -0
  15. data/book/images/glyph/glyph.svg +29 -0
  16. data/book/lib/commands/commands.rb +11 -0
  17. data/book/lib/layouts/bookindex.glyph +127 -0
  18. data/book/lib/layouts/bookpage.glyph +129 -0
  19. data/book/lib/layouts/project.glyph +26 -0
  20. data/book/lib/macros/reference.rb +27 -7
  21. data/book/lib/tasks/tasks.rake +52 -0
  22. data/book/snippets.yml +1 -1
  23. data/book/text/{acknowledgement.glyph → acknowledgements.glyph} +4 -2
  24. data/book/text/changelog.glyph +29 -3
  25. data/book/text/compiling/compiling.glyph +44 -20
  26. data/book/text/compiling/lite_mode.glyph +0 -4
  27. data/book/text/compiling/programmatic_usage.glyph +1 -5
  28. data/book/text/config/document.glyph +35 -0
  29. data/book/text/config/filters.glyph +28 -0
  30. data/book/text/config/options.glyph +25 -0
  31. data/book/text/config/output.glyph +83 -0
  32. data/book/text/extending/bookmarks_headers.glyph +0 -5
  33. data/book/text/extending/command.glyph +56 -0
  34. data/book/text/extending/commands_tasks.glyph +39 -0
  35. data/book/text/extending/further_reading.glyph +0 -3
  36. data/book/text/extending/internals.glyph +3 -5
  37. data/book/text/extending/interpreting.glyph +0 -4
  38. data/book/text/extending/layouts.glyph +68 -0
  39. data/book/text/extending/macro_def.glyph +0 -5
  40. data/book/text/extending/output_format.glyph +78 -0
  41. data/book/text/extending/params_attrs.glyph +0 -3
  42. data/book/text/extending/placeholders.glyph +0 -4
  43. data/book/text/extending/task.glyph +46 -0
  44. data/book/text/extending/validators.glyph +5 -6
  45. data/book/text/getting_started/configuration.glyph +1 -5
  46. data/book/text/getting_started/create_project.glyph +1 -5
  47. data/book/text/getting_started/structure.glyph +0 -4
  48. data/book/text/introduction.glyph +100 -75
  49. data/book/text/license.glyph +1 -2
  50. data/book/text/macros/macros_block.glyph +8 -4
  51. data/book/text/macros/macros_core.glyph +0 -3
  52. data/book/text/macros/macros_filters.glyph +2 -7
  53. data/book/text/macros/macros_inline.glyph +0 -4
  54. data/book/text/macros/macros_structure.glyph +0 -4
  55. data/book/text/ref_commands.glyph +29 -7
  56. data/book/text/stats/bookmarks.glyph +49 -0
  57. data/book/text/stats/links.glyph +90 -0
  58. data/book/text/stats/macros.glyph +73 -0
  59. data/book/text/stats/snippets.glyph +50 -0
  60. data/book/text/stats/stats.glyph +79 -0
  61. data/book/text/text_editing/attribute_intro.glyph +22 -0
  62. data/book/text/text_editing/code.glyph +0 -5
  63. data/book/text/text_editing/conditionals.glyph +0 -4
  64. data/book/text/text_editing/esc_quot.glyph +64 -0
  65. data/book/text/text_editing/evaluation.glyph +0 -3
  66. data/book/text/text_editing/glyph_files.glyph +0 -3
  67. data/book/text/text_editing/images.glyph +0 -5
  68. data/book/text/text_editing/inclusions.glyph +0 -4
  69. data/book/text/text_editing/links.glyph +2 -7
  70. data/book/text/text_editing/macro_intro.glyph +1 -98
  71. data/book/text/text_editing/raw_html.glyph +0 -87
  72. data/book/text/text_editing/section_aliases.glyph +28 -0
  73. data/book/text/text_editing/sections.glyph +1 -32
  74. data/book/text/text_editing/stylesheets.glyph +3 -5
  75. data/book/text/text_editing/topics.glyph +33 -0
  76. data/book/text/text_editing/xml_fallback.glyph +73 -0
  77. data/book/text/troubleshooting/errors_command.glyph +0 -3
  78. data/book/text/troubleshooting/errors_generic.glyph +21 -6
  79. data/book/text/troubleshooting/errors_macro.glyph +11 -8
  80. data/book/text/troubleshooting/errors_parser.glyph +0 -3
  81. data/config.yml +60 -25
  82. data/glyph.gemspec +90 -36
  83. data/layouts/web/index.glyph +16 -0
  84. data/layouts/web/topic.glyph +15 -0
  85. data/layouts/web5/index.glyph +16 -0
  86. data/layouts/web5/topic.glyph +17 -0
  87. data/lib/glyph.rb +36 -49
  88. data/lib/glyph/analyzer.rb +253 -0
  89. data/lib/glyph/bookmark.rb +92 -0
  90. data/lib/glyph/commands.rb +9 -221
  91. data/lib/glyph/commands/add.rb +8 -0
  92. data/lib/glyph/commands/compile.rb +93 -0
  93. data/lib/glyph/commands/config.rb +38 -0
  94. data/lib/glyph/commands/init.rb +6 -0
  95. data/lib/glyph/commands/outline.rb +45 -0
  96. data/lib/glyph/commands/stats.rb +48 -0
  97. data/lib/glyph/commands/todo.rb +29 -0
  98. data/lib/glyph/config.rb +2 -0
  99. data/lib/glyph/document.rb +61 -30
  100. data/lib/glyph/interpreter.rb +2 -2
  101. data/lib/glyph/macro.rb +14 -5
  102. data/lib/glyph/macro_helpers.rb +280 -0
  103. data/lib/glyph/macro_validators.rb +37 -2
  104. data/lib/glyph/reporter.rb +182 -0
  105. data/lib/glyph/syntax_node.rb +37 -10
  106. data/lib/glyph/system_extensions.rb +8 -45
  107. data/lib/glyph/utils.rb +148 -0
  108. data/macros/core.rb +10 -15
  109. data/macros/filters.rb +4 -5
  110. data/macros/html/block.rb +46 -30
  111. data/macros/html/inline.rb +9 -35
  112. data/macros/html/structure.rb +59 -72
  113. data/macros/html5/block.rb +69 -0
  114. data/macros/html5/inline.rb +24 -0
  115. data/macros/html5/structure.rb +139 -0
  116. data/macros/xml.rb +1 -1
  117. data/spec/files/custom_command.rb +6 -0
  118. data/spec/files/custom_tasks.rake +6 -0
  119. data/spec/files/document_for_stats.glyph +12 -0
  120. data/spec/files/references.glyph +4 -0
  121. data/spec/files/web1.glyph +11 -0
  122. data/spec/files/web2.glyph +10 -0
  123. data/spec/files/web_doc.glyph +23 -0
  124. data/spec/lib/analyzer_spec.rb +137 -0
  125. data/spec/lib/bookmark_spec.rb +64 -0
  126. data/spec/lib/commands_spec.rb +30 -5
  127. data/spec/lib/document_spec.rb +49 -9
  128. data/spec/lib/glyph_spec.rb +21 -1
  129. data/spec/lib/macro_spec.rb +6 -6
  130. data/spec/lib/macro_validators_spec.rb +24 -0
  131. data/spec/lib/reporter_spec.rb +132 -0
  132. data/spec/macros/core_spec.rb +2 -3
  133. data/spec/macros/filters_spec.rb +2 -2
  134. data/spec/macros/html5_spec.rb +101 -0
  135. data/spec/macros/macros_spec.rb +16 -6
  136. data/spec/macros/web5_spec.rb +32 -0
  137. data/spec/macros/web_spec.rb +59 -0
  138. data/spec/macros/xml_spec.rb +1 -1
  139. data/spec/spec_helper.rb +24 -4
  140. data/spec/tasks/generate_spec.rb +54 -0
  141. data/spec/tasks/load_spec.rb +29 -3
  142. data/spec/tasks/project_spec.rb +21 -3
  143. data/styles/default.css +40 -4
  144. data/styles/pagination.css +59 -41
  145. data/tasks/generate.rake +110 -31
  146. data/tasks/load.rake +39 -7
  147. data/tasks/project.rake +9 -7
  148. metadata +115 -34
  149. data/book/images/glyph.png +0 -0
  150. data/book/images/glyph.svg +0 -351
  151. data/book/output/html/glyph.html +0 -4482
  152. data/book/output/html/images/document_generation.png +0 -0
  153. data/book/output/html/images/glyph.png +0 -0
  154. data/book/output/html/images/glyph.svg +0 -351
  155. data/book/output/pdf/glyph.pdf +4 -10254
  156. data/book/script/authors +0 -1
  157. data/book/script/changelog +0 -1
  158. data/book/script/license +0 -1
  159. data/book/script/readme +0 -1
  160. data/book/text/ref_config.glyph +0 -100
  161. data/book/text/ref_macros.glyph +0 -6
  162. data/book/text/troubleshooting/errors_intro.glyph +0 -3
@@ -1,5 +1,3 @@
1
- section[
2
- @title[Further Reading]
3
1
  txt[
4
2
  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.
5
3
 
@@ -10,4 +8,3 @@ To gain a deeper understanding on how macros are executed, have a look at the fo
10
8
  * class[Glyph::Document]
11
9
  * class[Glyph::Macro]
12
10
  ]
13
- ]
@@ -1,8 +1,6 @@
1
- section[
2
- @title[A quick look at Glyph's internals]
3
1
  p[If you plan on extending Glyph, knowing how it works inside helps. It is not mandatory by any means, but it definitely helps, especially when creating complex macros.]
4
2
  p[What happens behind the scenes when you call code[glyph compile]? Glyph's code is parsed, analyzed and then translated into text, and here's how:]
5
- figure[document_generation.png|A sequence diagram for document generation]
3
+ figure[glyph/document_generation.png|A sequence diagram for document generation]
6
4
  txt[From the diagram, it is possible to divide the document generation process into three phases:
7
5
  * The _Parsing Phase_ starts when a chunk of Glyph code is passed (by the code[generate:document] Rake task, for example) to a class[Glyph::Interpreter]. The interpreter initializes a class[Glyph::Parser] that parses the code and returns an _Abstract Syntax Tree_ (AST) of class[Glyph::SyntaxNode] objects.
8
6
  * The _Analysis Phase_ (Processing) starts when the interpreter method calls the @analyze@ method, instantiating a new class[Glyph::Document]. The @Glyph::Document@ object evaluates the AST expanding all macro nodesth (that's when macros are executed) and generates string.
@@ -67,7 +65,8 @@ section[
67
65
  ]
68
66
  p[Finally, when the document is finalized, placeholders and escape sequences are removed and the final result is the following:]
69
67
  highlight[=html|
70
- <span class="fmi">for more information on something, see <a href="#test">Test Section</a></span>
68
+ <span class="fmi">for more information on something,
69
+ see <a href="#test">Test Section</a></span>
71
70
  [...]
72
71
  <div class="section">
73
72
  <h2 id="test">Test Section</h2>
@@ -76,4 +75,3 @@ section[
76
75
  </div>
77
76
  =]
78
77
  ]
79
- ]
@@ -1,6 +1,3 @@
1
- section[
2
- @title[Interpreting Glyph Code]
3
- @id[interpreting]
4
1
 
5
2
  txt[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:]
6
3
 
@@ -48,4 +45,3 @@ rewrite:[issue\|
48
45
  p[Within the %>[rewrite:], it is possible to use a special syntax to call the code[raw_attr] or code[raw_param] methods: br[]
49
46
  code[{{]em[parameter_number] or em[attribute_name]code[}}]]
50
47
  ]
51
- ]
@@ -0,0 +1,68 @@
1
+ txt[
2
+ When generating =>[#topics|topic]-based outputs, Glyph uses _layouts_ to render topics as standalone documents. By default, the following two layout are used:
3
+ * code[topic] -- used to render standard topics.
4
+ * code[index] -- used to render the index page of your document.
5
+
6
+ Layouts are nothing more than "fancy" Glyph macros defined using the Glyph language (i.e. by using =>[#rewriting|macro rewriting]) within a single code[.glyph] file.
7
+ ]
8
+ section[
9
+ @title[Topic Layout]
10
+ p[The default layout used to render all web topics (the layout used for web5 topics is very similar) is defined as follows:]
11
+ highlight[=html|
12
+ document[
13
+ head[
14
+ style[default.css]
15
+ ]
16
+ body[
17
+ @class[topic]
18
+ section[
19
+ @title[{{title}}]
20
+ @id[{{id}}]
21
+ navigation[{{id}}]
22
+ {{contents}}
23
+ navigation[{{id}}]
24
+ ]
25
+ ]
26
+ ]
27
+ =]
28
+ txt[Note that it takes the following attributes, passed automatically by Glyph when processing each topic:
29
+ * code[title] -- the title of the topic.
30
+ * code[id] -- the ID of the topic.
31
+ * code[contents] -- the body of the topic.
32
+ ]
33
+ ]
34
+ section[
35
+ @title[Index Layout]
36
+ @id[index_layout]
37
+ p[The default layout used to render the web index page (the layout used for the web5 index is very similar) is defined as follows:]
38
+ highlight[=html|
39
+ document[
40
+ head[
41
+ style[default.css]
42
+ ]
43
+ body[
44
+ @class[topic]
45
+ halftitlepage[
46
+ title[]
47
+ subtitle[]
48
+ author[]
49
+ ]
50
+ frontmatter[
51
+ toc[]
52
+ ]
53
+ ]
54
+ ]
55
+ =]
56
+ p[Index layouts do not take any attribute or parameter (basically because they are used to produce only one page).]
57
+ ]
58
+ section[
59
+ @title[Creating a Custom Layout]
60
+ txt[
61
+ To create a custom layout, proceed as follows:
62
+ * Create a @.glyph@ file in the @lib/layouts@ directory, within your project, e.g. @mytopic.glyph@
63
+ * Add the layout code, making sure (for topic layouts) that all the attributes (@title@, @id@, @contents@) are specified correctly.
64
+ * Set the @output.*.layouts.topic@ setting to the name of the new layout (@mytopic@).
65
+ ]
66
+ tip[You can override which layout to use on a specific topic by specifying it in a code[@layout] attribute.]
67
+ ]
68
+
@@ -1,6 +1,3 @@
1
- section[
2
- @title[Defining Macros]
3
- @id[macro_def]
4
1
  txt[
5
2
  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.
6
3
 
@@ -60,5 +57,3 @@ Note that the first two keys can also be accessed via instance variables.
60
57
  td[A code[String] identifying the source of the macro (a file, a snippet, etc.).]
61
58
  ]
62
59
  ]
63
- ]
64
-
@@ -0,0 +1,78 @@
1
+ txt[
2
+ As shown in =>[#cmd_tasks_arch], the #>[compile] command calls specific tasks defined in the @generate:@ Rake namespace to generate output files in a particular format.
3
+
4
+ More specifically, when a @--format@ option is specified, the command looks for a task with the same name within the @generate:@ namespace. This makes adding new output formats to Glyph a fairly easy task, without the need to specify custom commands or similar.
5
+
6
+ The following sections explain how the @h3rald@ output format was created to integrate this book into the =>[http://www.h3rald.com|H3RALD.com] website.
7
+ ]
8
+ section[
9
+ @title[Output Configuration]
10
+ txt[
11
+ The first step required to add a new output format to Glyph is extending Glyph's configuration by adding the appropriate output hash, as follows:
12
+ ]
13
+ highlight[=yaml|
14
+ :output:
15
+ :h3rald:
16
+ :multifile: true
17
+ :extension: '.html'
18
+ :filter_target: 'html'
19
+ :base: '/glyph/book/'
20
+ :macro_dirs: ['html']
21
+ :layout_dirs: ['web']
22
+ :layouts:
23
+ :topic: bookpage
24
+ :index: bookindex
25
+ =]
26
+ txt[
27
+ In particular, the following keys are mandatory:
28
+ * multifile
29
+ * extension
30
+ * filter_target
31
+ * base
32
+ * macro_dirs
33
+ * layout_dirs
34
+ ]
35
+ ]
36
+ section[
37
+ @title[Creating a 'generate:h3rald' task]
38
+ txt[
39
+ The next (and final) step involves creating a custom @h3rald@ task within the @generate:@ namespace. This task can be placed in any @.rake@ file within the @lib/tasks@ directory:
40
+ ]
41
+ highlight[=ruby|
42
+ namespace :generate do
43
+ desc "Create output for h3rald.com integration"
44
+ task :h3rald => [:web] do
45
+ dir = Glyph::PROJECT/'output/h3rald'
46
+ (dir/"glyph/book").mkpath
47
+ # Copy files in subdir
48
+ (dir).find do \|i\|
49
+ if i.file? then
50
+ next if
51
+ i.to_s.match(Regexp.escape(dir/'glyph')) \|\|
52
+ i.to_s.match(Regexp.escape(dir/'images')) \|\|
53
+ i.to_s.match(Regexp.escape(dir/'styles'))
54
+ dest = dir/"glyph/book/#{i.relative_path_from(Glyph::PROJECT/dir)}"
55
+ src = i.to_s
56
+ Pathname.new(dest).parent.mkpath
57
+ file_copy src, dest
58
+ end
59
+ end
60
+ # Remove files
61
+ dir.children.each do \|c\|
62
+ unless [dir/'glyph', dir/'images', dir/'styles'].include? c then
63
+ c.directory? ? c.rmtree : c.unlink
64
+ end
65
+ end
66
+ (dir/'images/glyph/glyph.eps').unlink
67
+ (dir/'images/glyph/glyph.svg').unlink
68
+ # Create project page
69
+ project = Glyph.filter %{layout:project[
70
+ @contents[#{file_load(Glyph::PROJECT/'text/introduction.glyph')}]
71
+ ]}
72
+ file_write dir/"glyph.textile", project
73
+ end
74
+ end
75
+ =]
76
+ p[In this case, this task does not actually renders files in a different format, it just moves the files generated by the @generate:web@ task in different subdirectories.]
77
+ p[Additionally, it also generates the =>[http://www.h3rald.com/glyph/|Glyph project page] from the book's introduction (note the usage of a raw custom layout macro).]
78
+ ]
@@ -1,5 +1,3 @@
1
- section[
2
- @title[Parameters and Attributes]
3
1
  txt[
4
2
  Perhaps the most common things to do in a macro definition is accessing parameters and attributes. When doing so, it is important to consider whether we want to retrieve the _raw value_ of and attribute or parameter or its _expanded value_. The difference between the two will become clearer in the following sections and also in the =>[#interpreting] section.
5
3
  ]
@@ -67,4 +65,3 @@ To access raw values, use the following methods:
67
65
  * @raw_attribute@ (or @raw_attr@): Returns the attribute value of the attribute specified by name.
68
66
  ]
69
67
  ]
70
- ]
@@ -1,5 +1,3 @@
1
- section[
2
- @title[Using Placeholders]
3
1
  txt[
4
2
  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.
5
3
 
@@ -30,5 +28,3 @@ If there's already a bookmark stored in the current document, then it is possibl
30
28
 
31
29
  Within the @placeholder@ block, the @document@ parameter is, by all means, the fully analyzed document.
32
30
  ]
33
- ]
34
-
@@ -0,0 +1,46 @@
1
+ txt[
2
+ Glyph relies on =>[http://rake.rubyforge.org/|Rake] to perform most of its core operations. Typically, Rake tasks are used do define the high level logic that is used by Glyph commands to, for example, compile a project or load configuration files.
3
+
4
+ Furthermore, Rake provides an easy mechanism to create dependencies among tasks: for example, to make sure that Glyph's configuration files are loaded before everything else happens.
5
+ ]
6
+ section[
7
+ @title[Creating a 'custom:generate' task]
8
+ @id[custom_generate_task]
9
+ txt[
10
+ A custom task has been defined for the Glyph project used to produce this document. This custom task is used to compile a few of the documents files into standalone files, deployed in Glyph's root folder:
11
+ * @book/text/introduction.glyph@ &rarr; @README.textile@
12
+ * @book/text/changelog.glyph@ &rarr; @CHANGELOG.textile@
13
+ * @book/text/license.glyph@ &rarr; @LICENSE.textile@
14
+ * @book/text/acknowledgement.glyph@ &rarr; @AUTHORS.textile@
15
+
16
+ First of all, create a @lib/tasks@ folder in your project directory. Then, create a @.rake@ file within it, e.g. @tasks.rake@.
17
+
18
+ Finally, here's the source of the task:
19
+ ]
20
+ highlight[=ruby|
21
+ namespace :custom do
22
+ task :generate, [:file] do \|t, args\|
23
+ generate = lambda do \|source, destination\|
24
+ Glyph.info "Generating #{destination}..."
25
+ Glyph.compile Glyph::PROJECT/"text/#{source}.glyph",
26
+ Glyph::PROJECT/"../#{destination}.textile"
27
+ end
28
+ files = {
29
+ :AUTHORS => :acknowledgements,
30
+ :CHANGELOG => :changelog,
31
+ :LICENSE => :license,
32
+ :README => :introduction
33
+ }
34
+ arg = args[:file].upcase.to_sym
35
+ raise RuntimeError, "Unknown file '#{arg}.glyph'"
36
+ unless files.keys.include? arg
37
+ generate.call files[arg], arg
38
+ Glyph.info "Done."
39
+ end
40
+ end
41
+ =]
42
+ txt[
43
+ That's it. Note that this task is pretty useless without a command that calls it, and it won't even show up if you run @rake -T@ within your project directory. fmi[creating custom commands|#custom_command].
44
+ ]
45
+ ]
46
+
@@ -1,16 +1,15 @@
1
- section[
2
- @title[Using Validators]
3
1
  p[If you need to make sure that a macro is used properly, consider using =>[&[yardoc]/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.]
4
2
  p[If you want to create your own validators, you can call the generic code[validate] method which takes the message to display in case of error, a Hash of options and a block containing the validation to perform.]
5
3
  box[Validating macro placement|
6
4
  txt[
7
- 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.
5
+ You can, of course, create your own validators to check whether a macro is used directly 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.
8
6
 
9
- Suppose, for example, that the %>[box] is only allowed within a @section@ macro. This means that, for example:
7
+ Suppose, for example, that the %>[box] is only allowed directly under a @section@ macro. This means that, for example:
10
8
  * the macro cannot be used within @chapter@ or @appendix@ macros.
11
9
  * the macro cannot be used in snippets
12
10
 
13
- Even if you consider all the possibilities within the scope of the default macros provided with Glyph, this would also make the @box@ macro unusable within custom macros.
11
+ Even if you consider all the possibilities within the scope of the default macros provided with Glyph, this could still make the @box@ macro unusable within custom macros.
12
+
13
+ For the specific cases where a macro does not make sense unless is within another (e.g. the %>[eq]), a @within@ validator is used. Note though, that this validator only checks that the macro is used within another, but it is not necessarily its child.
14
14
  ]
15
15
  ]
16
- ]
@@ -1,6 +1,3 @@
1
- section[
2
- @title[Project Configuration]
3
- @id[cfg]
4
1
 
5
2
  textile[
6
3
  Glyph stores configuration settings in the following YAML files:
@@ -18,7 +15,7 @@ Instead of editing your configuration settings directly, you can use the #>[conf
18
15
 
19
16
  @glyph config@ _setting_ _\[value\]_
20
17
 
21
- If no _value_ is specified, glyph prints the value of the configuration setting, so typing @glyph config document.author@ right after creating a project (assuming you didn't set this in the Global Configuration) will print nothing, because this setting is blank by default.
18
+ If no _value_ is specified, Glyph prints the value of the configuration setting, so typing @glyph config document.author@ right after creating a project (assuming you didn't set this in the Global Configuration) will print nothing, because this setting is blank by default.
22
19
 
23
20
  To change the value of a configuration setting, specify a value right after the setting, like this:
24
21
 
@@ -46,4 +43,3 @@ There are plenty of configuration settings that can be modified, but most of the
46
43
 
47
44
  For a complete reference, see =>[#cfg_ref]. For everyday use, you may just want to change the settings defined in the =>[#cfg_document] namespace.
48
45
  ] --[End textile]
49
- ]
@@ -1,7 +1,4 @@
1
- section[
2
- @title[Creating your first Glyph Project]
3
-
4
- textile[
1
+ textile[
5
2
  To install Glyph, simply run @gem install glyph@, like with any other Ruby gem. Then, create a new directory and initialize a new Glyph project, like so:
6
3
 
7
4
  @mkdir@ _==test_document==_
@@ -37,5 +34,4 @@ Additionally, the following files are also created at top level:
37
34
  * @config.yml@ -- containing your =>[#cfg|Project Configuration].
38
35
  * @document.glyph@ -- containing the =>[#struct|structure] of your document.
39
36
  * @snippets.yml@ -- containing your text =>[#incl|snippets].
40
- ]
41
37
  ]
@@ -1,6 +1,3 @@
1
- section[
2
- @title[Document Structure]
3
- @id[struct]
4
1
 
5
2
  p[Every Glyph project contains a code[document.glyph] file that is typically used to define the document structure. The default code[document.glyph] generated automatically when creating a new project is the following:]
6
3
 
@@ -52,4 +49,3 @@ More specifically, in this @document.glyph@ file:
52
49
  * Then, the code[@frontmatter], code[@bodymatter], and code[@backmatter] attributes are used to 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.
53
50
  * @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 through code[@title] attributes.
54
51
  ]
55
- ]
@@ -1,63 +1,45 @@
1
- &:[prince|=>[http://www.princexml.com/|Prince]]
2
- Glyph is a _Rapid Document Authoring Framework_.
3
-
4
- With Glyph, you can manage your documents tidily in _projects_ and generate deliverables in different formats such as HTML or PDF (through &[prince]).
5
-
6
- section[
7
- @title[Main Features]
8
-
9
- Glyph comes with its very own macro system to perform a wide variety of advanced tasks:
10
- * Generate block-level HTML tags not commonly managed by lightweight markups, like @head@, @body@, @div@ and @table@.
11
- * Create and validate internal and external links.
12
- * Include and validate images and figures.
13
- * Automatically determine header levels based on the document structure.
14
- * Automatically generate a Table of Contents based on the document structure.
15
- * Store common snippets of text in a single YAML file and use them anywhere in your document, as many times as you need.
16
- * Store configuration settings in a YAML file and use them anywhere in your document, as many times as you need.
17
- * Evaluate Ruby code within your document.
18
- * Include content only if certain conditions are satisfied.
19
- * Define macros, snippets and configuration settings directly within your document.
20
- * Highlight source code.
21
- * Call macros from other macros (including snippets), avoiding mutual calls.
22
- * Include text files within other text files.
23
- * Include the value of any configuration setting (like author, title) in the document.
24
- * Filter input explicitly or implicitly (based on file extensions).
25
- * Manage draft comments and todo items.
26
- * Provide a simple, less-verbose syntax to write XML code.
27
-
28
- ]
29
-
30
- section[
31
- @title[Installation]
32
-
33
- @gem install glyph@ -- simple, as always.
34
-
35
- ]
36
-
37
- section[
38
- @title[Essential Glyph commands]
39
-
1
+ .[
2
+ &:[prince|=>[http://www.princexml.com/|Prince]]
3
+ &:[wkhtml|=>[http://code.google.com/p/wkhtmltopdf/|wkhtmltopdf]]
4
+ macro:[=?txt|
5
+ if Glyph.lite? then
6
+ interpret "section[#{raw_value}]"
7
+ else
8
+ interpret "txt[#{raw_value}]"
9
+ end
10
+ =]
11
+ macro:[=?sep|
12
+ if Glyph['document.output'] == "h3rald" then
13
+ %{<br style="clear:both" />}
14
+ end
15
+ =]
16
+ ]?txt[Glyph is a _Rapid Document Authoring Framework_.
17
+
18
+ With Glyph, creating and maintaining any kind of document becomes as easy as... _programming_. Glyph enables you to minimize text duplication, focus on content rather than presentation, manage references seamlessly and automate tedious tasks through a simple but effective macro language, specifically geared towards customization and extensibility.
19
+
20
+ ?sep[]
21
+
22
+ section[
23
+ @title[Main Features]
24
+
25
+ section[
26
+ @title[Command Line Interface]
40
27
  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:
41
28
 
42
29
  * @glyph init@ -- to initialize a new Glyph project in the current (empty) directory.
43
30
  * @glyph add introduction.textile@ -- to create a new file called _introduction.textile_.
44
31
  * @glyph compile@ -- to compile the current document into a single HTML file.
45
32
  * @glyph compile --auto@ -- to keep recompiling the current document every time a file is changed.
46
- * @glyph compile -f pdf@ -- to compile the current document into HTML and then transform it into PDF using &[prince].
33
+ * @glyph compile -f pdf@ -- to compile the current document into HTML and then transform it into PDF.
47
34
  * @glyph compile readme.glyph@ -- to compile a _readme.glyph_ located in the current directory into a single HTML file.
48
35
  * @glyph outline -l 2@ -- Display the document outline, up to second-level headers.
36
+ * @glyph stats@ -- Display project statistics.
37
+ ]
49
38
 
50
- ]
51
-
52
- section[
53
- @title[Glyph macros in a nutshell]
54
- @id[macros_nutshell]
55
-
56
- Format your documents using Textile or Markdown, and use Glyph Macros to do everything else:
57
-
58
- **Glyph Source:**
59
-
60
- codeblock[=
39
+ section[
40
+ @title[Minimalist Syntax]
41
+ Glyph syntax rules can be explained using Glyph itself:
42
+ codeblock[=
61
43
  section[
62
44
  @title[Something about Glyph]
63
45
  txt[
@@ -65,24 +47,22 @@ You can use Glyph macros in conjunction
65
47
  with _Textile_ or _Markdown_ to
66
48
  produce HTML files effortlessly.
67
49
  ]
68
- p[
69
- Alternatively, you can just use em[Glyph itself]
70
- to generate HTML tags.
71
- ]
50
+ p[Alternatively, you can just use em[Glyph itself] to generate HTML tags.]
72
51
  section[
73
52
  @title[What about PDFs?]
74
53
  @id[pdf]
54
+ p[
75
55
  Once you have a single, well-formatted HTML
76
56
  file, converting it to PDF is
77
- extremely easy with a 3rd-party
78
- renderer like =>[http://www.princexml.com\|Prince].
57
+ extremely easy with a free 3rd-party
58
+ renderer like =>[http://www.princexml.com\|Prince]
59
+ or =>[http://code.google.com/p/wkhtmltopdf/\|wkhtmltopdf].
60
+ ]
79
61
  ]
80
62
  ]
81
- =]
82
-
83
- **HTML Output:**
84
-
85
- codeblock[=
63
+ =]
64
+ The Glyph code above corresponds to the following HTML code:
65
+ codeblock[=
86
66
  <div class="section">
87
67
  <h2 id="h_10">Something about Glyph</h2>
88
68
  <p>
@@ -90,32 +70,77 @@ codeblock[=
90
70
  <em>Textile</em> or <em>Markdown</em> to
91
71
  produce HTML files effortlessly.
92
72
  </p>
73
+ <p>
74
+ Alternatively, you can just use <em>Glyph itself</em>
75
+ to generate HTML tags.
76
+ </p>
93
77
  <div class="section">
94
78
  <h3 id="pdf">What about PDFs?</h3>
95
79
  <p>
96
80
  Once you have a single, well-formatted HTML
97
81
  file, converting it to PDF is
98
- extremely easy with a 3rd-party renderer
99
- like <a href="http://www.princexml.com">Prince</a>.
100
- </p>
101
- <p>
102
- Alternatively, you can just use <em>Glyph itself</em>
103
- to generate HTML tags.
82
+ extremely easy with a free 3rd-party renderer
83
+ like <a href="http://www.princexml.com">Prince</a>
84
+ or <a href="http://code.google.com/p/wkhtmltopdf/\">wkhtmltopdf</a>.
104
85
  </p>
105
86
  </div>
106
87
  </div>
107
- =]
88
+ =]
89
+ ]
90
+
91
+ section[
92
+ @title[Content Reuse]
93
+ Finding yourself repeating the same sentence over an over? Glyph allows you to create snippets. Within snippets. Within other snippets (and so on, for a long long time...) as long as you don't define a snippet by defining itself, which would be kinda nasty (and Glyph would complain!):
94
+ codeblock[=
95
+ snippet:[entities\|snippets and macros]
96
+ snippet:[custom_definitions\|
97
+ p[Glyph allows you to define your own &[entities].]
108
98
  ]
109
-
110
- section[
111
- @title[Resources]
112
-
99
+ &[custom_definitions]
100
+ =]
101
+ ...which results in:
102
+ codeblock[=
103
+ <p>Glyph allows you to define your own snippets and macros.</p>
104
+ =]
105
+ If yourself dreaming about _parametric_ snippets, just create your own macros (see the =>[http://github.com/h3rald/glyph/blob/master/book/text/changelog.glyph|source] of Glyph's changelog, just to have an idea).
106
+ ]
107
+ section[
108
+ @title[Automation of Common Tasks]
109
+ If you're writing a book, you shouldn't have to worry about pagination, headers, footers, table of contents, section numbering or similar. Glyph understands you, and will take care of everything for you (with a little help from CSS3, sometimes).
110
+ ]
111
+ section[
112
+ @title[Reference Validation]
113
+ Feel free to add plenty of links, snippets, bookmarks, ... if Glyph doesn't find something, it will definitely complain. Broken references are a thing on the past, and you don't need to worry about it.
114
+ ]
115
+ section[
116
+ @title[Extreme Extensibility]
117
+ * You miss a code[=!!!=] macro to format really, _really_ important things? Create it. In under 3 seconds, in Ruby or Glyph itself. And yes, you can use special characters, too.
118
+ * You want your own, very special special @glyph create --everything@ command to create all _you_ need in a Glyph project? You can do it. Using your own Rake tasks, too.
119
+ * You want Glyph to output ODF files? You can do it, and you'll be able to run @glyph generate -f odf@. This would probably require a little more time, but it's trivial, from a technical point of view.
120
+ ]
121
+ section[
122
+ @title[Convention over Configuration]
123
+ Put your text files in @/text@, your images in @/images@, add custom macros in a @macro@ folder within your @/lib@ folder... you get the picture: Glyph has its special places.
124
+
125
+ Nonetheless, you also have 1 (_one_) configuration file to customize to your heart's content (with smart defaults).
126
+ ]
127
+ section[
128
+ @title[Free and Open Source]
129
+ Glyph is 100% Open Source Software, developed using the Ruby Programming Language and licensed under the very permissive terms of the =>[http://www.opensource.org/licenses/mit-license.php|MIT License].
130
+
131
+ If you have Ruby installed, just run @gem install glyph@. That's all it takes.
132
+ ]
133
+ ]
134
+ section[
135
+ @title[Resources]
113
136
  * Home Page: =>[http://www.h3rald.com/glyph/]
114
137
  * Repository: =>[http://www.github.com/h3rald/glyph/]
115
138
  * Bug Tracking: =>[http://www.github.com/h3rald/glyph/issues]
116
139
  * Development Wiki =>[http://wiki.github.com/h3rald/glyph]
117
140
  * RubyGem Download =>[http://www.rubygems.org/gems/glyph]
118
- * Book (PDF): =>[http://github.com/h3rald/glyph/raw/\.%[Glyph::VERSION.strip]/book/output/pdf/glyph.pdf]
119
- * Reference Documentation: =>[http://yardoc.org/docs/h3rald-glyph/]
141
+ * Book (PDF): =>[http://github.com/downloads/h3rald/glyph/glyph.pdf]
142
+ * Book (Web): =>[http://www.h3rald.com/glyph/book/]
143
+ * Reference Documentation: =>[http://rubydoc.info/gems/glyph/]
120
144
  * User Group: =>[http://groups.google.com/group/glyph-framework]
145
+ ]
121
146
  ]