glyph 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/AUTHORS.textile +1 -1
  2. data/CHANGELOG.textile +119 -222
  3. data/LICENSE.textile +1 -1
  4. data/README.textile +42 -23
  5. data/Rakefile +1 -3
  6. data/VERSION +1 -1
  7. data/benchmark.rb +72 -0
  8. data/book/config.yml +4 -4
  9. data/book/document.glyph +90 -57
  10. data/book/images/document_generation.png +0 -0
  11. data/book/lib/macros/reference.rb +75 -22
  12. data/book/output/html/glyph.html +3183 -2121
  13. data/book/output/html/images/document_generation.png +0 -0
  14. data/book/output/pdf/glyph.pdf +7370 -4913
  15. data/book/resources/document_generation.txt +34 -0
  16. data/book/snippets.yml +6 -0
  17. data/book/text/changelog.glyph +45 -34
  18. data/book/text/compiling/compiling.glyph +23 -0
  19. data/book/text/compiling/lite_mode.glyph +23 -0
  20. data/book/text/compiling/programmatic_usage.glyph +77 -0
  21. data/book/text/extending/bookmarks_headers.glyph +21 -0
  22. data/book/text/extending/further_reading.glyph +13 -0
  23. data/book/text/extending/internals.glyph +79 -0
  24. data/book/text/extending/interpreting.glyph +51 -0
  25. data/book/text/extending/macro_def.glyph +64 -0
  26. data/book/text/extending/params_attrs.glyph +70 -0
  27. data/book/text/extending/placeholders.glyph +34 -0
  28. data/book/text/extending/validators.glyph +16 -0
  29. data/book/text/getting_started/configuration.glyph +49 -0
  30. data/book/text/getting_started/create_project.glyph +41 -0
  31. data/book/text/getting_started/structure.glyph +55 -0
  32. data/book/text/introduction.glyph +49 -26
  33. data/book/text/license.glyph +1 -1
  34. data/book/text/macros/macros_block.glyph +99 -0
  35. data/book/text/macros/macros_core.glyph +208 -0
  36. data/book/text/macros/macros_filters.glyph +40 -0
  37. data/book/text/macros/macros_inline.glyph +50 -0
  38. data/book/text/macros/macros_structure.glyph +100 -0
  39. data/book/text/ref_commands.glyph +94 -73
  40. data/book/text/ref_config.glyph +34 -42
  41. data/book/text/ref_macros.glyph +1 -373
  42. data/book/text/text_editing/code.glyph +51 -0
  43. data/book/text/text_editing/conditionals.glyph +49 -0
  44. data/book/text/text_editing/evaluation.glyph +13 -0
  45. data/book/text/text_editing/glyph_files.glyph +7 -0
  46. data/book/text/text_editing/images.glyph +29 -0
  47. data/book/text/text_editing/inclusions.glyph +44 -0
  48. data/book/text/text_editing/links.glyph +53 -0
  49. data/book/text/text_editing/macro_intro.glyph +111 -0
  50. data/book/text/text_editing/raw_html.glyph +112 -0
  51. data/book/text/text_editing/sections.glyph +63 -0
  52. data/book/text/text_editing/stylesheets.glyph +36 -0
  53. data/book/text/troubleshooting/errors_command.glyph +39 -0
  54. data/book/text/troubleshooting/errors_generic.glyph +29 -0
  55. data/book/text/troubleshooting/errors_intro.glyph +3 -0
  56. data/book/text/troubleshooting/errors_macro.glyph +98 -0
  57. data/book/text/troubleshooting/errors_parser.glyph +29 -0
  58. data/config.yml +77 -58
  59. data/document.glyph +25 -25
  60. data/glyph.gemspec +57 -22
  61. data/lib/glyph.rb +54 -13
  62. data/lib/glyph/commands.rb +84 -17
  63. data/lib/glyph/config.rb +3 -3
  64. data/lib/glyph/document.rb +14 -8
  65. data/lib/glyph/interpreter.rb +18 -58
  66. data/lib/glyph/macro.rb +160 -55
  67. data/lib/glyph/macro_validators.rb +104 -12
  68. data/lib/glyph/node.rb +24 -0
  69. data/lib/glyph/parser.rb +278 -0
  70. data/lib/glyph/syntax_node.rb +225 -0
  71. data/macros/core.rb +212 -0
  72. data/macros/filters.rb +66 -15
  73. data/macros/html/block.rb +43 -105
  74. data/macros/html/inline.rb +11 -12
  75. data/macros/html/structure.rb +123 -58
  76. data/macros/xml.rb +33 -0
  77. data/spec/files/container.textile +2 -2
  78. data/spec/files/document.glyph +2 -2
  79. data/spec/files/document_with_toc.glyph +3 -3
  80. data/spec/files/included.textile +1 -1
  81. data/spec/files/ligature.jpg +0 -0
  82. data/spec/files/markdown.markdown +2 -1
  83. data/spec/lib/commands_spec.rb +46 -3
  84. data/spec/lib/document_spec.rb +4 -4
  85. data/spec/lib/glyph_spec.rb +17 -46
  86. data/spec/lib/interpreter_spec.rb +6 -25
  87. data/spec/lib/macro_spec.rb +141 -43
  88. data/spec/lib/macro_validators_spec.rb +27 -5
  89. data/spec/lib/node_spec.rb +26 -1
  90. data/spec/lib/parser_spec.rb +246 -0
  91. data/spec/lib/syntax_node_spec.rb +111 -0
  92. data/spec/macros/core_spec.rb +195 -0
  93. data/spec/macros/filters_spec.rb +38 -4
  94. data/spec/macros/macros_spec.rb +20 -176
  95. data/spec/macros/textile_spec.rb +13 -71
  96. data/spec/macros/xml_spec.rb +77 -0
  97. data/spec/spec_helper.rb +50 -10
  98. data/spec/tasks/load_spec.rb +13 -2
  99. data/styles/default.css +18 -6
  100. data/styles/pagination.css +1 -19
  101. data/tasks/generate.rake +2 -2
  102. data/tasks/load.rake +27 -17
  103. data/tasks/project.rake +1 -1
  104. metadata +75 -62
  105. data/book/script/compile.rb +0 -8
  106. data/book/script/prof +0 -1
  107. data/book/script/prof_results.htm +0 -21079
  108. data/book/text/authoring.glyph +0 -548
  109. data/book/text/extending.glyph +0 -224
  110. data/book/text/getting_started.glyph +0 -158
  111. data/book/text/troubleshooting.glyph +0 -179
  112. data/lib/glyph/glyph_language.rb +0 -538
  113. data/lib/glyph/glyph_language.treetop +0 -27
  114. data/macros/common.rb +0 -160
