glyph 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.textile +8 -0
- data/CHANGELOG.textile +260 -0
- data/LICENSE.textile +26 -0
- data/README.textile +49 -21
- data/Rakefile +17 -7
- data/VERSION +1 -1
- data/book/config.yml +11 -5
- data/book/document.glyph +24 -13
- data/book/lib/macros/reference.rb +41 -14
- data/book/output/html/glyph.html +2298 -687
- data/book/output/pdf/glyph.pdf +6218 -2698
- data/book/script/authors +1 -0
- data/book/script/changelog +1 -0
- data/book/script/compile.rb +8 -0
- data/book/script/license +1 -0
- data/book/script/prof +1 -0
- data/book/script/prof_results.htm +21079 -0
- data/book/script/readme +1 -0
- data/book/snippets.yml +3 -4
- data/book/text/acknowledgement.glyph +8 -0
- data/book/text/authoring.glyph +548 -0
- data/book/text/changelog.glyph +76 -0
- data/book/text/extending.glyph +224 -0
- data/book/text/{getting_started.textile → getting_started.glyph} +30 -24
- data/book/text/{introduction.textile → introduction.glyph} +22 -12
- data/book/text/license.glyph +21 -0
- data/book/text/{ref_commands.textile → ref_commands.glyph} +30 -8
- data/book/text/ref_config.glyph +108 -0
- data/book/text/ref_macros.glyph +378 -0
- data/book/text/troubleshooting.glyph +179 -0
- data/config.yml +16 -4
- data/glyph.gemspec +83 -22
- data/lib/glyph.rb +164 -31
- data/lib/glyph/commands.rb +98 -23
- data/lib/glyph/document.rb +13 -7
- data/lib/glyph/glyph_language.rb +9 -1
- data/lib/glyph/glyph_language.treetop +1 -1
- data/lib/glyph/interpreter.rb +19 -9
- data/lib/glyph/macro.rb +88 -11
- data/lib/glyph/macro_validators.rb +48 -0
- data/lib/glyph/node.rb +13 -1
- data/lib/glyph/system_extensions.rb +0 -28
- data/macros/common.rb +125 -31
- data/macros/filters.rb +19 -13
- data/macros/html/block.rb +119 -68
- data/macros/html/inline.rb +29 -3
- data/macros/html/structure.rb +40 -40
- data/spec/files/article.glyph +5 -0
- data/spec/lib/commands_spec.rb +98 -3
- data/spec/lib/document_spec.rb +15 -2
- data/spec/lib/glyph_spec.rb +39 -10
- data/spec/lib/interpreter_spec.rb +8 -2
- data/spec/lib/macro_spec.rb +54 -6
- data/spec/lib/macro_validators_spec.rb +33 -0
- data/spec/lib/node_spec.rb +11 -3
- data/spec/macros/filters_spec.rb +5 -5
- data/spec/macros/macros_spec.rb +185 -8
- data/spec/macros/textile_spec.rb +217 -0
- data/spec/spec_helper.rb +25 -15
- data/spec/tasks/generate_spec.rb +3 -3
- data/spec/tasks/load_spec.rb +11 -1
- data/spec/tasks/project_spec.rb +0 -3
- data/styles/coderay.css +121 -0
- data/styles/default.css +54 -20
- data/{book/styles/css3.css → styles/pagination.css} +35 -7
- data/styles/ultraviolet/active4d.css +114 -0
- data/styles/ultraviolet/all_hallows_eve.css +72 -0
- data/styles/ultraviolet/amy.css +147 -0
- data/styles/ultraviolet/blackboard.css +88 -0
- data/styles/ultraviolet/brilliance_black.css +605 -0
- data/styles/ultraviolet/brilliance_dull.css +599 -0
- data/styles/ultraviolet/cobalt.css +149 -0
- data/styles/ultraviolet/dawn.css +121 -0
- data/styles/ultraviolet/eiffel.css +121 -0
- data/styles/ultraviolet/espresso_libre.css +109 -0
- data/styles/ultraviolet/idle.css +62 -0
- data/styles/ultraviolet/iplastic.css +80 -0
- data/styles/ultraviolet/lazy.css +73 -0
- data/styles/ultraviolet/mac_classic.css +123 -0
- data/styles/ultraviolet/magicwb_amiga.css +104 -0
- data/styles/ultraviolet/pastels_on_dark.css +188 -0
- data/styles/ultraviolet/slush_poppies.css +85 -0
- data/styles/ultraviolet/spacecadet.css +51 -0
- data/styles/ultraviolet/sunburst.css +180 -0
- data/styles/ultraviolet/twilight.css +137 -0
- data/styles/ultraviolet/zenburnesque.css +91 -0
- data/tasks/generate.rake +45 -26
- data/tasks/load.rake +21 -18
- data/tasks/project.rake +3 -1
- metadata +210 -41
- data/book/styles/default.css +0 -190
- data/book/text/authoring.textile +0 -351
- data/book/text/extending.textile +0 -148
- data/book/text/ref_config.textile +0 -0
- data/book/text/ref_macros.textile +0 -256
- data/book/text/troubleshooting.textile +0 -118
- data/styles/css3.css +0 -220
data/book/styles/default.css
DELETED
@@ -1,190 +0,0 @@
|
|
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
|
-
|
data/book/text/authoring.textile
DELETED
@@ -1,351 +0,0 @@
|
|
1
|
-
section[header[Text Editing]
|
2
|
-
|
3
|
-
One of the aims of Glyph is streamlining text editing. Glyph accomplishes this through its own macro language that can be used in conjunction with &[markups].
|
4
|
-
|
5
|
-
section[header[Introducing &[macros]]
|
6
|
-
|
7
|
-
By now you probably figured out what a macro looks like: it's an identifier of some kind that wraps a value or parameters within square brackets. More specifically:
|
8
|
-
* The macro identifier can contain _any_ character except for: @\[@, @\]@, @\\@, @\|@ or spaces.
|
9
|
-
* The delimiters can be either @\[@ and @\]@ or @\[=@ and @=\]@ (\.fmi[differences between delimiters|#esc_quot]).
|
10
|
-
* The value can be anything, even other macros. If a macro supports more than one parameter, they must be separated with @\|@. For example, the @link@ (@=>@) macro can take an optional second parameter for the link text: @\..[==>[#link_id|This is the link text]=]@.
|
11
|
-
|
12
|
-
todo[Add info about macro aliases]
|
13
|
-
|
14
|
-
]
|
15
|
-
|
16
|
-
section[header[Escaping and Quoting|esc_quot]
|
17
|
-
|
18
|
-
Glyph doesn't require any special control characters like LaTeX, and its macro syntax is very straightforward and liberal. This however comes with a price: because square brackets are used as delimiters, you must escape any square bracket in your text with a backslash. That's not _too_ bad if you think about it, unless you're writing programming code: in that case, escaping every single square bracket can be painful.
|
19
|
-
|
20
|
-
If a portion of your text contains an excessive amount of square brackets, you may consider using the @escape@ macro (or better, its alias @.@) with @\[=@ and @=\]@ as delimiters. By itself, the escape macro doesn't do anything: it just evaluates to its contents, but the special delimiters act as a quote for any square bracket within them. As a consequence, any macro within @\[=@ and @=\]@ will _not_ be evaluated.
|
21
|
-
|
22
|
-
You can use the quoting delimiters with _any_ macro identifier. Obviously, using them as delimiters for things like @section@ macros may not be a good idea, but they should really be mandatory with the @code@ macro, like this:
|
23
|
-
|
24
|
-
code[=
|
25
|
-
code\[=
|
26
|
-
section[header[A section]
|
27
|
-
|
28
|
-
This is a section.
|
29
|
-
|
30
|
-
section[header[A nested section]
|
31
|
-
This is another section.
|
32
|
-
]
|
33
|
-
]
|
34
|
-
=\]
|
35
|
-
=]
|
36
|
-
|
37
|
-
note[Although quoting delimiters allow you to use square brackets without escaping them, you must still escape them if you want to escape quoting delimiter themselves.]
|
38
|
-
|
39
|
-
Besides square brackets, there are other characters that must or can be escaped with backslashes, as shown in the following table
|
40
|
-
|
41
|
-
table[
|
42
|
-
tr[
|
43
|
-
th[Escape Sequence]
|
44
|
-
th[Evaluates to...]
|
45
|
-
th[Notes]
|
46
|
-
]
|
47
|
-
tr[
|
48
|
-
td[@\\\[@]
|
49
|
-
td[@\[@]
|
50
|
-
td[&[sq_esc]]
|
51
|
-
]
|
52
|
-
tr[
|
53
|
-
td[@\\\]@]
|
54
|
-
td[@\]@]
|
55
|
-
td[&[sq_esc]]
|
56
|
-
]
|
57
|
-
tr[
|
58
|
-
td[@\\\\@]
|
59
|
-
td[@\\@]
|
60
|
-
td[Backslashes do not have to be escaped by default, but an escaped backslash will evaluate to itself.]
|
61
|
-
]
|
62
|
-
tr[
|
63
|
-
td[@\\\=@]
|
64
|
-
td[@=@]
|
65
|
-
td[Equal signs do not have to be escaped by default, but an escaped equal sign will evaluate to iself.]
|
66
|
-
]
|
67
|
-
tr[
|
68
|
-
td[@\\\|@]
|
69
|
-
td[@\|@]
|
70
|
-
td[Pipes must be escaped (even within quoting macros) unless they are used to separate two or more macro parameters.]
|
71
|
-
]
|
72
|
-
tr[
|
73
|
-
td[@\\\..@]
|
74
|
-
td[]
|
75
|
-
td[An escaped dot evaluates to nothing. Useful to separate macro identifiers from other characters:
|
76
|
-
@\..[= _\.=>[#link|This is an emphasized link]_ =]@
|
77
|
-
]
|
78
|
-
]
|
79
|
-
]
|
80
|
-
|
81
|
-
] --[End section]
|
82
|
-
|
83
|
-
section[header[Sections and Headers|sec_head]
|
84
|
-
|
85
|
-
Glyph documents are normally organized as a hierarchical tree of nested chapters, appendixes, sections, etc. To define a section, use the @section@ macro, like so:
|
86
|
-
|
87
|
-
code[=
|
88
|
-
section[
|
89
|
-
header[Section #1]
|
90
|
-
|
91
|
-
Write the section contents here...
|
92
|
-
|
93
|
-
section[
|
94
|
-
header[Section #2]
|
95
|
-
|
96
|
-
This section is nested into the previous one.
|
97
|
-
|
98
|
-
] --[End of Section #2]
|
99
|
-
] --[End of Section #1]
|
100
|
-
=]
|
101
|
-
|
102
|
-
This example defines two nested sections, each with its own header. The header is _mandatory_: it will be displayed at the start of the section and in the Table of Contents.
|
103
|
-
|
104
|
-
Note an important difference from HTML: there is no explicit level for the headers, as it will be determined at runtime when the document is compiled, based on how sections are nested. The previous code snippet (taken as it is), for example, will be transformed into the following HTML code:
|
105
|
-
|
106
|
-
<notextile>
|
107
|
-
code[=
|
108
|
-
<div class="section">
|
109
|
-
<h2>Section #1</h2>
|
110
|
-
<p>Write the section contents here...</p>
|
111
|
-
<div class="section">
|
112
|
-
<h3>Section #2</h3>
|
113
|
-
<p>This section is nested in the previous one</p>
|
114
|
-
</div>
|
115
|
-
</div>
|
116
|
-
=]
|
117
|
-
</notextile>
|
118
|
-
|
119
|
-
By default, in Glyph the first header level is _2_, so the two headers are rendered as @h2@ and @h3@, respectively (@--\[...\]@ macros are _comments_, therefore they are not included in the final output).
|
120
|
-
|
121
|
-
There are _a lot_ of macros that can be used in the same way as @section@, one for each element of =>[http://en.wikipedia.org/wiki/Book_design|Book Design]. Each one of them is a simple wrapper for a @<div>@ tag with a class set to its name.
|
122
|
-
|
123
|
-
The following table lists the identifiers of all section-like macros, divided according to the part of the book they should be placed in:
|
124
|
-
|
125
|
-
table[
|
126
|
-
tr[
|
127
|
-
td[*Frontmatter*]
|
128
|
-
td[@imprint@ ^†^, @dedication@ ^†^, @inspiration@ ^†^, @foreword@ ^‡^, @introduction@ ^‡^, @acknowledgement@ ^‡^, @prologue@ ^‡^, @toc@ ^*^]
|
129
|
-
]
|
130
|
-
tr[
|
131
|
-
td[*Bodymatter*]
|
132
|
-
td[@volume@, @book@, @part@, @chapter@]
|
133
|
-
]
|
134
|
-
tr[
|
135
|
-
td[*Backmatter*]
|
136
|
-
td[@epilogue@ ^‡^, @afterword@ ^‡^, @postscript@ ^†^, @appendix@, @addendum@ ^‡^, @glossary@ ^**‡^, @colophon@ ^†^, @bibliography@ ^**‡^, @promotion@ ^†^, @references@ ^**‡^, @index@ ^**‡^, @lot@ ^**‡^, @lof@ ^**‡^]
|
137
|
-
]
|
138
|
-
]
|
139
|
-
|
140
|
-
<notextile>*</notextile>: The @toc@ macro is to generate the Table of Contents automatically, and it must be used with no contents (@toc\[\]@).
|
141
|
-
|
142
|
-
<notextile>**</notextile>: This macro is likely to be extended in future versions to generate/aggregate content automatically.
|
143
|
-
|
144
|
-
†: This section is not listed in the Table of Contents.
|
145
|
-
|
146
|
-
‡: Any subsection of this section is not listed in the Table of Contents.
|
147
|
-
|
148
|
-
note[@frontmatter@, @bodymatter@ and @backmatter@ are also valid (and mandatory!) macro identifiers, typically already included in the default @document.glyph@ file of every project.]
|
149
|
-
|
150
|
-
] --[End section]
|
151
|
-
|
152
|
-
section[header[Including Files and Snippets]
|
153
|
-
|
154
|
-
If you're authoring a user manual, a long article or a book, writing everything inside a single file (@document.glyph@) may not be optimal. For this reason, Glyph provides an @include@ macro (aliased by codeph[@]) that can be used to include the contents of any file within the @text/@ directory:
|
155
|
-
|
156
|
-
codeph[=@[introduction.textile]=]
|
157
|
-
|
158
|
-
The macro above loads the contents of the @introduction.textile@ file, that can be stored _anywhere_ within the @text/@ directory.
|
159
|
-
|
160
|
-
note[Unlike with =>[img_fig|image and figures] that must be included with their _relative_ path to the @images/@ folder, you must not specify a relative path when including text files. This is due to the fact that images are copied _as they are_ in the @output/<format>/images/@ directory and they have to be linked from the output file.
|
161
|
-
|
162
|
-
A possible downside of this behavior is that file names must be unique within the entire @text/@ directory (or any of its subdirectories)]
|
163
|
-
|
164
|
-
When including a text file, by default an input filter macro is applied to its contents based on the file extension used:
|
165
|
-
* @.textile@ → @textile@
|
166
|
-
* @.markdown@ or @.md@ → @markdown@
|
167
|
-
|
168
|
-
tip[You can override this behavior by setting the @filters.by_file_extensions@ configuration setting to @false@, like this:
|
169
|
-
|
170
|
-
@glyph config filters.by_file_extensions false@]
|
171
|
-
|
172
|
-
While including the context of an entire file is definitely a useful feature for content reuse, sometimes it can be an overkill. What if, for example, you just want to reuse a short procedure or even a sentence? In this case, you may want to consider using a _snippet_ instead.
|
173
|
-
|
174
|
-
Snippets are text strings saved in YAML format in the @snippets.yml@ file. They can be included anywhere in your document using the @snippet@ macro (or its alias @&@).
|
175
|
-
|
176
|
-
box[Example|
|
177
|
-
Consider the following @snippets.yml@ file:
|
178
|
-
code[=
|
179
|
-
---
|
180
|
-
:glang: Glyph Language
|
181
|
-
:macros: Glyph Macros
|
182
|
-
:sq_esc: \|-
|
183
|
-
Square brackets must be escaped
|
184
|
-
unless used as macro delimiters or within a quoting macro.
|
185
|
-
:markups: Textile or Markdown
|
186
|
-
:test: \|-
|
187
|
-
This is a
|
188
|
-
Test snippet
|
189
|
-
=]
|
190
|
-
You can use codeph[=&[markups]=] anywhere in your document instead of having to type "Textile or Markdown" every time. Additionally, later on you can change the value of the @markups@ snippets only in the @snippets.yml@ file to change it everywhere else in the document.
|
191
|
-
] --[End Example]
|
192
|
-
tip[
|
193
|
-
Snippets (or any other macro) can be nested within other snippets. Glyph takes care of checking if you nested snippets or macros mutually and warns you if necessary.
|
194
|
-
]
|
195
|
-
] --[End Section]
|
196
|
-
|
197
|
-
|
198
|
-
section[header[Links and Bookmarks|links]
|
199
|
-
|
200
|
-
Lightweight markups let you create internal and external links in a very easy way, and you can still do so in Glyph. However, if you do so:
|
201
|
-
* There is no built-in way to check if they are valid
|
202
|
-
* There is no built-in way to determine the title of a link automatically
|
203
|
-
|
204
|
-
If you care about link validation and you want to save some keystrokes, then you should use the following markup-agnostic &[macros]:
|
205
|
-
* @link@ (aliased to @=>@) -- to create internal and external links.
|
206
|
-
* @anchor@ (aliased to @#@) -- to create named anchors (bookmarks) within your document.
|
207
|
-
|
208
|
-
box[Example|
|
209
|
-
|
210
|
-
&[gcode]
|
211
|
-
|
212
|
-
code[=
|
213
|
-
This is a link to =>[#test].
|
214
|
-
|
215
|
-
...
|
216
|
-
|
217
|
-
This is =>[#wrong].
|
218
|
-
|
219
|
-
This is a #[test\|test anchor].
|
220
|
-
=]
|
221
|
-
|
222
|
-
&[htmlcode]
|
223
|
-
|
224
|
-
<notextile>
|
225
|
-
code[=
|
226
|
-
<p>This is a link to <a href="#test">test anchor</a>.</p>
|
227
|
-
<p>...</p>
|
228
|
-
<p>This is <a href="#wrong">#wrong</a>.</p>
|
229
|
-
<p>This is a <a id="test">test anchor</a>.</p>
|
230
|
-
=]
|
231
|
-
</notextile>
|
232
|
-
|
233
|
-
Additionally, the following warning message is displayed when =>[#compile|compiling]:
|
234
|
-
|
235
|
-
<notextile>
|
236
|
-
code[=
|
237
|
-
warning: Bookmark 'wrong' does not exist
|
238
|
-
-> source: @: aurhoting.textile
|
239
|
-
-> path: document/body/bodymatter/chapter/@/textile/section/section/box/=>
|
240
|
-
=]
|
241
|
-
</notextile>
|
242
|
-
|
243
|
-
]
|
244
|
-
|
245
|
-
Basically, if you use the @=>@ and @#@ macros, Glyph makes sure that:
|
246
|
-
* All links point to valid anchors within the document (regardless if the anchors are before or after the link, in snippets or included files).
|
247
|
-
* There are no duplicate anchors within the documents.
|
248
|
-
* If no title is specified as second parameter for the @=>@ macro, the anchor's title is used as such.
|
249
|
-
|
250
|
-
Besides using the @#@ macro, you can also create an anchor for a header by passing an extra parameter to the @header@ macro, like this: codeph[=header[Header Title|my_anchor]=].
|
251
|
-
|
252
|
-
note[
|
253
|
-
At present, link validation and automatic title retrieval only works with internal links (i.e. the check occurs if the first parameter of the @=>@ macro starts with a @#@). In the future, the macro could be extended to support external links as well.
|
254
|
-
]
|
255
|
-
|
256
|
-
] --[End section]
|
257
|
-
|
258
|
-
section[header[Evaluating Ruby code and Configuration Settings]
|
259
|
-
|
260
|
-
&[glang] is not a full-blown programming language, as it does not provide control flow or variables, for example.
|
261
|
-
However, it is possible to evaluate simple ruby code snippets using the @ruby@ macro (aliased to @%@), like this:
|
262
|
-
* codeph[=%[2 + 2]=] → 4
|
263
|
-
* codeph[=%[Time.now]=] → %[Time.now]
|
264
|
-
* codeph[=%[Glyph::VERSION]=] → %[Glyph::VERSION]
|
265
|
-
|
266
|
-
The scope for the code evaluation is the Kernel module, (with all inclusions required by Glyph itself).
|
267
|
-
|
268
|
-
Although it is possible to retrieve Glyph configuration settings in this way (e.g. codeph[=%[cfg('document.author')]=]), the @config@ macro (aliased to @$@) makes things slightly simpler (e.g. codeph[=$[document.author]=]).
|
269
|
-
|
270
|
-
]
|
271
|
-
|
272
|
-
section[header[Images and Figures|img_fig]
|
273
|
-
|
274
|
-
In a similar way to =>[#links|links], if you want you can include images and figures using &[markups]. If you want additional features, you can use the @img@ and @fig@ macros, as shown in the following example:
|
275
|
-
|
276
|
-
box[Example|
|
277
|
-
|
278
|
-
&[gcode]
|
279
|
-
|
280
|
-
code[=
|
281
|
-
img[glyph.svg\|20%\|20%]
|
282
|
-
|
283
|
-
fig[example.png\|An example figure.]
|
284
|
-
=]
|
285
|
-
|
286
|
-
&[htmlcode]
|
287
|
-
|
288
|
-
<notextile>
|
289
|
-
code[=
|
290
|
-
|
291
|
-
<img src="images/glyph.svg" width="20%" height="20%" alt="-" />
|
292
|
-
|
293
|
-
<div class="figure">
|
294
|
-
<img src="images/example.png" alt="-"/>
|
295
|
-
<div class="caption">An example figure.</div>
|
296
|
-
</div>
|
297
|
-
=]
|
298
|
-
</notextile>
|
299
|
-
|
300
|
-
]
|
301
|
-
|
302
|
-
note[
|
303
|
-
In future releases, figures will be numbered automatically and included in a _List of Figures_ section.
|
304
|
-
]
|
305
|
-
|
306
|
-
] --[End of section]
|
307
|
-
|
308
|
-
|
309
|
-
] --[End of Text Editing section]
|
310
|
-
|
311
|
-
section[header[Compiling your project|compile]
|
312
|
-
|
313
|
-
By default, a Glyph project can be _compiled_ into an HTML document. Additionally, Glyph can also be used to produce PDF documents through &[prince], and in future releases more formats are likely to be supported.
|
314
|
-
|
315
|
-
section[header[Adding Stylesheets|stylesheets]
|
316
|
-
|
317
|
-
Currently, Glyph does not provide any native way to format text and pages. The reason is that there's absolutely no need for that: CSS does the job just fine. In particular, CSS 3 offers specific attributes and elements that can be used specifically for paginated documents. That's no replacement for LaTeX by any means, but it is enough if you're not looking for advanced typographical features.
|
318
|
-
|
319
|
-
You can embed CSS files using the @style@ macro, like this:
|
320
|
-
|
321
|
-
code[= style[default.css] =]
|
322
|
-
|
323
|
-
In this case, the @style@ macro looks for a @default.css@ file in the @/styles@ folder of your Glyph project and embeds it within a @<style>@ tag. If you supply a file with a @.sass@ extension, it will interpret it as a Sass file and convert it to CSS automatically (if the _Haml_ gem is installed).
|
324
|
-
|
325
|
-
]
|
326
|
-
|
327
|
-
section[header[HTML output]
|
328
|
-
|
329
|
-
To compile a Glyph project to an HTML document, use the @glyph compile@ command within your Glyph project folder. Glyph parses the @document.glyph@ file (and all included files and snippets); if no errors are found, Glyph creates an HTML document in the @/output/html@ folder. The name of the HTML file can be set in the configuration (@document.filename@ setting).
|
330
|
-
|
331
|
-
If you don't want to compile the whole project, you can specify a different source, like this:
|
332
|
-
|
333
|
-
code[= glyph compile -s myfile.textile =]
|
334
|
-
|
335
|
-
]
|
336
|
-
|
337
|
-
section[header[PDF Output]
|
338
|
-
|
339
|
-
To generate a PDF document, you must specify @pdf@ as format, like this:
|
340
|
-
|
341
|
-
code[= glyph compile -f pdf =]
|
342
|
-
|
343
|
-
The command above will attempt to compile the project into an HTML document and then call Prince to generate a PDF document from it. In order for this to work, you must download and install &[prince]. It's not open source, but the free version is fully functional, and it just adds a small logo on the first page.
|
344
|
-
|
345
|
-
note[Glyph v\.%[Glyph::VERSION.strip] has been successfully tested with Prince v7.0, and the PDF version of this very book was generated with it.]
|
346
|
-
|
347
|
-
]
|
348
|
-
|
349
|
-
]
|
350
|
-
|
351
|
-
|