glyph 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/AUTHORS.textile +8 -0
  2. data/CHANGELOG.textile +260 -0
  3. data/LICENSE.textile +26 -0
  4. data/README.textile +49 -21
  5. data/Rakefile +17 -7
  6. data/VERSION +1 -1
  7. data/book/config.yml +11 -5
  8. data/book/document.glyph +24 -13
  9. data/book/lib/macros/reference.rb +41 -14
  10. data/book/output/html/glyph.html +2298 -687
  11. data/book/output/pdf/glyph.pdf +6218 -2698
  12. data/book/script/authors +1 -0
  13. data/book/script/changelog +1 -0
  14. data/book/script/compile.rb +8 -0
  15. data/book/script/license +1 -0
  16. data/book/script/prof +1 -0
  17. data/book/script/prof_results.htm +21079 -0
  18. data/book/script/readme +1 -0
  19. data/book/snippets.yml +3 -4
  20. data/book/text/acknowledgement.glyph +8 -0
  21. data/book/text/authoring.glyph +548 -0
  22. data/book/text/changelog.glyph +76 -0
  23. data/book/text/extending.glyph +224 -0
  24. data/book/text/{getting_started.textile → getting_started.glyph} +30 -24
  25. data/book/text/{introduction.textile → introduction.glyph} +22 -12
  26. data/book/text/license.glyph +21 -0
  27. data/book/text/{ref_commands.textile → ref_commands.glyph} +30 -8
  28. data/book/text/ref_config.glyph +108 -0
  29. data/book/text/ref_macros.glyph +378 -0
  30. data/book/text/troubleshooting.glyph +179 -0
  31. data/config.yml +16 -4
  32. data/glyph.gemspec +83 -22
  33. data/lib/glyph.rb +164 -31
  34. data/lib/glyph/commands.rb +98 -23
  35. data/lib/glyph/document.rb +13 -7
  36. data/lib/glyph/glyph_language.rb +9 -1
  37. data/lib/glyph/glyph_language.treetop +1 -1
  38. data/lib/glyph/interpreter.rb +19 -9
  39. data/lib/glyph/macro.rb +88 -11
  40. data/lib/glyph/macro_validators.rb +48 -0
  41. data/lib/glyph/node.rb +13 -1
  42. data/lib/glyph/system_extensions.rb +0 -28
  43. data/macros/common.rb +125 -31
  44. data/macros/filters.rb +19 -13
  45. data/macros/html/block.rb +119 -68
  46. data/macros/html/inline.rb +29 -3
  47. data/macros/html/structure.rb +40 -40
  48. data/spec/files/article.glyph +5 -0
  49. data/spec/lib/commands_spec.rb +98 -3
  50. data/spec/lib/document_spec.rb +15 -2
  51. data/spec/lib/glyph_spec.rb +39 -10
  52. data/spec/lib/interpreter_spec.rb +8 -2
  53. data/spec/lib/macro_spec.rb +54 -6
  54. data/spec/lib/macro_validators_spec.rb +33 -0
  55. data/spec/lib/node_spec.rb +11 -3
  56. data/spec/macros/filters_spec.rb +5 -5
  57. data/spec/macros/macros_spec.rb +185 -8
  58. data/spec/macros/textile_spec.rb +217 -0
  59. data/spec/spec_helper.rb +25 -15
  60. data/spec/tasks/generate_spec.rb +3 -3
  61. data/spec/tasks/load_spec.rb +11 -1
  62. data/spec/tasks/project_spec.rb +0 -3
  63. data/styles/coderay.css +121 -0
  64. data/styles/default.css +54 -20
  65. data/{book/styles/css3.css → styles/pagination.css} +35 -7
  66. data/styles/ultraviolet/active4d.css +114 -0
  67. data/styles/ultraviolet/all_hallows_eve.css +72 -0
  68. data/styles/ultraviolet/amy.css +147 -0
  69. data/styles/ultraviolet/blackboard.css +88 -0
  70. data/styles/ultraviolet/brilliance_black.css +605 -0
  71. data/styles/ultraviolet/brilliance_dull.css +599 -0
  72. data/styles/ultraviolet/cobalt.css +149 -0
  73. data/styles/ultraviolet/dawn.css +121 -0
  74. data/styles/ultraviolet/eiffel.css +121 -0
  75. data/styles/ultraviolet/espresso_libre.css +109 -0
  76. data/styles/ultraviolet/idle.css +62 -0
  77. data/styles/ultraviolet/iplastic.css +80 -0
  78. data/styles/ultraviolet/lazy.css +73 -0
  79. data/styles/ultraviolet/mac_classic.css +123 -0
  80. data/styles/ultraviolet/magicwb_amiga.css +104 -0
  81. data/styles/ultraviolet/pastels_on_dark.css +188 -0
  82. data/styles/ultraviolet/slush_poppies.css +85 -0
  83. data/styles/ultraviolet/spacecadet.css +51 -0
  84. data/styles/ultraviolet/sunburst.css +180 -0
  85. data/styles/ultraviolet/twilight.css +137 -0
  86. data/styles/ultraviolet/zenburnesque.css +91 -0
  87. data/tasks/generate.rake +45 -26
  88. data/tasks/load.rake +21 -18
  89. data/tasks/project.rake +3 -1
  90. metadata +210 -41
  91. data/book/styles/default.css +0 -190
  92. data/book/text/authoring.textile +0 -351
  93. data/book/text/extending.textile +0 -148
  94. data/book/text/ref_config.textile +0 -0
  95. data/book/text/ref_macros.textile +0 -256
  96. data/book/text/troubleshooting.textile +0 -118
  97. data/styles/css3.css +0 -220
