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
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
3
+
4
+ describe "load" do
5
+
6
+ before do
7
+ delete_project
8
+ create_project
9
+ end
10
+
11
+ after do
12
+ delete_project
13
+ end
14
+
15
+ it "should raise an error unless PROJECT is a valid project directory" do
16
+ delete_project
17
+ lambda { Glyph.run! 'load:all' }.should raise_error
18
+ end
19
+
20
+ it "[snippets] should load snippet definitions" do
21
+ lambda { Glyph.run! 'load:snippets'}.should_not raise_error
22
+ Glyph::SNIPPETS[:test].blank?.should == false
23
+ end
24
+
25
+ it "[macros] should load macro definitions" do
26
+ lambda { Glyph.run! 'load:macros'}.should_not raise_error
27
+ Glyph::MACROS[:note].blank?.should == false
28
+ Glyph::MACROS[:"#"].blank?.should == false
29
+ end
30
+
31
+ it "[config] should load configuration files and apply overrides" do
32
+ Glyph::PROJECT_CONFIG.blank?.should == false
33
+ Glyph::SYSTEM_CONFIG.blank?.should == false
34
+ cfg('structure.headers').class.to_s.should == "Array"
35
+ end
36
+
37
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
3
+
4
+ describe "project:create" do
5
+
6
+ before do
7
+ create_project_dir
8
+ end
9
+
10
+ after do
11
+ delete_project_dir
12
+ end
13
+
14
+ it "[create] should not create a new project if no valid directory is supplied" do
15
+ lambda { Glyph.run! 'project:create', 'test_dir' }.should raise_error
16
+ end
17
+
18
+ it "[create] should create a new project if an existing empty directory is supplied" do
19
+ lambda { Glyph.run! 'project:create', Glyph::PROJECT }.should_not raise_error
20
+ (Glyph::PROJECT/'lib').exist?.should == true
21
+ (Glyph::PROJECT/'lib/tasks').exist?.should == true
22
+ (Glyph::PROJECT/'lib/macros').exist?.should == true
23
+ (Glyph::PROJECT/'lib/macros/html').exist?.should == true
24
+ (Glyph::PROJECT/'document.glyph').exist?.should == true
25
+ (Glyph::PROJECT/'config.yml').exist?.should == true
26
+ (Glyph::PROJECT/'text').exist?.should == true
27
+ (Glyph::PROJECT/'styles').exist?.should == true
28
+ (Glyph::PROJECT/'images').exist?.should == true
29
+ (Glyph::PROJECT/'output').exist?.should == true
30
+ end
31
+
32
+ it "[add] should add new files to project" do
33
+ create_project
34
+ lambda { Glyph.run 'project:add', 'test.textile'}.should_not raise_error
35
+ (Glyph::PROJECT/'text/test.textile').exist?.should == true
36
+ lambda { Glyph.run 'project:add', 'test.textile'}.should raise_error
37
+ lambda { Glyph.run 'project:add', 'chapter1/test.textile'}.should_not raise_error
38
+ (Glyph::PROJECT/'text/chapter1/test.textile').exist?.should == true
39
+ end
40
+
41
+ end
data/styles/css3.css ADDED
@@ -0,0 +1,220 @@
1
+ @page {
2
+ size: A4;
3
+ margin: 40pt 30pt 40pt 30pt;
4
+ @top {
5
+ content: string(book-title) " · " string(book-subtitle) " – " string(chapter-title);
6
+ font-style: italic;
7
+ }
8
+ @bottom { content: counter(page, decimal); }
9
+ }
10
+
11
+ @page frontmatter {
12
+ @bottom { content: counter(page, lower-roman); }
13
+ }
14
+
15
+ @page backmatter {
16
+ @bottom { content: counter(page, decimal); }
17
+ }
18
+
19
+ @page:first {
20
+ padding-top: 20%;
21
+ @top { content: normal; }
22
+ @bottom { content: normal; }
23
+ }
24
+
25
+ .toc li a::after {
26
+ content: leader('.') target-counter(attr(href), page);
27
+ }
28
+
29
+ .titlepage h1 {
30
+ string-set: book-title content();
31
+ }
32
+
33
+ .titlepage h2 {
34
+ string-set: book-subtitle content();
35
+ }
36
+
37
+ .toc>li[class~=chapter] {
38
+ counter-increment: toc1;
39
+ counter-reset: toc2;
40
+ }
41
+
42
+ .toc>li[class~=appendix] {
43
+ counter-increment: appendix1;
44
+ counter-reset: toc2;
45
+ }
46
+
47
+ .toc ol li[class] {
48
+ counter-increment: toc2;
49
+ counter-reset: toc3;
50
+ }
51
+
52
+ .toc ol ol li[class] {
53
+ counter-increment: toc3;
54
+ counter-reset: toc4;
55
+ }
56
+
57
+ .toc ol ol ol li[class] {
58
+ counter-increment: toc4;
59
+ counter-reset: toc5;
60
+ }
61
+
62
+ .toc ol ol ol ol li[class] {
63
+ counter-increment: toc5;
64
+ }
65
+
66
+ .toc>li[class~=chapter]::before {
67
+ content: counter(toc1) ". ";
68
+ }
69
+
70
+
71
+ .toc>li[class~=appendix]::before {
72
+ content: counter(appendix1, upper-latin) ". ";
73
+ }
74
+
75
+ .toc>li[class] {
76
+ margin: 1em 0;
77
+ }
78
+
79
+ .toc ol li[class~=bodymatter]::before {
80
+ margin-left: 1em;
81
+ content: counter(toc1) "." counter(toc2) " ";
82
+ }
83
+ .toc ol li[class~=appendix]::before {
84
+ margin-left: 1em;
85
+ content: counter(appendix1, upper-latin) "." counter(toc2) " ";
86
+ }
87
+
88
+
89
+ .toc ol ol li[class~=bodymatter]::before {
90
+ margin-left: 1em;
91
+ content: counter(toc1) "." counter(toc2) "." counter(toc3) " ";
92
+ }
93
+ .toc ol ol li[class~=appendix]::before {
94
+ margin-left: 1em;
95
+ content: counter(appendix1, upper-latin) "." counter(toc2) "." counter(toc3) " ";
96
+ }
97
+
98
+ .toc ol ol ol li[class~=bodymatter]::before {
99
+ margin-left: 1em;
100
+ content: counter(toc1) "." counter(toc2) "." counter(toc3) "." counter(toc4) " ";
101
+ }
102
+ .toc ol ol ol li[class~=appendix]::before {
103
+ margin-left: 1em;
104
+ content: counter(appendix1, upper-latin) "." counter(toc2) "." counter(toc3) "." counter(toc4) " ";
105
+ }
106
+
107
+ .toc ol ol ol ol li[class~=bodymatter]::before {
108
+ margin-left: 1em;
109
+ content: counter(toc1) "." counter(toc2) "." counter(toc3) "." counter(toc4) "." counter(toc5) " ";
110
+ }
111
+ .toc ol ol ol ol li[class~=appendix]::before {
112
+ margin-left: 1em;
113
+ content: counter(appendix1, upper-latin) "." counter(toc2) "." counter(toc3) "." counter(toc4) "." counter(toc5) " ";
114
+ }
115
+
116
+ div.frontmatter{
117
+ page: frontmatter;
118
+ }
119
+
120
+ div.backmatter{
121
+ page: backmatter;
122
+ }
123
+
124
+ .bodymatter h2::before {
125
+ content: "Chapter " counter(h2, upper-roman) " – ";
126
+ counter-reset: footnote;
127
+ }
128
+
129
+ .backmatter h2::before {
130
+ content: "Appendix " counter(a2, upper-latin) " – ";
131
+ }
132
+
133
+ .bodymatter h3::before {
134
+ content: counter(h2) "." counter(h3) " ";
135
+ }
136
+
137
+ .backmatter h3::before {
138
+ content: counter(a2, upper-latin) "." counter(h3) " ";
139
+ }
140
+
141
+ .bodymatter h4::before {
142
+ content: counter(h2) "." counter(h3) "." counter(h4) " ";
143
+ }
144
+
145
+ .backmatter h4::before {
146
+ content: counter(a2, upper-latin) "." counter(h3) "." counter(h4) " ";
147
+ }
148
+
149
+ .bodymatter h5::before {
150
+ content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " ";
151
+ }
152
+
153
+ .backmatter h5::before {
154
+ content: counter(a2, upper-latin) "." counter(h3) "." counter(h4) "." counter(h5) " ";
155
+ }
156
+
157
+ h2 {
158
+ string-set: chapter-title content();
159
+ page-break-before: always;
160
+ }
161
+
162
+ .titlepage h2 {
163
+ page-break-before: avoid;
164
+ }
165
+
166
+ .bodymatter h2{
167
+ counter-increment: h2;
168
+ counter-reset: h3;
169
+ }
170
+
171
+ .backmatter h2{
172
+ counter-increment: a2;
173
+ counter-reset: h3;
174
+ }
175
+
176
+ .bodymatter h3, .backmatter h3 {
177
+ counter-increment: h3;
178
+ counter-reset: h4;
179
+ }
180
+
181
+ .bodymatter h4, .backmatter h4 {
182
+ counter-increment: h4;
183
+ counter-reset: h5;
184
+ }
185
+
186
+ .bodymatter h5, .backmatter h5 {
187
+ counter-increment: h5;
188
+ }
189
+
190
+ h2, h3, h4, h5 { page-break-after: avoid }
191
+ table, .box, .note, .important, .tip, .caution, .code { page-break-inside: avoid }
192
+
193
+ /* Footnotes */
194
+
195
+ @page {
196
+ @footnotes {
197
+ border-top: 1px solid #000;
198
+ }
199
+ }
200
+
201
+ .fn {
202
+ font-size: 85%;
203
+ margin-left: 1.5em;
204
+ display: prince-footnote;
205
+ counter-increment: footnote;
206
+ }
207
+
208
+ .fn::footnote-call {
209
+ content: counter(footnote);
210
+ font-size: 85%;
211
+ vertical-align: super;
212
+ line-height: none;
213
+ font-weight: bold;
214
+ margin-left: 1pt;
215
+ }
216
+
217
+ .fn::footnote-marker {
218
+ font-weight: bold;
219
+ margin-right: 0.5em;
220
+ }
@@ -0,0 +1,190 @@
1
+ * {
2
+ border: none;
3
+ font-family: inherit;
4
+ font-size: 100%;
5
+ font-style: inherit;
6
+ margin: 0;
7
+ padding: 0;
8
+ }
9
+ html {
10
+ background: #fff;
11
+ }
12
+ p, ol, ul {
13
+ margin: 0.3em 0;
14
+ }
15
+ table {
16
+ border-collapse: collapse;
17
+ border-spacing: 0;
18
+ margin: auto;
19
+ margin-top: 1em;
20
+ }
21
+ body {
22
+ line-height: 1.2em;
23
+ margin: 0;
24
+ padding: 0;
25
+ padding: 0 1em;
26
+ text-align: justify;
27
+ }
28
+
29
+ /* Structure */
30
+ .titlepage {
31
+ margin: auto;
32
+ text-align: center;
33
+ }
34
+ .title, h1 {
35
+ font-size: 2.5em;
36
+ font-weight: bold;
37
+ line-height: 1.5em;
38
+ margin-bottom: 0.2em;
39
+ }
40
+ .titlepage h2 {
41
+ font-size: 1.1em;
42
+ font-style: italic;
43
+ font-weight: bold;
44
+ line-height: 1.2em;
45
+ margin-bottom: 0.5em;
46
+ prince-bookmark-level: none;
47
+ }
48
+ .author {
49
+ font-size: 1em;
50
+ }
51
+ .pubdate {
52
+ font-size: 0.8em;
53
+ }
54
+ li {
55
+ list-style-type: square;
56
+ margin: 0.4em 0;
57
+ margin-left: 1.5em;
58
+ }
59
+ ol li{
60
+ list-style-type: decimal;
61
+ }
62
+ img {
63
+ margin: 0 5px;
64
+ padding: 2px;
65
+ }
66
+ dt {
67
+ font-weight: bold;
68
+ margin-top: 1em;
69
+ }
70
+ dd {
71
+ font-style: italic;
72
+ }
73
+ p {
74
+ margin: 1em 0;
75
+ }
76
+ ol.toc {
77
+ margin-left: 1.5em;
78
+ }
79
+ .toc > li[class] {
80
+ font-weight: bold;
81
+ }
82
+ .toc li {
83
+ list-style-type: none;
84
+ margin-left: 0;
85
+ }
86
+ .toc li a, .toc li a:hover {
87
+ color: #000;
88
+ }
89
+ table {
90
+ border: 1px solid #E6E6E6;
91
+ }
92
+ th {
93
+ background: #EEE;
94
+ }
95
+ tr, td, th {
96
+ padding: 5px;
97
+ }
98
+ td, tr {
99
+ border: 1px solid #E6E6E6;
100
+ }
101
+ sup {
102
+ font-size: 0.7em;
103
+ font-weight: bold;
104
+ margin-left: -0.4em;
105
+ }
106
+ /* BLOCKS */
107
+ .center {
108
+ margin: auto;
109
+ text-align: center;
110
+ }
111
+ .left {
112
+ margin: auto;
113
+ text-align: left;
114
+ }
115
+ .right {
116
+ margin: auto;
117
+ text-align: center;
118
+ }
119
+
120
+ .note,
121
+ .important,
122
+ .tip,
123
+ .caution,
124
+ .box {
125
+ border: 1px solid #E6E6E6;
126
+ display: block;
127
+ margin: 0.5em auto;
128
+ padding: 0 0.5em;
129
+ width: 600px;
130
+ background: #EEE;
131
+ color: #1F1F1F;
132
+ }
133
+ .note-title {
134
+ font-weight: bold;
135
+ margin-right: 1em;
136
+ }
137
+ .box-title {
138
+ display: block;
139
+ text-align: center;
140
+ font-weight: bold;
141
+ }
142
+ .code {
143
+ margin: 1em auto;
144
+ padding: 0.5em;
145
+ width: 600px;
146
+ }
147
+ /* TEXT */
148
+ body {
149
+ color: #000;
150
+ font-size: 1em;
151
+ }
152
+ h2 {
153
+ display: block;
154
+ font-size: 2em;
155
+ font-weight: bold;
156
+ margin: 3em 0 1em 0;
157
+ }
158
+ h3 {
159
+ font-size: 1.6em;
160
+ font-weight: normal;
161
+ margin: 3em 0 1em 0;
162
+ }
163
+ h4 {
164
+ font-size: 1.3em;
165
+ font-weight: normal;
166
+ margin: 3em 0 1em 0;
167
+ }
168
+ em {
169
+ font-style: italic;
170
+ }
171
+ a {
172
+ color: #8A1513;
173
+ text-decoration: none;
174
+ }
175
+ a:hover {
176
+ color: #CF282D;
177
+ }
178
+ code {
179
+ font-size: 0.75em;
180
+ }
181
+
182
+ /* FONTS */
183
+ body {
184
+ font-family: "Book Antiqua", "Times New Roman", "Serif";
185
+ }
186
+
187
+ code {
188
+ font-family: "Droid Sans Mono", "Consolas", "Monaco", "Courier", "Monospace";
189
+ }
190
+