glyph 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/Rakefile +19 -40
  2. data/benchmark.rb +1 -2
  3. data/book/config.yml +8 -8
  4. data/book/document.glyph +18 -19
  5. data/book/images/glyph/commands_tasks.png +0 -0
  6. data/book/lib/layouts/bookindex.glyph +113 -111
  7. data/book/lib/layouts/bookpage.glyph +112 -108
  8. data/book/lib/macros/reference.rb +2 -2
  9. data/book/lib/tasks/tasks.rake +1 -1
  10. data/book/text/acknowledgements.glyph +1 -0
  11. data/book/text/changelog.glyph +140 -112
  12. data/book/text/compiling/compiling.glyph +36 -24
  13. data/book/text/compiling/lite_mode.glyph +11 -11
  14. data/book/text/compiling/programmatic_usage.glyph +57 -57
  15. data/book/text/config/document.glyph +7 -1
  16. data/book/text/config/options.glyph +5 -3
  17. data/book/text/config/output.glyph +41 -8
  18. data/book/text/extending/bookmarks_headers.glyph +13 -11
  19. data/book/text/extending/command.glyph +1 -1
  20. data/book/text/extending/commands_tasks.glyph +2 -2
  21. data/book/text/extending/internals.glyph +29 -29
  22. data/book/text/extending/interpreting.glyph +48 -9
  23. data/book/text/extending/macro_def.glyph +80 -32
  24. data/book/text/extending/output_format.glyph +2 -2
  25. data/book/text/extending/placeholders.glyph +27 -15
  26. data/book/text/extending/validators.glyph +1 -1
  27. data/book/text/getting_started/configuration.glyph +1 -1
  28. data/book/text/getting_started/create_project.glyph +4 -5
  29. data/book/text/getting_started/structure.glyph +2 -2
  30. data/book/text/macros/macros_core.glyph +341 -199
  31. data/book/text/macros/macros_filters.glyph +1 -1
  32. data/book/text/macros/macros_inline.glyph +3 -3
  33. data/book/text/macros/macros_structure.glyph +1 -1
  34. data/book/text/ref_commands.glyph +98 -93
  35. data/book/text/snippets.glyph +18 -0
  36. data/book/text/stats/bookmarks.glyph +16 -16
  37. data/book/text/stats/links.glyph +23 -23
  38. data/book/text/stats/macros.glyph +14 -14
  39. data/book/text/stats/snippets.glyph +26 -26
  40. data/book/text/stats/stats.glyph +14 -15
  41. data/book/text/text_editing/attribute_intro.glyph +8 -8
  42. data/book/text/text_editing/code.glyph +16 -16
  43. data/book/text/text_editing/conditionals.glyph +12 -13
  44. data/book/text/text_editing/esc_quot.glyph +3 -3
  45. data/book/text/text_editing/evaluation.glyph +57 -3
  46. data/book/text/text_editing/inclusions.glyph +34 -25
  47. data/book/text/text_editing/macro_composition.glyph +28 -0
  48. data/book/text/text_editing/macro_intro.glyph +4 -4
  49. data/book/text/text_editing/section_aliases.glyph +23 -23
  50. data/book/text/text_editing/sections.glyph +22 -22
  51. data/book/text/text_editing/stylesheets.glyph +33 -33
  52. data/book/text/text_editing/topics.glyph +6 -6
  53. data/book/text/text_editing/xml_fallback.glyph +1 -1
  54. data/book/text/troubleshooting/errors_command.glyph +4 -4
  55. data/book/text/troubleshooting/errors_generic.glyph +16 -10
  56. data/book/text/troubleshooting/errors_macro.glyph +18 -21
  57. data/book/text/troubleshooting/errors_parser.glyph +7 -7
  58. data/config.yml +51 -29
  59. data/document.glyph +18 -18
  60. data/glyph.gemspec +39 -287
  61. data/layouts/web5/topic.glyph +1 -1
  62. data/lib/glyph.rb +42 -10
  63. data/lib/glyph/analyzer.rb +5 -2
  64. data/lib/glyph/bookmark.rb +3 -1
  65. data/lib/glyph/commands.rb +11 -9
  66. data/lib/glyph/commands/add.rb +3 -1
  67. data/lib/glyph/commands/compile.rb +10 -7
  68. data/lib/glyph/commands/config.rb +7 -5
  69. data/lib/glyph/commands/init.rb +2 -0
  70. data/lib/glyph/commands/outline.rb +2 -0
  71. data/lib/glyph/commands/stats.rb +3 -0
  72. data/lib/glyph/commands/todo.rb +2 -0
  73. data/lib/glyph/config.rb +2 -0
  74. data/lib/glyph/document.rb +34 -9
  75. data/lib/glyph/interpreter.rb +2 -0
  76. data/lib/glyph/macro.rb +97 -25
  77. data/lib/glyph/macro_validators.rb +9 -6
  78. data/lib/glyph/node.rb +3 -1
  79. data/lib/glyph/parser.rb +68 -33
  80. data/lib/glyph/reporter.rb +3 -1
  81. data/lib/glyph/syntax_node.rb +23 -28
  82. data/lib/glyph/system_extensions.rb +21 -0
  83. data/lib/glyph/utils.rb +24 -4
  84. data/macros/block.rb +111 -0
  85. data/macros/core.rb +163 -33
  86. data/macros/filters.rb +3 -2
  87. data/macros/inline.rb +97 -0
  88. data/macros/reps/html.rb +180 -0
  89. data/macros/reps/html5.rb +100 -0
  90. data/macros/reps/web.rb +4 -0
  91. data/macros/reps/web5.rb +4 -0
  92. data/macros/structure.rb +229 -0
  93. data/macros/xml.rb +29 -24
  94. data/spec/config.yml +7 -0
  95. data/spec/files/article.glyph +2 -2
  96. data/spec/files/web_doc.glyph +9 -5
  97. data/spec/lib/commands_spec.rb +13 -9
  98. data/spec/lib/config_spec.rb +2 -2
  99. data/spec/lib/document_spec.rb +10 -0
  100. data/spec/lib/glyph_spec.rb +30 -8
  101. data/spec/lib/macro_spec.rb +39 -4
  102. data/spec/lib/macro_validators_spec.rb +3 -4
  103. data/spec/lib/parser_spec.rb +7 -0
  104. data/spec/lib/reporter_spec.rb +1 -0
  105. data/spec/lib/syntax_node_spec.rb +40 -6
  106. data/spec/macros/core_spec.rb +154 -21
  107. data/spec/macros/filters_spec.rb +1 -1
  108. data/spec/macros/html5_spec.rb +4 -5
  109. data/spec/macros/macros_spec.rb +6 -7
  110. data/spec/macros/web5_spec.rb +3 -3
  111. data/spec/macros/web_spec.rb +10 -7
  112. data/spec/macros/xml_spec.rb +11 -2
  113. data/spec/spec_helper.rb +11 -5
  114. data/spec/tasks/generate_spec.rb +40 -5
  115. data/spec/tasks/load_spec.rb +1 -13
  116. data/styles/coderay.css +147 -38
  117. data/styles/default.css +19 -22
  118. data/styles/pagination.css +30 -30
  119. data/tasks/generate.rake +54 -18
  120. data/tasks/load.rake +9 -24
  121. data/tasks/project.rake +0 -2
  122. metadata +208 -207
  123. data/.gitignore +0 -7
  124. data/VERSION +0 -1
  125. data/book/snippets.yml +0 -18
  126. data/lib/glyph/macro_helpers.rb +0 -282
  127. data/macros/html/block.rb +0 -124
  128. data/macros/html/inline.rb +0 -42
  129. data/macros/html/structure.rb +0 -191
  130. data/macros/html5/block.rb +0 -69
  131. data/macros/html5/inline.rb +0 -24
  132. data/macros/html5/structure.rb +0 -140