@@ -6,8 +6,7 @@ describe Glyph::Interpreter do
6
6
  before do
7
7
  delete_project
8
8
  create_project
9
- Glyph.run! 'load:macros'
10
- Glyph.run! 'load:snippets'
9
+ Glyph.run! 'load:all'
11
10
  end
12
11
 
13
12
 
@@ -87,4 +86,11 @@ describe Glyph::Interpreter do
87
86
  {:"@" => 1}, {:markdown => 2},{:section => 3}, {:header => 4}]
88
87
  end
89
88
 
89
+
90
+ it "should provide diagnostic information on errors" do
91
+ failure = "Incorrect macro syntax\n -> -- [Line 1, Column 13]"
92
+ # This is probably the only type of error recognized which can occur at parser level
93
+ lambda { interpret "section[em[]" }.should raise_error(Glyph::SyntaxError, failure)
94
+ end
95
+
90
96
  end
@@ -4,8 +4,8 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper")
4
4
  describe Glyph::Macro do
5
5
 
6
6
  before do
7
- Glyph.macro :test do |node|
8
- "Test: #{node[:value]}"
7
+ Glyph.macro :test do
8
+ "Test: #{@value}"
9
9
  end
10
10
  create_tree = lambda {|text| }
11
11
  create_doc = lambda {|tree| }
@@ -17,14 +17,30 @@ describe Glyph::Macro do
17
17
  end
18
18
 
19
19
  it "should raise macro errors" do
20
- lambda { @macro.macro_error "Error!" }.should raise_error(MacroError)
21
-
20
+ lambda { @macro.macro_error "Error!" }.should raise_error(Glyph::MacroError)
22
21
  end
23
22
 
24
23
  it "should interpret strings" do
25
24
  @macro.interpret("test[--]").should == "Test: --"
26
25
  end
27
26
 
27
+ it "should not interpret escaped macros" do
28
+ Glyph.macro :int_1 do
29
+ "->#{interpret(@value)}<-"
30
+ end
31
+ Glyph.macro :int_2 do
32
+ "=>#{interpret(@value)}<="
33
+ end
34
+ text1 = "int_1[int_2[Test]]"
35
+ text2 = "int_1[=int_2[Test]=]"
36
+ text3 = "int_1[=int_2\\[Test\\]=]"
37
+ text4 = "int_2[int_1[=int_1[wrong_macro[Test]]=]]"
38
+ @macro.interpret(text1).should == "->=>Test<=<-"
39
+ @macro.interpret(text2).should == "->int_2\\[Test\\]<-"
40
+ @macro.interpret(text3).should == "->int_2\\[Test\\]<-"
41
+ @macro.interpret(text4).should == "=>->int_1\\[wrong_macro\\[Test\\]\\]<-<="
42
+ end
43
+
28
44
  it "should store and check bookmarks" do
29
45
  h = { :id => "test2", :title => "Test 2" }
30
46
  @macro.bookmark h
@@ -53,8 +69,40 @@ describe Glyph::Macro do
53
69
  create_project
54
70
  Glyph.run! 'load:macros'
55
71
  Glyph::SNIPPETS[:inc] = "Test &[inc]"
56
- @macro.interpret("&[inc] test").should == "Test [SNIPPET 'inc' NOT PROCESSED] test"
72
+ lambda {interpret("&[inc] test").document}.should raise_error(Glyph::MutualInclusionError)
57
73
  end
