glyph 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.textile +1 -1
- data/CHANGELOG.textile +119 -222
- data/LICENSE.textile +1 -1
- data/README.textile +42 -23
- data/Rakefile +1 -3
- data/VERSION +1 -1
- data/benchmark.rb +72 -0
- data/book/config.yml +4 -4
- data/book/document.glyph +90 -57
- data/book/images/document_generation.png +0 -0
- data/book/lib/macros/reference.rb +75 -22
- data/book/output/html/glyph.html +3183 -2121
- data/book/output/html/images/document_generation.png +0 -0
- data/book/output/pdf/glyph.pdf +7370 -4913
- data/book/resources/document_generation.txt +34 -0
- data/book/snippets.yml +6 -0
- data/book/text/changelog.glyph +45 -34
- data/book/text/compiling/compiling.glyph +23 -0
- data/book/text/compiling/lite_mode.glyph +23 -0
- data/book/text/compiling/programmatic_usage.glyph +77 -0
- data/book/text/extending/bookmarks_headers.glyph +21 -0
- data/book/text/extending/further_reading.glyph +13 -0
- data/book/text/extending/internals.glyph +79 -0
- data/book/text/extending/interpreting.glyph +51 -0
- data/book/text/extending/macro_def.glyph +64 -0
- data/book/text/extending/params_attrs.glyph +70 -0
- data/book/text/extending/placeholders.glyph +34 -0
- data/book/text/extending/validators.glyph +16 -0
- data/book/text/getting_started/configuration.glyph +49 -0
- data/book/text/getting_started/create_project.glyph +41 -0
- data/book/text/getting_started/structure.glyph +55 -0
- data/book/text/introduction.glyph +49 -26
- data/book/text/license.glyph +1 -1
- data/book/text/macros/macros_block.glyph +99 -0
- data/book/text/macros/macros_core.glyph +208 -0
- data/book/text/macros/macros_filters.glyph +40 -0
- data/book/text/macros/macros_inline.glyph +50 -0
- data/book/text/macros/macros_structure.glyph +100 -0
- data/book/text/ref_commands.glyph +94 -73
- data/book/text/ref_config.glyph +34 -42
- data/book/text/ref_macros.glyph +1 -373
- data/book/text/text_editing/code.glyph +51 -0
- data/book/text/text_editing/conditionals.glyph +49 -0
- data/book/text/text_editing/evaluation.glyph +13 -0
- data/book/text/text_editing/glyph_files.glyph +7 -0
- data/book/text/text_editing/images.glyph +29 -0
- data/book/text/text_editing/inclusions.glyph +44 -0
- data/book/text/text_editing/links.glyph +53 -0
- data/book/text/text_editing/macro_intro.glyph +111 -0
- data/book/text/text_editing/raw_html.glyph +112 -0
- data/book/text/text_editing/sections.glyph +63 -0
- data/book/text/text_editing/stylesheets.glyph +36 -0
- data/book/text/troubleshooting/errors_command.glyph +39 -0
- data/book/text/troubleshooting/errors_generic.glyph +29 -0
- data/book/text/troubleshooting/errors_intro.glyph +3 -0
- data/book/text/troubleshooting/errors_macro.glyph +98 -0
- data/book/text/troubleshooting/errors_parser.glyph +29 -0
- data/config.yml +77 -58
- data/document.glyph +25 -25
- data/glyph.gemspec +57 -22
- data/lib/glyph.rb +54 -13
- data/lib/glyph/commands.rb +84 -17
- data/lib/glyph/config.rb +3 -3
- data/lib/glyph/document.rb +14 -8
- data/lib/glyph/interpreter.rb +18 -58
- data/lib/glyph/macro.rb +160 -55
- data/lib/glyph/macro_validators.rb +104 -12
- data/lib/glyph/node.rb +24 -0
- data/lib/glyph/parser.rb +278 -0
- data/lib/glyph/syntax_node.rb +225 -0
- data/macros/core.rb +212 -0
- data/macros/filters.rb +66 -15
- data/macros/html/block.rb +43 -105
- data/macros/html/inline.rb +11 -12
- data/macros/html/structure.rb +123 -58
- data/macros/xml.rb +33 -0
- data/spec/files/container.textile +2 -2
- data/spec/files/document.glyph +2 -2
- data/spec/files/document_with_toc.glyph +3 -3
- data/spec/files/included.textile +1 -1
- data/spec/files/ligature.jpg +0 -0
- data/spec/files/markdown.markdown +2 -1
- data/spec/lib/commands_spec.rb +46 -3
- data/spec/lib/document_spec.rb +4 -4
- data/spec/lib/glyph_spec.rb +17 -46
- data/spec/lib/interpreter_spec.rb +6 -25
- data/spec/lib/macro_spec.rb +141 -43
- data/spec/lib/macro_validators_spec.rb +27 -5
- data/spec/lib/node_spec.rb +26 -1
- data/spec/lib/parser_spec.rb +246 -0
- data/spec/lib/syntax_node_spec.rb +111 -0
- data/spec/macros/core_spec.rb +195 -0
- data/spec/macros/filters_spec.rb +38 -4
- data/spec/macros/macros_spec.rb +20 -176
- data/spec/macros/textile_spec.rb +13 -71
- data/spec/macros/xml_spec.rb +77 -0
- data/spec/spec_helper.rb +50 -10
- data/spec/tasks/load_spec.rb +13 -2
- data/styles/default.css +18 -6
- data/styles/pagination.css +1 -19
- data/tasks/generate.rake +2 -2
- data/tasks/load.rake +27 -17
- data/tasks/project.rake +1 -1
- metadata +75 -62
- data/book/script/compile.rb +0 -8
- data/book/script/prof +0 -1
- data/book/script/prof_results.htm +0 -21079
- data/book/text/authoring.glyph +0 -548
- data/book/text/extending.glyph +0 -224
- data/book/text/getting_started.glyph +0 -158
- data/book/text/troubleshooting.glyph +0 -179
- data/lib/glyph/glyph_language.rb +0 -538
- data/lib/glyph/glyph_language.treetop +0 -27
- data/macros/common.rb +0 -160
@@ -1,27 +0,0 @@
|
|
1
|
-
grammar GlyphLanguage
|
2
|
-
|
3
|
-
rule expression
|
4
|
-
(escaping_macro / macro / escaped_text)* <GlyphSyntaxNode>
|
5
|
-
end
|
6
|
-
|
7
|
-
rule escaping_macro
|
8
|
-
macro_name '[=' text '=]' <EscapingMacroNode>
|
9
|
-
end
|
10
|
-
|
11
|
-
rule macro
|
12
|
-
macro_name '[' expression ']' <MacroNode>
|
13
|
-
end
|
14
|
-
|
15
|
-
rule escaped_text
|
16
|
-
(('\\' .) / !((macro_name ('[' / '[=')) / (']' / '=]')) .)+ <TextNode>
|
17
|
-
end
|
18
|
-
|
19
|
-
rule text
|
20
|
-
(('\\' .) / !((macro_name '[=') / '=]') .)+ <TextNode>
|
21
|
-
end
|
22
|
-
|
23
|
-
rule macro_name
|
24
|
-
[^\[\]\|\\\s]+
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
data/macros/common.rb
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
macro :snippet do
|
4
|
-
ident = @value.to_sym
|
5
|
-
if Glyph::SNIPPETS.has_key? ident then
|
6
|
-
begin
|
7
|
-
interpret Glyph::SNIPPETS[ident]
|
8
|
-
rescue Exception => e
|
9
|
-
raise if e.is_a? Glyph::MutualInclusionError
|
10
|
-
Glyph.warning e.message
|
11
|
-
macro_todo "Correct errors in snippet '#{@value}'"
|
12
|
-
end
|
13
|
-
else
|
14
|
-
macro_warning "Snippet '#{ident}' does not exist"
|
15
|
-
"[SNIPPET '#{@value}' NOT PROCESSED]"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
macro "snippet:" do
|
20
|
-
exact_parameters 2
|
21
|
-
ident, text = params
|
22
|
-
Glyph::SNIPPETS[ident.to_sym] = text
|
23
|
-
""
|
24
|
-
end
|
25
|
-
|
26
|
-
macro "macro:" do
|
27
|
-
exact_parameters 2
|
28
|
-
ident, code = params
|
29
|
-
Glyph.macro(ident) do
|
30
|
-
instance_eval code
|
31
|
-
end
|
32
|
-
""
|
33
|
-
end
|
34
|
-
|
35
|
-
macro :include do
|
36
|
-
macro_error "Macro not available when compiling a single file." if Glyph.lite?
|
37
|
-
file = nil
|
38
|
-
(Glyph::PROJECT/"text").find do |f|
|
39
|
-
file = f if f.to_s.match /\/#{@value}$/
|
40
|
-
end
|
41
|
-
if file then
|
42
|
-
contents = file_load file
|
43
|
-
ext = @value.match(/\.(.*)$/)[1]
|
44
|
-
if Glyph["filters.by_file_extension"] && ext != 'glyph' then
|
45
|
-
if Glyph::MACROS.include?(ext.to_sym) then
|
46
|
-
contents = "#{ext}[#{contents}]"
|
47
|
-
else
|
48
|
-
macro_warning "Filter macro '#{ext}' not available"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
begin
|
52
|
-
interpret contents
|
53
|
-
rescue Exception => e
|
54
|
-
raise if e.is_a? Glyph::MutualInclusionError
|
55
|
-
Glyph.warning e.message
|
56
|
-
macro_todo "Correct errors in file '#{@value}'"
|
57
|
-
end
|
58
|
-
else
|
59
|
-
macro_warning "File '#{@value}' no found."
|
60
|
-
"[FILE '#{@value}' NOT FOUND]"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
macro :ruby do
|
65
|
-
res = Glyph.instance_eval(@value.gsub(/\\*([\[\]\|])/){$1})
|
66
|
-
res.is_a?(Proc) ? "" : res
|
67
|
-
end
|
68
|
-
|
69
|
-
macro :config do
|
70
|
-
Glyph[@value]
|
71
|
-
end
|
72
|
-
|
73
|
-
macro "config:" do
|
74
|
-
exact_parameters 2
|
75
|
-
setting,value = params
|
76
|
-
Glyph[setting] = value
|
77
|
-
nil
|
78
|
-
end
|
79
|
-
|
80
|
-
macro :comment do
|
81
|
-
""
|
82
|
-
end
|
83
|
-
|
84
|
-
macro :escape do
|
85
|
-
@value
|
86
|
-
end
|
87
|
-
|
88
|
-
macro :encode do
|
89
|
-
encode @value
|
90
|
-
end
|
91
|
-
|
92
|
-
macro :decode do
|
93
|
-
decode @value
|
94
|
-
end
|
95
|
-
|
96
|
-
macro :condition do
|
97
|
-
min_parameters 1
|
98
|
-
max_parameters 2
|
99
|
-
cond, actual_value = params
|
100
|
-
res = interpret(cond)
|
101
|
-
if res.blank? || res == "false" then
|
102
|
-
""
|
103
|
-
else
|
104
|
-
interpret(decode(actual_value))
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
macro :eq do
|
110
|
-
min_parameters 1
|
111
|
-
max_parameters 2
|
112
|
-
a, b = params
|
113
|
-
res_a = interpret(a.to_s)
|
114
|
-
res_b = interpret(b.to_s)
|
115
|
-
(res_a == res_b) ? true : nil
|
116
|
-
end
|
117
|
-
|
118
|
-
macro :not do
|
119
|
-
max_parameters 1
|
120
|
-
v = interpret(@value)
|
121
|
-
(v.blank? || v == "false") ? true : nil
|
122
|
-
end
|
123
|
-
|
124
|
-
macro :and do
|
125
|
-
min_parameters 1
|
126
|
-
max_parameters 2
|
127
|
-
a, b = params
|
128
|
-
res_a = !interpret(a.to_s).blank?
|
129
|
-
res_b = !interpret(b.to_s).blank?
|
130
|
-
(res_a && res_b) ? true : nil
|
131
|
-
end
|
132
|
-
|
133
|
-
macro :or do
|
134
|
-
min_parameters 1
|
135
|
-
max_parameters 2
|
136
|
-
a, b = params
|
137
|
-
res_a = !interpret(a.to_s).blank?
|
138
|
-
res_b = !interpret(b.to_s).blank?
|
139
|
-
(res_a || res_b) ? true : nil
|
140
|
-
end
|
141
|
-
|
142
|
-
macro :match do
|
143
|
-
exact_parameters 2
|
144
|
-
val, regexp = params
|
145
|
-
macro_error "Invalid regular expression: #{regexp}" unless regexp.match /^\/.*\/[a-z]?$/
|
146
|
-
(interpret(val).match(instance_eval(regexp))) ? true : nil
|
147
|
-
end
|
148
|
-
|
149
|
-
macro_alias '--' => :comment
|
150
|
-
macro_alias '*' => :encode
|
151
|
-
macro_alias '**' => :decode
|
152
|
-
macro_alias '&' => :snippet
|
153
|
-
macro_alias '&:' => 'snippet:'
|
154
|
-
macro_alias '%:' => 'macro:'
|
155
|
-
macro_alias '@' => :include
|
156
|
-
macro_alias '%' => :ruby
|
157
|
-
macro_alias '$' => :config
|
158
|
-
macro_alias '$:' => 'config:'
|
159
|
-
macro_alias '.' => :escape
|
160
|
-
macro_alias '?' => :condition
|