@@ -0,0 +1,51 @@
1
+ section[
2
+ @title[Source Code]
3
+ @id[source_code]
4
+ txt[
5
+ If you're a programmer, chances are that you're going to include some source code in your articles and books. Glyph offers two ways to format code blocks effortlessly: the %>[codeblock], which simply wraps text into @<pre>@ and @<code>@ tags, or the %>[highlight]. The last one requires either &[coderay] or &[uv], but it provides syntax highlighting for the most common programming languages.
6
+
7
+ Cosider the following piece of ruby code:
8
+ ]
9
+ highlight[=mediawiki|
10
+ def find_child(&block)
11
+ children.each do \|c\|
12
+ c.descend do \|node, level\|
13
+ return node if block.call(node)
14
+ end
15
+ end
16
+ nil
17
+ end
18
+ =]
19
+ p[It can be wrapped in a highlight macro, like so:]
20
+ highlight[=mediawiki|
21
+ highlight[\=ruby\|
22
+ def find_child(&block)
23
+ children.each do \\\.\|c\\\.\|
24
+ c.descend do \\\.\|node, level\\\.\|
25
+ return node if block.call(node)
26
+ end
27
+ end
28
+ nil
29
+ end
30
+ \=]
31
+ =]
32
+ p[...to produce the following, using the $[filters.highlighter] highlighter:]
33
+ highlight[=ruby|
34
+ def find_child(&block)
35
+ children.each do \|c\|
36
+ c.descend do \|node, level\|
37
+ return node if block.call(node)
38
+ end
39
+ end
40
+ nil
41
+ end
42
+ =]
43
+ box[Some Remarks|
44
+ txt[
45
+ * Highlighters require some configuration. For more information on relevant configuration settings, see the =>[#cfg_filters|filters.*] configuration settings.
46
+ * If you're using the %>[highlight] together within the %>[textile], you must wrap the macro call within @<notextile>@ tags.
47
+ * You must always escape pipes (@\|@) with the code or the highlight macro.
48
+ ]
49
+ ]
50
+ ]
51
+
@@ -0,0 +1,49 @@
1
+ section[
2
+ @title[Conditional Macros]
3
+ @id[cond_macros]
4
+ txt[
5
+ Sometimes you may want text to be included in a document only if certain conditions are satisfied. For example, you may want to display a disclaimer section only if the document is a draft (see the $>[document.draft]), or use a particular stylesheet only if when you generate a PDF document.
6
+
7
+ To do so, you can use the %>[condition] (aliased by @?@), and a set of additional macros that can be used as conditional operators i.e.:
8
+ * %>[eq]
9
+ * %>[not]
10
+ * %>[and]
11
+ * %>[or]
12
+ * %>[match]
13
+
14
+ Consider the following code:
15
+ ]
16
+ highlight[=html|
17
+ ?[$[document.draft]\|
18
+ This is a first draft of the Glyph Book]
19
+ ?[not[$[document.draft]]\|
20
+ This is the official version of the Glyph Book]
21
+ =]
22
+ txt[
23
+ In this case, if @document.draft@ is set to @true@, "This is a first draft of the Glyph Book" will be displayed; if not, "This is the official version of the Glyph Book" will be displayed instead.
24
+
25
+ The %>[condition] takes two parameters:
26
+ * the first one is the condition to evaluate
27
+ * the second one is the text to include in the document only if the condition is satisfied.
28
+
29
+ Note that _both_ parameters can contain macros, of course, so you can write things like:
30
+ ]
31
+ highlight[=html|
32
+ ?[and[
33
+ eq[$[document.output]\|pdf]
34
+ \|
35
+ eq[$[tools.pdf_generator]\|prince]
36
+ ]
37
+ \|
38
+ style[pagination.css]]
39
+ =]
40
+ p[In this case, the code[pagination.css] stylesheet is included only when you're generating a PDF document using Prince XML.]
41
+ section[
42
+ @title[Results of conditional expressions]
43
+ txt[
44
+ The %>[condition] in Glyph works in a similar way as conditionals in programming languages: if the conditional expression (supplied as first parameter) is satisfied then the second parameter is executed or displayed. But when is a conditional expression satisfied? Glyph is a simple mini-language to perform text manipulation, and has no types, it can only understand text, therefore:
45
+ * A conditional expression is satisfied if it evaluates to a non-empty string except "false".
46
+ * A conditional expression is not satisfied if it evaluates to an empty string or the string "false".
47
+ ]
48
+ ]
49
+ ]
@@ -0,0 +1,13 @@
1
+ section[
2
+ @title[Evaluating Ruby code and Configuration Settings]
3
+ txt[
4
+ &[glang] is not a full-blown programming language and it is currently not Turing-complete (it does not provide loops). However, it is possible to evaluate simple ruby code snippets using the @ruby@ macro (aliased to @%@), like this:
5
+ * code[=%[2 + 2]=] &rarr; 4
6
+ * code[=%[Time.now]=] &rarr; %[Time.now]
7
+ * code[=%[Glyph::VERSION]=] &rarr; %[Glyph::VERSION]
8
+
9
+ The scope for the code evaluation is the Kernel module, (with all inclusions required by Glyph itself).
10
+
11
+ Although it is possible to retrieve Glyph configuration settings in this way (e.g. code[=%[cfg('document.author')]=]), the %>[config] (aliased to @$@) makes things slightly simpler (e.g. code[=$[document.author]=]).
12
+ ]
13
+ ]
@@ -0,0 +1,7 @@
1
+ section[
2
+ @title[.glyph files]
3
+ txt[
4
+ The @text@ folder of any Glyph folder contains all the text source files used to produce a document. Although there are no restrictions on the extension of the files in this folder, you may want to use @.glyph@, especially if =>[http://www.vim.org|Vim] is your favorite text editor.
5
+ The reason is simple: a Glyph syntax file is =>[http://www.vim.org/scripts/script.php?script_id=3086|available on vim.org]. Although not essential, syntax highlighting does help when editing Glyph files.
6
+ ]
7
+ ]
@@ -0,0 +1,29 @@
1
+ section[
2
+ @title[Images and Figures]
3
+ @id[img_fig]
4
+ p[Same as for =>[#links|links], you can also include images and figures using &[markups]. If you want additional features, you can use the %>[image] and the %>[figure], as shown in the following example:]
5
+
6
+ box[Example|
7
+ p[&[gcode]]
8
+ highlight[=html|
9
+ image[glyph.svg
10
+ @with[20%]
11
+ @height[20%]
12
+ ]
13
+ figure[example.png\|An example figure.
14
+ @alt[Example Figure]
15
+ ]
16
+ =]
17
+ p[&[htmlcode]]
18
+ highlight[=html|
19
+ <img src="images/glyph.svg" width="20%" height="20%" />
20
+ <div class="figure">
21
+ <img src="images/example.png" alt="Example Figure"/>
22
+ <div class="caption">An example figure.</div>
23
+ </div>
24
+ =]
25
+ txt[Any attribute passed to the %>[image] or the %>[figure] is automatically passed to the underlying @<img>@ tag.]
26
+ ]
27
+ note[In future releases, figures will be numbered automatically and included in a em[List of Figures] section.]
28
+ ]
29
+
@@ -0,0 +1,44 @@
1
+ section[
2
+ @title[Including Files and Snippets]
3
+ @id[incl]
4
+ txt[
5
+ If you're authoring a user manual, a long article, or a book, writing everything inside a single @document.glyph@ file may not be optimal. For this reason, Glyph provides an %>[include] that can be used to include the contents of any file within the @text/@ directory:
6
+
7
+ code[=include[general/introduction.textile]=]
8
+
9
+ The macro call above loads the contents of the @introduction.textile@ file, within the @text/general@ directory.
10
+
11
+ When including a text file, an input filter macro is applied to its contents by default, based on the file extension used:
12
+ * @.textile@ or @.txt@ &rarr; %>[textile]
13
+ * @.markdown@ or @.md@ &rarr; %>[markdown]
14
+
15
+ You can override this behavior by setting the @filters.by_file_extensions@ configuration setting to @false@. If no extension is specified, @.glyph@ is assumed.
16
+
17
+ tip[The %>[include] can also be used to include (and evaluate) ruby files (with a @.rb@ extension). In this case, the ruby file must be placed within the @lib/@ directory of the current project.]
18
+
19
+ 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 or a single word? In this case, you may want to consider using a _snippet_ instead.
20
+
21
+ Snippets are text strings saved in YAML format in the @snippets.yml@ file. They can be included anywhere in your document using the %>[snippet] (or its alias @&@).
22
+
23
+ tip[Besides storing snippets in the @snippets.yml@ file, you can also define them right in your document, using the %>[snippet:].]
24
+ ]
25
+ box[Example|
26
+ p[Consider the following code[snippets.yml] file:]
27
+ highlight[=yaml|
28
+ ---
29
+ :glang: Glyph Language
30
+ :macros: Glyph Macros
31
+ :sq_esc: \\\|-
32
+ Square brackets must be escaped
33
+ unless used as macro delimiters or within a quoting macro.
34
+ :markups: Textile or Markdown
35
+ :test: \\\|-
36
+ This is a
37
+ Test snippet
38
+ =]
39
+ p[You can use code[=&amp;[markups]=] anywhere in your document instead of having to type "\.&[markups]" every time. Additionally, later on you can change the value of the code[markups] snippet only in the code[snippets.yml] file to change it everywhere else in the document.]
40
+ ]
41
+ tip[
42
+ 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 as necessary.
43
+ ]
44
+ ]
@@ -0,0 +1,53 @@
1
+ section[
2
+ @title[Links and Bookmarks]
3
+ @id[links]
4
+ txt[
5
+ 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:
6
+ * you can't check if they are valid
7
+ * you can't infer the link title automatically
8
+
9
+ If you care about link validation and you want to save some keystrokes, then you should use:
10
+ * the %>[link] (aliased to @=>@) -- to create internal and external links.
11
+ * the %>[anchor] (aliased to @#@) -- to create named anchors (bookmarks) within your document.
12
+ ]
13
+ box[Example|
14
+ p[&[gcode]]
15
+ highlight[=html|
16
+ This is a link to link[#test].
17
+ ...
18
+ This is link[#wrong].
19
+ This is a #[test\\\|test anchor].
20
+ =]
21
+ p[&[htmlcode]]
22
+ highlight[=html|
23
+ <p>This is a link to <a href="#test">test anchor</a>.</p>
24
+ <p>...</p>
25
+ <p>This is <a href="#wrong">#wrong</a>.</p>
26
+ <p>This is a <a id="test">test anchor</a>.</p>
27
+ =]
28
+ p[Additionally, the following warning message is displayed when =>[#compile|compiling]:]
29
+ highlight[=html|
30
+ warning: Bookmark 'wrong' does not exist
31
+ -> source: @: authoring.textile
32
+ -> path: document/body/bodymatter/chapter/@/textile/section/section/box/link
33
+ =]
34
+ ]
35
+ txt[
36
+ Basically, if you use the %>[link] and the %>[anchor], Glyph makes sure that:
37
+ * all links point to valid anchors within the document (regardless if the anchors are before or after the link, in snippets or included files).
38
+ * there are no duplicate anchors within the documents.
39
+ * if no title is specified as second parameter for the %>[link], the anchor's name is used as such.
40
+
41
+ Besides using the %>[anchor], you can also create an anchor for a header by passing an code[@id] attribute the the %>[section], like this:
42
+ ]
43
+ highlight[=html|
44
+ section[
45
+ @title[My Section]
46
+ @id[my_section]
47
+ ...
48
+ ]
49
+ =]
50
+ note[
51
+ At present, link validation and automatic title retrieval only works with internal links (i.e. the check occurs if the first parameter of the %>[link] starts with a code[#]). In the future, the macro could be extended to support external (http) links as well.
52
+ ]
53
+ ]
@@ -0,0 +1,111 @@
1
+ section[
2
+ @title[Introducing &[macros]]
3
+ @id[macro_intro]
4
+ txt[
5
+ The most important concept to grasp about Glyph is the concept of _macro_.
6
+
7
+ A Glyph macro is, in a nutshell, 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: @\[@, @\]@, @\\@, @\|@, code[@] 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] can take an optional second parameter for the link text: @\..[=link[#link_id\|This is the link text]=]@.
11
+ * A macro can also have _attributes_, which look exactly like macros but their identifier starts with a code[@].
12
+
13
+ A macro can often have one or more aliases. For example, @=>@ is an alias for the %>[link], so the following macro calls are equivalent:
14
+ * code[=\.=>[#test\|Test Section]=]
15
+ * code[=\.link[#test\|Test Section]=]
16
+ ]
17
+ ]
18
+ section[
19
+ @title[Macro attributes]
20
+ @id[attribute_intro]
21
+ txt[
22
+ Although a macro can take any number of parameters, they are often no more than two or three, for readibility reasons: parameters have no name, but their position within a macro is significant.
23
+
24
+ If you have something like this:
25
+ ]
26
+
27
+ highlight[=html|custom_image[test.png\|50%\|50%\|Test Image]=]
28
+ txt[
29
+ it may still be easy enough to understand what each parameter is used for, but:
30
+ * you can easily forget that the third parameter is the image width
31
+ * if you don't want to resize the image, you still have to pass _empty parameters_ to the macro, like this: code[=custom_image[test2.png\|\|\|Test Image]=]
32
+
33
+ To avoid these situations, some macros which would normally take three or four parameters take optional attributes instead, so you can write:
34
+ ]
35
+ highlight[=html|
36
+ image[test.png
37
+ @width[50%]
38
+ @alt[Test Image]
39
+ @height[50%]
40
+ ]=]
41
+ p[More verbose, of course, but definitely more readable. In this way, if you won't want to scale an image, you can safely omit the code[@width] and code[@height] attributes.]
42
+ note[Like parameters, attributes can contain other macros, too.]
43
+ ]
44
+ section[
45
+ @title[Escaping and Quoting]
46
+ @id[esc_quot]
47
+ txt[
48
+ 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 which case escaping every single square bracket can be painful.
49
+
50
+ If a portion of your text contains an excessive amount of square brackets, you may consider using the %>[escape] (or its alias @.@) with the @\[=@ and @=\]@ delimiters. By itself, the escape macro doesn't do anything: it just evaluates to its contents, but the special delimiters act as an escape for any square bracket within them. As a consequence, any macro within @\[=@ and @=\]@ will _not_ be evaluated.
51
+
52
+ You can use the quoting delimiters with _any_ macro identifier. Obviously, using them as delimiters for things like %>[section]s may not be a good idea, but they should be more or less mandatory with the %>[codeblock] or the %>[highlight], especially when it contains square brackets or even Glyph code, like this:
53
+ ]
54
+
55
+ highlight[=html|
56
+ codeblock\[=
57
+ section[
58
+ @title[A section]
59
+ @id[test]
60
+ This is a section.
61
+ section[
62
+ @title[A nested section]
63
+ This is another section.
64
+ ]
65
+ ]
66
+ \=]
67
+ =]
68
+
69
+ note[Although quoting delimiters allow you to use square brackets without escaping them, you must still escape them if you want to escape quoting delimiters themselves.]
70
+
71
+ p[Besides square brackets, there are other characters that must or can be escaped with backslashes, as shown in the following table:]
72
+
73
+ table[
74
+ tr[
75
+ th[Escape Sequence]
76
+ th[Evaluates to...]
77
+ th[Notes]
78
+ ]
79
+ tr[
80
+ td[code[\\\.\[]]
81
+ td[code[\[]]
82
+ td[&[sq_esc]]
83
+ ]
84
+ tr[
85
+ td[code[\\\.\]]]
86
+ td[code[\]]]
87
+ td[&[sq_esc]]
88
+ ]
89
+ tr[
90
+ td[code[\\\\]]
91
+ td[code[\\]]
92
+ td[Backslashes do not have to be escaped by default, but an escaped backslash will evaluate to itself.]
93
+ ]
94
+ tr[
95
+ td[code[\\\.\=]]
96
+ td[code[\.=]]
97
+ td[Equal signs do not have to be escaped by default, but an escaped equal sign will evaluate to iself.]
98
+ ]
99
+ tr[
100
+ td[code[\\\.\|]]
101
+ td[code[\|]]
102
+ td[Pipes must be escaped (even within quoting macros) unless they are used to separate macro parameters.]
103
+ ]
104
+ tr[
105
+ td[code[\\\..]]
106
+ td[]
107
+ td[An escaped dot evaluates to nothing. Useful to separate macro identifiers from other characters: br[]code[=_\\\\..=>[#link\|This link is emphasized using Textile]_ =]
108
+ ]
109
+ ]
110
+ ]
111
+ ]
@@ -0,0 +1,112 @@
1
+ section[
2
+ txt[So far we examined how to create @<div>@ tags for sections, links, images... but what about lists, tables or paragraphs? How is it possible to create them using Glyphs? You have two possibilities (besides using raw HTML code, that is):
3
+ * use a lightweight markup supported by Glyph (currently &[markups])
4
+ * rely Glyph's _XML fallback_ feature
5
+ ]
6
+ @title[Other HTML Elements]
7
+ @id[other_elements]
8
+ section[
9
+ @title[&[markups]]
10
+ p[&[markups] are very easy and intuitive to use, and they can produce HTML markup with almost no effort. Using them with Glyph is as simple as using the %>[textile] (aliased to code[txt]) and the %>[markdown] (aliased to code[md]).]
11
+ box[Example|
12
+ p[The following Glyph code:]
13
+ highlight[=html|
14
+ textile[
15
+ This is a paragraph with some _emphasized_ text.
16
+
17
+ This is another paragraph with some -deleted- text.
18
+ * This is
19
+ * a bulletted
20
+ * list
21
+ ]
22
+ =]
23
+ p[produces the following HTML code:]
24
+ highlight[=html|
25
+ <p>This is a paragraph with some <em>emphasized</em> text.</p>
26
+ <p>This is a paragraph with some <del>deleted</del> text.</p>
27
+ <ul>
28
+ <li>This is</li>
29
+ <li>a bulletted</li>
30
+ <li>list</li>
31
+ </ul>
32
+ =]
33
+ ]
34
+ important[Be careful when using block-level HTML with Textile and Markdown: sometimes it may be necessary to add extra empty lines or escape tags.]
35
+ ]
36
+ section[
37
+ @title[XML Fallback]
38
+ p[Sure Textile and Markdown are great, but sometimes you may want to just use HTML, without the extra verbosity, of course. Take tables for example: Textile offers an easy way to create them, but things may get dirty when you need to have multiple paragraphs or lists within cells.]
39
+ p[Very early versions of Glyph used to offered some simple code[table], code[tr], code[tr], code[td] macros just for that. Of course the problem was that thy didn't offer any way to customize the markup by adding, for example, CSS classes.]
40
+ p[Instead, by default, Glyph can convert any unrecognized macro to the corresponding XML element and macro attributes to XML attributes.]
41
+ box[Example|
42
+ p[&[gcode]]
43
+ highlight[=html|
44
+ table[@class[features]
45
+ tr[
46
+ th[ID]
47
+ th[Priority]
48
+ th[Description]
49
+ ]
50
+ tr[
51
+ td[27]
52
+ td[span[@style[color:red;font-weight:bold;] HIGH]]
53
+ td[HTML output]
54
+ ]
55
+ tr[
56
+ td[42]
57
+ td[span[@style[color:green;font-weight:bols;] LOW]]
58
+ td[
59
+ p[Support for less-used tags:]
60
+ ul[
61
+ li[cite]
62
+ li[sup]
63
+ li[...]
64
+ ]
65
+ ]
66
+ ]
67
+ ]
68
+ =]
69
+ p[&[htmlcode]]
70
+ highlight[=html|
71
+ <table class="features">
72
+ <tr>
73
+ <th>ID</th>
74
+ <th>Priority</th>
75
+ <th>Description</th>
76
+ </tr>
77
+ <tr>
78
+ <td>27</td>
79
+ <td><span style="color:red;font-weight:bold;">HIGH</span></td>
80
+ <td>HTML output</td>
81
+ </tr>
82
+ <tr>
83
+ <td>42</td>
84
+ <td><span style="color:green;font-weight:bold;">LOW</span></td>
85
+ <td>
86
+ <p>Support for less-used tags:</p>
87
+ <ul>
88
+ <li>cite</li>
89
+ <li>sup</li>
90
+ <li>...</li>
91
+ </ul>
92
+ </td>
93
+ </tr>
94
+ </table>
95
+ =]
96
+ ]
97
+ p[Basically, if the $>[language.options.xml_fallback] is set to code[true], any macro unknown to Glyph with at most one parameter will be converted to an XML tag with the same name and any attribute will be converted to the corresponding XML attribute.]
98
+ important[While macro names and attributes are validated so that an error is returned if they contain illegal character, no check is performed against any particular XML schema.]
99
+ txt[Additionally, it is possible to force macro-to-XML conversion by prepending an equal sign to any macro, so for example code[=\.=snippet[test]=] will be converted into @<snippet>test</snippet>@.]
100
+ ]
101
+ section[
102
+ @title[Blacklisted XML tags]
103
+ @id[xml_blacklist]
104
+ txt[
105
+ By default, the following tags are blacklisted and will be ignored:
106
+ %[="* "+Glyph['language.options.xml_blacklist'].join("\n* ")=]
107
+
108
+ tip[You can change this list by modifying the $>[language.options.xml_blacklist].]
109
+ ]
110
+
111
+ ]
112
+ ]