58
74
 
59
- end
75
+ it "should encode and decode text" do
76
+ Glyph.run! "load:all"
77
+ Glyph.macro :sec_1 do
78
+ res = decode "section[header[Test1]\n#{@value}]"
79
+ interpret res
80
+ end
81
+ Glyph.macro :sec_2 do
82
+ encode "section[section[header[Test2]\n#@value]]"
83
+ end
84
+ text1 = %{sec_1[sec_2[Test]]}
85
+ interpret text1
86
+ res1 = @p.document.output.gsub(/\t/, '')
87
+ text2 = %{section[header[Test1]
88
+ section[section[header[Test2]
89
+ Test]]]}
90
+ interpret text2
91
+ res2 = @p.document.output.gsub(/\t/, '')
92
+ result = "<div class=\"section\">
93
+ <h2 id=\"h_1\">Test1</h2>
94
+ <div class=\"section\">
95
+ <div class=\"section\">
96
+ <h4 id=\"h_2\">Test2</h4>
97
+ Test
98
+
99
+ </div>
100
+
101
+ </div>
60
102
 
103
+ </div>".gsub(/\t/, '')
104
+ res1.should == result
105
+ res2.should == result
106
+ end
107
+
108
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
3
+
4
+ describe Glyph::Macro::Validators do
5
+
6
+ before do
7
+ Glyph.run! 'load:all'
8
+ Glyph.macro :validated_test do
9
+ validate("Invalid Macro"){ @value == "valid" }
10
+ "Validated Test: #{@value}"
11
+ end
12
+ end
13
+
14
+ it "should provide custom validation" do
15
+ lambda { interpret("section[validated_test[invalid]]").document.output }.should raise_error Glyph::MacroError
16
+ lambda { interpret("chapter[validated_test[valid]]").document.output }.should_not raise_error
17
+ end
18
+
19
+ it "should validate the number of parameters" do
20
+ # exact
21
+ lambda { interpret("table[]").document.output }.should raise_error Glyph::MacroError
22
+ # none
23
+ lambda { interpret("toc[test]").document.output }.should raise_error Glyph::MacroError
24
+ # min
25
+ lambda { interpret("img[]").document.output }.should raise_error Glyph::MacroError
26
+ # max
27
+ lambda { interpret("not[a|b|c]").document.output }.should raise_error Glyph::MacroError
28
+ # correct
29
+ lambda { interpret("chapter[fmi[something|#something]]").document.output }.should_not raise_error Glyph::MacroError
30
+ end
31
+
32
+ end
33
+
@@ -26,7 +26,15 @@ describe Node do
26
26
  lambda { @ht << {:e => 5, :f => 6}.to_node }.should_not raise_error
27
27
  @ht.child(1) << {:g => 7, :h => 8}
28
28
  @ht.child(1) << {:i => 9, :j => 10}
29
- ((@ht>>1>>1)[:j]).should == 10
29
+ ((@ht&1&1)[:j]).should == 10
30
+ l = (@ht&1).length
31
+ orphan = @ht&1&0
32
+ orphan.parent.should == @ht&1
33
+ (@ht&1).children.include?(orphan).should == true
34
+ (@ht&1) >> orphan
35
+ (@ht&1).children.length.should == l-1
36
+ orphan.parent.should == nil
37
+ (@ht&1).children.include?(orphan).should == false
30
38
  end
31
39
 
32
40
  it "should support iteration" do
@@ -55,8 +63,8 @@ describe Node do
55
63
  @ht << {:e => 5, :f => 6}
56
64
  @ht.child(1) << {:g => 7, :h => 8}
57
65
  @ht.child(1).child(0) << {:i => 9, :j => 10}
58
- (@ht>>1>>0>>0).parent.should == @ht>>1>>(0)
59
- (@ht>>1>>0>>0).root.should == @ht
66
+ (@ht&1&0&0).parent.should == @ht&1&0
67
+ (@ht&1&0&0).root.should == @ht
60
68
  end
61
69
 
62
70
  it "should find child nodes" do
@@ -17,11 +17,11 @@ describe "Filter Macros" do
17
17
  text = "textile[This is a _TEST_(TM).]"
18
18
  interpret text
19
19
  @p.document.output.should == "<p>This is a <em><span class=\"caps\">TEST</span></em>&#8482;.</p>"
20
- run_command ["config", "filters.target", :latex]
20
+ Glyph['filters.target'] = :latex
21
21
  interpret text