@@ -17,7 +17,7 @@ The first step required to add a new output format to Glyph is extending Glyph's
17
17
  :extension: '.html'
18
18
  :filter_target: 'html'
19
19
  :base: '/glyph/book/'
20
- :macro_dirs: ['html', 'html5']
20
+ :macro_rep: html5
21
21
  :layout_dirs: ['web5']
22
22
  :layouts:
23
23
  :topic: bookpage
@@ -63,7 +63,7 @@ namespace :generate do
63
63
  (dir/'glyph/book/images/glyph/glyph.eps').unlink
64
64
  (dir/'glyph/book/images/glyph/glyph.svg').unlink
65
65
  # Create project page
66
- project = Glyph.filter %{layout:project[
66
+ project = Glyph.filter %{layout/project[
67
67
  @contents[#{file_load(Glyph::PROJECT/'text/introduction.glyph')}]
68
68
  ]}
69
69
  file_write dir/"glyph.textile", project
@@ -5,22 +5,34 @@ Here's the source code of the %>[link]:
5
5
  ]
6
6
  highlight[=ruby|
7
7
  macro :link do
8
- href, title = @params
9
- if href.match /^#/ then
10
- anc = href.gsub(/^#/, '').to_sym
11
- bmk = bookmark? anc
12
- if bmk then
13
- title \|\|= bmk[:title]
14
- else
15
- plac = placeholder do \|document\|
16
- macro_error "Bookmark '#{anc}' does not exist" unless document.bookmarks[anc]
17
- document.bookmarks[anc][:title]
18
- end
19
- title \|\|= plac
20
- end
8
+ min_parameters 1
9
+ max_parameters 2
10
+ target = param 0
11
+ title = param 1
12
+ if target.match /^#/ then
13
+ @node[:document].links << target
14
+ anchor = target.gsub /^#/, ''
15
+ bmk = bookmark? anchor
16
+ if !bmk then
17
+ placeholder do \|document\|
18
+ bmk = document.bookmark?(anchor)
19
+ macro_error "Bookmark '#{anchor}' does not exist" unless bmk
20
+ bmk_title = title
21
+ bmk_title = bmk.title if bmk_title.blank?
22
+ @data[:target] = bmk.link(@source_file)
23
+ @data[:title] = bmk_title
24
+ render
25
+ end
26
+ else
27
+ bmk_title = title
28
+ bmk_title = bmk.title if bmk_title.blank?
29
+ @data[:target] = bmk.link(@source_file)
30
+ @data[:title] = bmk_title
31
+ render
32
+ end
33
+ else
34
+ # Code omitted...
21
35
  end
22
- title \|\|= href
23
- %{<a href="#{href}">#{title}</a>}
24
36
  end
25
37
  =]
26
38
  txt[
@@ -1,4 +1,4 @@
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.]
1
+ p[If you need to make sure that a macro is used properly, consider using =>[&[rubydoc]/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.]
2
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.]
3
3
  box[Validating macro placement|
4
4
  txt[
@@ -2,7 +2,7 @@
2
2
  textile[
3
3
  Glyph stores configuration settings in the following YAML files:
4
4
  # Your _Project Configuration_ is stored in the @config.yml@ file, included in each Glyph Project.
5
- # Your _Global Configuration_ is stored in a @.glyphrc@ file in your code[$HOME] (or ==\.code[%HOMEPATH%]== on Windows) directory (not created by default).
5
+ # Your _Global Configuration_ is stored in a @.glyphrc@ file in your code[$HOME] (or ==\/code[%HOMEPATH%]== on Windows) directory (not created by default).
6
6
  # The _System Configuration_ is stored in the source directory of Glyph itself.
7
7
 
8
8
  When compiling, Glyph loads all these configuration files and merges them according to the following rules:
@@ -16,10 +16,10 @@ Glyph requires the following gems:
16
16
  * rake
17
17
 
18
18
  Additionally, some Glyph macros may require additional gems, such as:
19
- * RedCloth (\.%>[textile])
20
- * BlueCloth _or_ RDiscount _or_ Maruku _or_ Kramdown (\.%>[markdown])
21
- * Haml (if you want to load .sass files with the %>[style])
22
- * CodeRay _or_ UltraViolet (\.%>[highlight])
19
+ * RedCloth (\/%>[textile])
20
+ * BlueCloth _or_ RDiscount _or_ Maruku _or_ Kramdown (\/%>[markdown])
21
+ * Sass (if you want to load .sass files with the %>[style])
22
+ * CodeRay _or_ UltraViolet (\/%>[highlight])
23
23
  * directory_watcher (to use auto-regeneration with the #>[compile])
24
24
  ]
25
25
 
@@ -33,5 +33,4 @@ 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 the =>[#struct|structure] of your document.
36
- * @snippets.yml@ -- containing your text =>[#incl|snippets].
37
36
  ]
@@ -36,7 +36,7 @@ book[
36
36
  textile[
37
37
  Even without knowing anything about &[glang], you can easily figure out that this file defines a document with a Table of Contents, a Preface some Chapters and an Appendix.
38
38
 
39
- As you can see, Glyph wraps portions of text within square brackets preceded by an identifier. These identifiers are used for em[\.=>[#macro_intro|macros]] and em[\.=>[#attribute_intro|attributes]]. The only syntactic difference between macros and attributes is that attributes are preceded by a code[@].
39
+ As you can see, Glyph wraps portions of text within square brackets preceded by an identifier. These identifiers are used for em[\/=>[#macro_intro|macros]] and em[\/=>[#attribute_intro|attributes]]. The only syntactic difference between macros and attributes is that attributes are preceded by a code[@].
40
40
 
41
41
  For now, think about a macro as something that performs a certain action and -- generally -- produces some text output or manipulation of the text inside it. In this way, it becomes easy to understand that the @chapter@ macro creates a chapter and the %>[include] includes an external file, for example.
42
42
  Attributes "belong" to the macro they're in, so in this case the %>[book] has the following attributes:
@@ -47,5 +47,5 @@ Attributes "belong" to the macro they're in, so in this case the %>[book] has th
47
47
  More specifically, in this @document.glyph@ file:
48
48
  * The %>[book] wraps every other macro and is used to create the document header and default title page.
49
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.
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.
50
+ * @preface@, @chapter@, @appendix@ are just a way to wrap content in @<div>@ tags, from an HTML point of view (or @<section>@ tags, in HTML5), but they are also necessary to nest the content of your document and generate the Table of Contents automatically, together through code[@title] attributes.
51
51
  ]
@@ -1,214 +1,356 @@
1
1
 
2
- ref_macro[
3
- @n[alias]
4
- @desc[Creates a macro alias.]
5
- @params[
6
- -p[0|The name of the alias.]
7
- -p[1|The name of an existing macro.]
8
- ]
9
- @example[=alias[s\|section]=]
10
- ]
11
-
12
- ref_macro[
13
- @n[and]
14
- @desc[Conditional code[and] operator, to be used with the %>[condition].]
15
- @params[&[bin_params]]
16
- @example[=?[and[true\|false]\|This is never displayed.]=]
17
- ]
18
-
19
- ref_macro[
20
- @n[comment]
21
- @desc[
2
+ ref_macro[
3
+ @n[add]
4
+ @desc[Adds two or more integers together.]
5
+ @params[Two or more integer values.]
6
+ @example[=add[2\|5\|7]=]
7
+ ]
8
+
9
+ ref_macro[
10
+ @n[alias]
11
+ @desc[Creates a macro alias.]
12
+ @params[
13
+ -p[0|The name of the alias.]
14
+ -p[1|The name of an existing macro.]
15
+ ]
16
+ @example[=alias[s\|section]=]
17
+ ]
18
+
19
+ ref_macro[
20
+ @n[and]
21
+ @desc[Conditional code[and] operator, to be used with the %>[condition].]
22
+ @params[&[bin_params]]
23
+ @example[=?[and[true\|false]\|This is never displayed.]=]
24
+ ]
25
+
26
+ ref_macro[
27
+ @n[attribute]
28
+ @desc[Returns the value of the specified attribute. ##[see_let|For a more complete example, see the %>[let]].]
29
+ @aliases[@]
30
+ @example[=@[title]=]
31
+ @params[-p[0|The name of the attribute to retrieve.]]
32
+ ]
33
+
34
+ ref_macro[
35
+ @n[attribute:]
36
+ @desc[Sets the value of the specified attribute. <=[see_let].]
37
+ @aliases[@:]
38
+ @example[=@:[title\|Test Title]=]
39
+ @params[
40
+ -p[0|The name of the attribute to set.]
41
+ -p[1|The value of the attribute.]
42
+ ]
43
+ ]
44
+
45
+ ref_macro[
46
+ @n[comment]
47
+ @desc[
22
48
  Evaluates to nothing. Used to add comments in a Glyph document that will not be displayed in output files.
23
- ]
24
- @aliases[--]
25
- @params[-p[0|The contents to comment out]]
26
- @example[=--[\.=>[#link\|This link will not be evaluated]]=]
27
- @remarks[Macros are not expanded within comments.]
28
- ]
29
-
30
- ref_macro[
31
- @n[condition]
32
- @desc[
49
+ ]
50
+ @aliases[--]
51
+ @params[-p[0|The contents to comment out]]
52
+ @example[=--[\/=>[#link\|This link will not be evaluated]]=]
53
+ @remarks[Macros are not expanded within comments.]
54
+ ]
55
+
56
+ ref_macro[
57
+ @n[condition]
58
+ @desc[
33
59
  Tests a conditional expression. For more information, see =>[#cond_macros].
34
- ]
35
- @aliases[?]
36
- @params[
37
- -p[0|The condition to test]
38
- -p[1|The contents to expand if the condition is satisfied.]
39
- ]
40
- @remarks[
60
+ ]
61
+ @aliases[?]
62
+ @params[
63
+ -p[0|The condition to test]
64
+ -p[1|The contents to expand if the condition is satisfied.]
65
+ ]
66
+ @remarks[
41
67
  For examples see any of the following:
42
68
  * %>[and]
43
69
  * %>[or]
44
70
  * %>[not]
45
71
  * %>[match]
46
72
  * %>[eq]
47
- ]
48
- ]
49
-
50
- ref_macro[
51
- @n[config]
52
- @desc[Returns the value of a configuration setting.]
53
- @aliases[$]
54
- @example[=$[document.author]=]
55
- @params[
56
- -p[0|The full name of a configuration setting.]
57
- ]
58
- ]
59
-
60
- ref_macro[
61
- @n[config:]
62
- @desc[Sets the value of a configuration setting.]
63
- @aliases[$:]
64
- @example[=$:[document.draft\|true]=]
65
- @remarks[&[unsafe]]
66
- @params[
67
- -p[0|The full name of a configuration setting.]
68
- -p[1|The new value of the configuration setting]
69
- ]
70
- ]
71
-
72
- ref_macro[
73
- @n[eq]
74
- @desc[Conditional equality operator, to be used with the %>[condition].]
75
- @example[=?[eq[$[document.draft]\|true]\|This is displayed only in draft documents.]=]
76
- @params[&[bin_params]]
77
- ]
78
-
79
- ref_macro[
80
- @n[escape]
81
- @desc[Evaluates to its value. Commonly used with the escaping delimiters code[\[\=] and code[\=\]].]
82
- @aliases[.]
83
- @example[=.\[=Macros are escaped here =>[#test].=\]=]
84
- @params[-p[0|The contents to escape.]]
85
- ]
86
-
87
- ref_macro[
88
- @n[include]
89
- @desc[
73
+ ]
74
+ ]
75
+
76
+ ref_macro[
77
+ @n[config]
78
+ @desc[Returns the value of a configuration setting.]
79
+ @aliases[$]
80
+ @example[=$[document.author]=]
81
+ @params[
82
+ -p[0|The full name of a configuration setting.]
83
+ ]
84
+ ]
85
+
86
+ ref_macro[
87
+ @n[config:]
88
+ @desc[Sets the value of a configuration setting.]
89
+ @aliases[$:]
90
+ @example[=$:[document.draft\|true]=]
91
+ @remarks[&[unsafe]]
92
+ @params[
93
+ -p[0|The full name of a configuration setting.]
94
+ -p[1|The new value of the configuration setting]
95
+ ]
96
+ ]
97
+
98
+ ref_macro[
99
+ @n[eq]
100
+ @desc[Conditional equality operator, to be used with the %>[condition].]
101
+ @example[=?[eq[$[document.draft]\|true]\|This is displayed only in draft documents.]=]
102
+ @params[&[bin_params]]
103
+ ]
104
+
105
+ ref_macro[
106
+ @n[escape]
107
+ @desc[Evaluates to its value. Commonly used with the escaping delimiters code[\[\=] and code[\=\]].]
108
+ @aliases[.]
109
+ @example[=.\[=Macros are escaped here =>[#test].=\]=]
110
+ @params[-p[0|The contents to escape.]]
111
+ ]
112
+
113
+ ref_macro[
114
+ @n[fragment]
115
+ @desc[Delimits a fragment of text that can be embedded using the %>[embed].]
116
+ @aliases[##]
117
+ @example[=##\[test_fragment\|This is an embeddable fragment\]=]
118
+ @params[
119
+ -p[0|The ID of the fragment.]
120
+ -p[1|The contents of the fragment.]
121
+ ]
122
+ ]
123
+
124
+ ref_macro[
125
+ @n[embed]
126
+ @desc[Embeds text previously-delimited using the %>[fragment].]
127
+ @aliases[&amp;=]
128
+ @example[=&amp;=\[test_fragment\]=]
129
+ @params[-p[0|The ID of the fragment.]]
130
+ ]
131
+
132
+ def:[comp_macro|
133
+ ref_macro[
134
+ @n[{{0}}]
135
+ @desc[Returns em[true] if the first parameter is {{0}} the second one.]
136
+ @example[={{1}}\[5\|2\]=]
137
+ @params[
138
+ -p[0|The first integer to compare.]
139
+ -p[1|The second integer to compare.]
140
+ ]
141
+ ]
142
+ ]
143
+
144
+ comp_macro[gt|greater than]
145
+
146
+ comp_macro[gte|greater than or equal to]
147
+
148
+ ref_macro[
149
+ @n[include]
150
+ @desc[
90
151
  Evaluates to the contents of a text file stored in the @text/@ directory referenced by its relative path. If &[filter_by_ext], filters the contents of the file using the =>[#f_macros|filter macro] corresponding to the file extension.
91
- ]
92
- @aliases[@]
93
- @example[=include[frontmatter/introduction]=]
94
- @params[-p[0|The file to include.]]
95
- @remarks[
96
- ul[
97
- li[&[unsafe]]
98
- li[@.glyph@ is assumed if no file extension is specified.]
99
- li[
100
- This macro can also be used to include @.rb@ ruby files within the @lib@ directory. File contents are evaluated in the context of the =>[&[yardoc]/Glyph|Glyph] module.
101
- ]
102
- ]
103
- ]
104
- ]
105
-
106
- ref_macro[
107
- @n[match]
108
- @desc[
109
- Checks a string against a regular expression.
110
- ]
111
- @params[
112
- -p[0|The string to check.]
113
- -p[1|The regular expression to match against the string.]
114
- -p[2|The contents to expand if the string matches.]
115
- ]
116
- @remarks[This macro must be used with the %>[condition].]
117
- @example[=?[match[Hello!\|/^hell/i]\|This is always displayed]=]
118
- ]
119
-
120
- ref_macro[
121
- @n[macro:]
122
- @desc[Defines a macro.]
123
- @remarks[
124
- ul[
125
- li[&[unsafe]]
126
- li[The new macro &[only_after_declaration].]
127
- ]
128
- ]
129
- @aliases[%:]
130
- @example[=%:[test\|"<em>test: #{value}</em>"]=]
131
- @params[
132
- -p[0|The name of the new macro.]
133
- -p[1|The macro definition (Ruby code).]
134
- ]
135
- ]
136
-
137
- ref_macro[
138
- @n[not]
139
- @desc[Conditional @not@ operator, to be used with the %>[condition].]
140
- @example[=?[not[false]\|This is always displayed.]=]
141
- @params[-p[0|The expression to negate]]
142
- ]
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
-
153
- ref_macro[
154
- @n[or]
155
- @desc[Conditional @or@ operator, to be used with the %>[condition].]
156
- @example[=?[or[true\|false]\|This is always displayed.]=]
157
- @params[&[bin_params]]
158
- ]
159
-
160
- ref_macro[
161
- @n[rewrite:]
162
- @desc[Defines a new macro by rewriting (for more information, see =>[#rewriting])]
163
- @aliases[rw:]
164
- @params[
165
- -p[0|The name of the new macro.]
166
- -p[0|The macro definition (Glyph code).]
167
- ]
168
- @block_example[=
169
- rw:[release\|
152
+ ]
153
+ @aliases[@]
154
+ @example[=include[frontmatter/introduction]=]
155
+ @params[-p[0|The file to include.]]
156
+ @remarks[
157
+ ul[
158
+ li[&[unsafe]]
159
+ li[@.glyph@ is assumed if no file extension is specified.]
160
+ li[
161
+ This macro can also be used to include @.rb@ ruby files within the @lib@ directory. File contents are evaluated in the context of the =>[&[rubydoc]/Glyph|Glyph] module.
162
+ ]
163
+ ]
164
+ ]
165
+ ]
166
+
167
+ ref_macro[
168
+ @n[let]
169
+ @desc[Used to bind one or more attributes via the %>[attribute]. Actually, you can use %>[attribute] inside any other macro, but it looks tidier in this way.]
170
+ @block_example[=
171
+ let[
172
+ @:[a\|2]
173
+ @:[b\|3]
170
174
  section[
171
- @title[Release {{0}}]
172
- {{1}}
175
+ @title[Testing]
176
+ @[title]: @[a] * @[b] = multiply[@[a]\|@[b]] --[Outputs: Testing: 2 * 3 = 6]
173
177
  ]
174
178
  ]
175
- =]
176
- @remarks[
177
- ul[
178
- li[The new macro &[only_after_declaration].]
179
- li[&[unsafe]]
180
- ]
181
- ]
182
- ]
183
-
184
- ref_macro[
185
- @n[ruby]
186
- @desc[Evaluates its value as Ruby code within the context of the =>[&[yardoc]/Glyph|Glyph] module.]
187
- @aliases[%]
188
- @examples[=
179
+ =]
180
+ @params[-p[0|Any content.]]
181
+ ]
182
+
183
+ ref_macro[
184
+ @n[load]
185
+ @desc[Embeds the contents of a file.]
186
+ @params[
187
+ -p[0|The file to embed, relative to the Glyph project folder.]
188
+ ]
189
+ @example[=load[my_samples.rb]=]
190
+ ]
191
+
192
+ comp_macro[lt|less than]
193
+
194
+ comp_macro[lte|less than or equal to]
195
+
196
+ ref_macro[
197
+ @n[match]
198
+ @desc[
199
+ Checks a string against a regular expression.
200
+ ]
201
+ @params[
202
+ -p[0|The string to check.]
203
+ -p[1|The regular expression to match against the string.]
204
+ -p[2|The contents to expand if the string matches.]
205
+ ]
206
+ @remarks[This macro must be used with the %>[condition].]
207
+ @example[=?[match[Hello!\|/^hell/i]\|This is always displayed]=]
208
+ ]
209
+
210
+ ref_macro[
211
+ @n[macro:]
212
+ @desc[Defines a macro.]
213
+ @remarks[
214
+ ul[
215
+ li[&[unsafe]]
216
+ li[The new macro &[only_after_declaration].]
217
+ ]
218
+ ]
219
+ @aliases[%:]
220
+ @example[=%:[test\|"<em>test: #{value}</em>"]=]
221
+ @params[
222
+ -p[0|The name of the new macro.]
223
+ -p[1|The macro definition (Ruby code).]
224
+ ]
225
+ ]
226
+
227
+ ref_macro[
228
+ @n[multiply]
229
+ @desc[Multiplies two or more integers together.]
230
+ @params[Two or more integer values.]
231
+ @example[=add[3\|5\|9]=]
232
+ ]
233
+
234
+ ref_macro[
235
+ @n[not]
236
+ @desc[Conditional @not@ operator, to be used with the %>[condition].]
237
+ @example[=?[not[false]\|This is always displayed.]=]
238
+ @params[-p[0|The expression to negate]]
239
+ ]
240
+
241
+ ref_macro[
242
+ @n[output?]
243
+ @desc[Evaluates to true if Glyph is generating output in the specified format(s).]
244
+ @example[=?[output?[web\|web5]\|This text is printed only when generating web or web5 output.]=]
245
+ @params[
246
+ -p[0, ...|a valid output target.]
247
+ ]
248
+ ]
249
+
250
+ ref_macro[
251
+ @n[or]
252
+ @desc[Conditional @or@ operator, to be used with the %>[condition].]
253
+ @example[=?[or[true\|false]\|This is always displayed.]=]
254
+ @params[&[bin_params]]
255
+ ]
256
+
257
+ ref_macro[
258
+ @n[define:]
259
+ @desc[Defines a new macro in Glyph code (for more information, see =>[#rewriting])]
260
+ @aliases[def:]
261
+ @params[
262
+ -p[0|The name of the new macro.]
263
+ -p[0|The macro definition (Glyph code).]
264
+ ]
265
+ @block_example[=
266
+ def:[factorial\|
267
+ ?[
268
+ eq[{{0}}\|0]\|1\|
269
+ multiply[
270
+ {{0}} \| factorial[subtract[{{0}}\|1]]
271
+ ]
272
+ ]
273
+ ]
274
+ factorial[5]
275
+ =]
276
+ @remarks[
277
+ ul[
278
+ li[The new macro &[only_after_declaration].]
279
+ li[&[unsafe]]
280
+ ]
281
+ ]
282
+ ]
283
+
284
+ ref_macro[
285
+ @n[ruby]
286
+ @desc[Evaluates its value as Ruby code within the context of the =>[&[rubydoc]/Glyph|Glyph] module.]
287
+ @aliases[%]
288
+ @examples[=
189
289
  %[Time.now]
190
290
  %[Glyph::VERSION]
191
- =]
192
- @params[-p[0|The Ruby code to evaluate.]]
193
- @remarks[&[unsafe]]
194
- ]
195
-
196
- ref_macro[
197
- @n[snippet]
198
- @desc[Returns the value of a snippet.]
199
- @aliases[&amp;]
200
- @example[=&amp;[glang]=]
201
- @params[-p[0|The ID of the snippet to retrieve.]]
202
- ]
203
-
204
- ref_macro[
205
- @n[snippet:]
206
- @desc[Defines a snippet.]
207
- @remarks[The new snippet &[only_after_declaration].]
208
- @aliases[&amp;:]
209
- @example[=&amp;:[test\|This is a test]=]
210
- @params[
211
- -p[0|The ID of the new snippet.]
212
- -p[1|The contents of the new snippet.]
213
- ]
214
- ]
291
+ =]
292
+ @params[-p[0|The Ruby code to evaluate.]]
293
+ @remarks[&[unsafe]]
294
+ ]
295
+
296
+ ref_macro[
297
+ @n[s]
298
+ @desc[Can be used to dispatch almost any instance method of the ruby =>[http://rubydoc.info/stdlib/core/1.9.2/String|String] class.]
299
+ @examples[=
300
+ s/match[This is a test string\|/test/]
301
+ s/sub[This is a test string\|/a test/\|another test]
302
+ =]
303
+ ]
304
+
305
+ ref_macro[
306
+ @n[snippet]
307
+ @desc[Returns the value of a snippet.]
308
+ @aliases[&amp;]
309
+ @example[=&amp;[glang]=]
310
+ @params[-p[0|The ID of the snippet to retrieve.]]
311
+ ]
312
+
313
+ ref_macro[
314
+ @n[snippet:]
315
+ @desc[Defines a snippet.]
316
+ @remarks[The new snippet &[only_after_declaration].]
317
+ @aliases[&amp;:]
318
+ @example[=&amp;:[test\|This is a test]=]
319
+ @params[
320
+ -p[0|The ID of the new snippet.]
321
+ -p[1|The contents of the new snippet.]
322
+ ]
323
+ ]
324
+
325
+ ref_macro[
326
+ @n[subtract]
327
+ @desc[Subtracts two or more integers together.]
328
+ @params[Two or more integer values.]
329
+ @example[=add[10\|5\|2]=]
330
+ ]
331
+
332
+ ref_macro[
333
+ @n[xml]
334
+ @desc[When used composed with another macro, it can be used to render arbitrary raw XML tags.]
335
+ @example[=xml/img[@src[test.png]@alt[A Test image]]=]
336
+ ]
337
+
338
+ ref_macro[
339
+ @n[while]
340
+ @desc[Keeps evaluating the second parameter while a condition is satisfied.]
341
+ @block_example[=
342
+ let[
343
+ @count[5]
344
+ @text[-]
345
+ while[gt[@[count]\|0]\|
346
+ @:[text\|s/concat[@[text]\|@[count]-]]
347
+ @:[count\|subtract[@[count]\|1]]
348
+ ]
349
+ @[text] --[Outputs: -5-4-3-2-1-]
350
+ ]
351
+ =]
352
+ @params[
353
+ -p[0|The condition to check.]
354
+ -p[1|The code to evaluate while the condition is satisfied.]
355
+ ]
356
+ ]