22
22
  @p.document.output.should == "This is a \\emph{TEST}\\texttrademark{}.\n\n"
23
- run_command ["config", "filters.target", ":html"]
24
- run_command ["config", "filters.redcloth.restrictions", "[:no_span_caps]"]
23
+ Glyph['filters.target'] = :html
24
+ Glyph['filters.redcloth.restrictions'] = [:no_span_caps]
25
25
  interpret text
26
26
  @p.document.output.should == "<p>This is a <em>TEST</em>&#8482;.</p>"
27
27
  end
@@ -33,10 +33,10 @@ describe "Filter Macros" do
33
33
  - item 2
34
34
  - item 3
35
35
 
36
- ...]"
36
+ etc.]"
37
37
  interpret text
38
38
  @p.document.output.gsub(/\n|\t/, '').should ==
39
- "<p>This is a test:</p><ul><li>item 1</li><li>item 2</li><li>item 3</li></ul><p>...</p>"
39
+ "<p>This is a test:</p><ul><li>item 1</li><li>item 2</li><li>item 3</li></ul><p>etc.</p>"
40
40
  end
41
41
 
42
42
  end
@@ -5,11 +5,11 @@ describe "Macro:" do
5
5
 
6
6
  before do
7
7
  create_project
8
- Glyph.run! 'load:macros'
9
- Glyph.run! 'load:snippets'
8
+ Glyph.run! 'load:all'
10
9
  end
11
10
 
12
11
  after do
12
+ Glyph.lite_mode = false
13
13
  delete_project
14
14
  end
15
15
 
@@ -18,7 +18,7 @@ describe "Macro:" do
18
18
  doc = @p.document
19
19
  doc.output.should == "this is a <a id=\"test\">test</a>."
20
20
  doc.bookmarks.has_key?(:test).should == true
21
- lambda { interpret "this is a #[test|test]. #[test|This won't work!]"; @p.document }.should raise_error(MacroError)
21
+ lambda { interpret "this is a #[test|test]. #[test|This won't work!]"; @p.document }.should raise_error(Glyph::MacroError)
22
22
  end
23
23
 
24
24
  it "snippet" do
@@ -39,6 +39,50 @@ describe "Macro:" do
39
39
  @p.document.output.should == %{Test. This is a link to something afterwards: <a href="#other">Test</a>. <a id="other">Test</a>.}
40
40
  end
41
41
 
42
+ it "snippet:" do
43
+ interpret("&[t1] - &:[t1|Test #1] - &[t1]")
44
+ @p.document.output.should == "[SNIPPET 't1' NOT PROCESSED] - - Test #1"
45
+ Glyph::SNIPPETS[:t1].should == "Test #1"
46
+ Glyph::SNIPPETS.delete :t1
47
+ end
48
+
49
+ it "condition" do
50
+ define_em_macro
51
+ interpret("?[$[document.invalid]|em[test]]")
52
+ @p.document.output.should == ""
53
+ interpret("?[$[document.output]|em[test]]")
54
+ @p.document.output.should == "<em>test</em>"
55
+ interpret("?[not[eq[$[document.output]|]]|em[test]]")
56
+ @p.document.output.should == "<em>test</em>"
57
+ interpret %{?[
58
+ or[
59
+ eq[$[document.target]|htmls]|
60
+ not[eq[$[document.author]|x]]
61
+ ]|em[test]]}
62
+ @p.document.output.should == "<em>test</em>"
63
+ # "false" should be regarded as false
64
+ interpret(%{?[%["test".blank?]|---]})
65
+ @p.document.output.should == ""
66
+ interpret("?[not[match[$[document.source]|/^docu/]]|em[test]]")
67
+ @p.document.output.should == ""
68
+ # Invalid regexp
69
+ lambda { interpret("?[match[$[document.source]|document]em[test]]").document.output }.should raise_error
70
+ interpret "?[%[lite?]|test]"
71
+ @p.document.output.should == ""
72
+ interpret "?[%[!lite?]|test]"
73
+ @p.document.output.should == "test"
74
+ interpret "?[%[lite?]|%[\"test\"]]"
75
+ @p.document.output.should == ""
76
+ # Condition not satisfied...
77
+ interpret "?[%[lite?]|*[= %[ Glyph\\['test_config'\\] = true ] =]]"
78
+ @p.document.output.should == ""
79
+ Glyph['test_config'].should_not == true
80
+ # Condition satisfied...
81
+ interpret "?[%[!lite?]|*[= --[%[ Glyph\\['test_config'\\] = true ]] =]]"
82
+ @p.document.output.should == ""
83
+ Glyph['test_config'].should == true
84
+ end
85
+
42
86
  it "section, chapter, header" do
43
87
  text = "chapter[header[Chapter X] ... section[header[Section Y|sec-y] ... section[header[Another section] ...]]]"
44
88
  interpret text
@@ -57,7 +101,7 @@ describe "Macro:" do
57
101
  end
58
102
 
59
103
  it "include" do
60
- Glyph.config_override "filters.by_extension", true
104
+ Glyph["filters.by_extension"] = true
61
105
  text = file_load(Glyph::PROJECT/'text/container.textile')
62
106
  interpret text
63
107
  @p.document.output.gsub(/\n|\t|_\d{1,3}/, '').should == %{
@@ -72,12 +116,52 @@ describe "Macro:" do
72
116
  }.gsub(/\n|\t|_\d{1,3}/, '')
73
117
  end
74
118
 
119
+ it "include should not work in Lite mode" do
120
+ text = file_load(Glyph::PROJECT/'text/container.textile')
121
+ Glyph.lite_mode = true
122
+ lambda { interpret(text).document.output }.should raise_error Glyph::MacroError
123
+ Glyph.lite_mode = false
124
+ end
75
125
 
76
- it "style" do
77
- interpret "style[test.sass]"
78
- @p.document.output.gsub(/\n|\t/, '').should == "<style type=\"text/css\">#main { background-color: #0000ff; }</style>"
126
+ it "document, head, style" do
127
+ interpret "document[head[style[test.sass]]]"
128
+ @p.document.output.gsub(/\n|\t/, '').should == %{
129
+ <?xml version="1.0" encoding="utf-8"?>
130
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
131
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
132
+ <head>
133
+ <title>#{Glyph::CONFIG.get("document.title")}</title>
134
+ <meta name="author" content="#{Glyph["document.author"]}" />
135
+ <meta name="copyright" content="#{Glyph["document.author"]}" />
136
+ <meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
137
+ <style type=\"text/css\">#main { background-color: #0000ff; }</style>
138
+ </head>
139
+ </html>
140
+ }.gsub(/\n|\t/, '')
79
141
  end
80
142
 
143
+ it "style should link files by absolute or relative path in Lite mode" do
144
+ result = %{
145
+ <?xml version="1.0" encoding="utf-8"?>
146
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
147
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
148
+ <head>
149
+ <title>#{Glyph::CONFIG.get("document.title")}</title>
150
+ <meta name="author" content="#{Glyph["document.author"]}" />
151
+ <meta name="copyright" content="#{Glyph["document.author"]}" />
152
+ <meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
153
+ <style type=\"text/css\">#main { background-color: #0000ff; }</style>
154
+ </head>
155
+ </html>
156
+ }.gsub(/\n|\t/, '')
157
+ Glyph.lite_mode = true
158
+ Dir.chdir Glyph::PROJECT
159
+ interpret "document[head[style[styles/test.sass]]]"
160
+ @p.document.output.gsub(/\n|\t/, '').should == result
161
+ interpret "document[head[style[#{Glyph::PROJECT}/styles/test.sass]]]"
162
+ @p.document.output.gsub(/\n|\t/, '').should == result
163
+ end
164
+
81
165
  it "escape" do
82
166
  define_em_macro
83
167
  text = %{This is a test em[This can .[=contain test[macros em[test]]=]]}
@@ -88,12 +172,23 @@ describe "Macro:" do
88
172
  it "ruby" do
89
173
  interpret "2 + 2 = %[2+2]"
90
174
  @p.document.output.should == %{2 + 2 = 4}
175
+ interpret "%[lite?]"
176
+ @p.document.output.should == %{false}
177
+ interpret "%[def test; end]"
91
178
  end
92
179
 
93
180
  it "config" do
94
- Glyph.config_override "test.setting", "TEST"
181
+ Glyph["test.setting"] = "TEST"
182
+ interpret "test.setting = $[test.setting]"
183
+ @p.document.output.should == %{test.setting = TEST}
184
+ end
185
+
186
+ it "config:" do
187
+ Glyph["test.setting"] = "TEST"
95
188
  interpret "test.setting = $[test.setting]"
96
189
  @p.document.output.should == %{test.setting = TEST}
190
+ interpret "test.setting = $:[test.setting|TEST2]$[test.setting]"
191
+ @p.document.output.should == %{test.setting = TEST2}
97
192
  end
98
193
 
99
194
  it "toc" do
@@ -146,6 +241,19 @@ describe "Macro:" do
146
241
  }.gsub(/\n|\t/, '')
147
242
  end
148
243
 
244
+ it "img should link files by absolute or relative path in Lite mode" do
245
+ result = %{
246
+ <img src="images/ligature.jpg"
247
+ width="90%" height="90%" alt="-"/>
248
+ }.gsub(/\n|\t/, '')
249
+ Glyph.lite_mode = true
250
+ Dir.chdir Glyph::PROJECT
251
+ interpret "img[images/ligature.jpg|90%|90%]"
252
+ @p.document.output.gsub(/\t|\n/, '').should == result
253
+ interpret "img[#{Glyph::PROJECT}/images/ligature.jpg|90%|90%]"
254
+ @p.document.output.gsub(/\t|\n/, '').gsub(Glyph::PROJECT.to_s+'/', '').should == result
255
+ end
256
+
149
257
  it "fig" do
150
258
  interpret "fig[ligature.jpg|Ligature]"
151
259
  @p.document.output.gsub(/\t|\n/, '').should == %{
@@ -156,4 +264,73 @@ describe "Macro:" do
156
264
  }.gsub(/\n|\t/, '')
157
265
  end
158
266
 
267
+ it "fig should link files by absolute or relative path in Lite mode" do
268
+ result = %{
269
+ <div class="figure">
270
+ <img src="images/ligature.jpg" alt="-"/>
271
+ <div class="caption">Ligature</div>
272
+ </div>
273
+ }.gsub(/\n|\t/, '')
274
+ Glyph.lite_mode = true
275
+ Dir.chdir Glyph::PROJECT
276
+ interpret "fig[images/ligature.jpg|Ligature]"
277
+ @p.document.output.gsub(/\t|\n/, '').should == result
278
+ interpret "fig[#{Glyph::PROJECT}/images/ligature.jpg|Ligature]"
279
+ @p.document.output.gsub(/\t|\n/, '').gsub(Glyph::PROJECT.to_s+'/', '').should == result
280
+ end
281
+
282
+ it "draftcomment, todo" do
283
+ text1 = "dc[comment!]"
284
+ text2 = "![todo!]"
285
+ interpret text1
286
+ @p.document.output.should == ""
287
+ interpret text2
288
+ @p.document.output.should == ""
289
+ Glyph['document.draft'] = true
290
+ interpret text1
291
+ @p.document.output.should == %{<span class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>comment!</span>}
292
+ interpret text2
293
+ @p.document.output.should == %{<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>todo!</span>}
294
+ @p.document.todos.length.should == 1
295
+ Glyph['document.draft'] = false
296
+ end
297
+
298
+ it "highlight" do
299
+ cr = false
300
+ uv = false
301
+ begin
302
+ require 'coderay'
303
+ cr = true
304
+ rescue Exception
305
+ end
306
+ begin
307
+ require 'uv'
308
+ uv = true
309
+ rescue Exception
310
+ end
311
+ code = %{def test_method(a, b)
312
+ puts a+b
313
+ end}
314
+ cr_result = %{<div class=\"CodeRay\"> <div class=\"code\"><pre> <span class=\"r\">def</span>
315
+ <span class=\"fu\">test_method</span>(a, b) puts a+b <span class=\"r\">end</span></pre></div> </div>}
316
+ uv_result = %{<pre class=\"iplastic\"> <span class=\"Keyword\">def</span>
317
+ <span class=\"FunctionName\">test_method</span>(<span class=\"Arguments\">a<span class=\"Arguments\">,</span> b</span>)
318
+ puts a<span class=\"Keyword\">+</span>b <span class=\"Keyword\">end</span> </pre>}
319
+ Glyph['highlighters.ultraviolet.theme'] = 'iplastic'
320
+ check = lambda do |hl, result|
321
+ Glyph["highlighters.current"] = hl
322
+ Glyph.debug_mode = true
323
+ interpret("highlight[=ruby|\n#{code}=]")
324
+ @p.document.output.gsub(/\s+/, ' ').strip.should == result.gsub(/\s+/, ' ').strip
325
+ end
326
+ check.call 'ultraviolet', uv_result if uv
327
+ check.call 'coderay', cr_result if cr
328
+ end
329
+
330
+ it "macro:" do
331
+ interpret '%:[e_macro|
332
+ "Test: #@value"]e_macro[OK!]'
333
+ @p.document.output.should == "Test: OK!"
334
+ end
335
+
159
336
  end